[PATCH 2/3] BZ 782574 raise exception when unable to connect to iwhd/provider account

Jan Provaznik jprovazn at redhat.com
Mon Feb 6 09:28:53 UTC 2012


On 02/03/2012 08:48 PM, Tzu-Mainn Chen wrote:
> ---
>   src/app/models/deployable.rb       |    2 ++
>   src/app/models/instance.rb         |    4 ++++
>   src/app/models/provider_account.rb |    2 +-
>   3 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/src/app/models/deployable.rb b/src/app/models/deployable.rb
> index c9df4c5..eba7e01 100644
> --- a/src/app/models/deployable.rb
> +++ b/src/app/models/deployable.rb
> @@ -69,6 +69,8 @@ class Deployable<  ActiveRecord::Base
>     def fetch_images
>       uuids = fetch_image_uuids || []
>       uuids.map { |uuid| Aeolus::Image::Warehouse::Image.find(uuid) }
> +  rescue Exception =>  e
> +    raise I18n.t("images.errors.could_not_connect", :message =>  e.message)
>     end
>
>     def fetch_image_uuids
> diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
> index 03bc119..cfa614a 100644
> --- a/src/app/models/instance.rb
> +++ b/src/app/models/instance.rb
> @@ -179,10 +179,14 @@ class Instance<  ActiveRecord::Base
>
>     def image
>       Aeolus::Image::Warehouse::Image.find(image_uuid) if image_uuid
> +  rescue Exception =>  e
> +    raise I18n.t("images.errors.could_not_connect", :message =>  e.message)
>     end
>
>     def image_build
>       Aeolus::Image::Warehouse::ImageBuild.find(image_build_uuid) if image_build_uuid
> +  rescue Exception =>  e
> +    raise I18n.t("images.errors.could_not_connect", :message =>  e.message)
>     end

Warehouse lib is now used on 40 places in conductor - so there are still 
many other not covered situations.

All warehouse connect requests are done by 'do_request' method in
aeolus-image-rubygem/lib/aeolus_image/model/warehouse/warehouse_client.rb and 
now it raises Errno::ECONNREFUSED exception.

The method could be updated to raise something like 
Warehouse::ConnectionRefused and then you can define "rescue_from 
Warehouse::ConnectionRefused" in application_controller.rb -> this could 
cover all warehouse connection problems.

>
>     def build
> diff --git a/src/app/models/provider_account.rb b/src/app/models/provider_account.rb
> index 89009aa..e29a637 100644
> --- a/src/app/models/provider_account.rb
> +++ b/src/app/models/provider_account.rb
> @@ -140,7 +140,7 @@ class ProviderAccount<  ActiveRecord::Base
>       rescue Exception =>  e
>         logger.error("Error connecting to framework: #{e.message}")
>         logger.error("Backtrace: #{e.backtrace.join("\n")}")
> -      return nil
> +      raise I18n.t("provider_accounts.errors.could_not_connect", :message =>  e.message)

Ideally a more specific exception type could be defined/raised (e.g. 
DC::ConnectionRefused).

There are some places in conductor where nil value is used to check if 
connect was successful. If this method newly raises an exception, all 
these places should be fixed too.

Through ProviderAccount is done only part of all deltacloud connections, 
there is also Provider#connect method which doeas same/similar thing - 
errors for provider connects should be handled in the same way.

>       end
>     end
>

Jan



More information about the aeolus-devel mailing list