[PATCH conductor] BZ 801527: wrong error message when imagefactory is down

Martyn Taylor mtaylor at redhat.com
Thu Sep 6 13:15:58 UTC 2012


I've tested this manually and it works fine.

Can you please add tests for both this patch and its conductor 
counterpart.  Also can you change the error message from: 'imagefactory 
is dead, Jim!'  to something a bit better ;)

Your free to push with these changes in.

Cheers

Martyn


On 03/15/2012 03:51 PM, mzatko at redhat.com wrote:
> From: Maros Zatko <mzatko at redhat.com>
>
> https://bugzilla.redhat.com/show_bug.cgi?id=801527
>
> API:
> * new API exception ServiceUnavailable
> * rescue for ECONNREFUSED when imagefactory is down
> ---
>   src/app/controllers/api/images_controller.rb |   14 +++++++++-----
>   src/lib/exceptions.rb                        |    1 +
>   2 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/src/app/controllers/api/images_controller.rb b/src/app/controllers/api/images_controller.rb
> index 465a20b..2bcbeee 100644
> --- a/src/app/controllers/api/images_controller.rb
> +++ b/src/app/controllers/api/images_controller.rb
> @@ -89,11 +89,15 @@ module Api
>               :template => @tpl.uuid,
>               :environment => @pool_family.name
>             })
> -          @image = Aeolus::Image::Factory::Image.new(:id => iwhd_image.id)
> -          @image.targets = req[:params][:targets]
> -          @image.template = req[:params][:template]
> -          @image.save!
> -          respond_with(@image)
> +          begin
> +            @image = Aeolus::Image::Factory::Image.new(:id => iwhd_image.id)
> +            @image.targets = req[:params][:targets]
> +            @image.template = req[:params][:template]
> +            @image.save!
> +            respond_with(@image)
> +          rescue Errno::ECONNREFUSED
> +            raise(Aeolus::Conductor::API::ServiceUnavailable.new(503, 'Imagefactory is dead, Jim!'))
> +          end
>           elsif req[:type] == :import
>             account = ProviderAccount.find_by_label(req[:params][:provider_account_name])
>             raise(Aeolus::Conductor::API::ProviderAccountNotFound.new(404, t("api.error_messages.provider_account_not_found",
> diff --git a/src/lib/exceptions.rb b/src/lib/exceptions.rb
> index d56ddb3..9b1edab 100644
> --- a/src/lib/exceptions.rb
> +++ b/src/lib/exceptions.rb
> @@ -38,6 +38,7 @@ module Aeolus
>         class ProviderImageDeleteFailure < Error; end
>         class ProviderImageNotFound < Error; end
>         class ProviderImageStatusNotFound < Error; end
> +      class ServiceUnavailable < Error; end
>         class TargetImageDeleteFailure < Error; end
>         class TargetImageNotFound < Error; end
>         class TargetImageStatusNotFound < Error; end





More information about the aeolus-devel mailing list