Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept Hash object as result of inter region api invocation #18210

Conversation

yrudman
Copy link
Contributor

@yrudman yrudman commented Nov 15, 2018

Issue:
Setting retirement date on Service via Centralized Administration generates error in log:

ERROR -- : [InterRegionApiMethodRelay::InterRegionApiMethodRelayError]: Got unexpected API result object Hash  Method:[block in method_missing]
ERROR -- : /var/www/miq/vmdb/app/models/mixins/inter_region_api_method_relay.rb:84:in `exec_api_call'
/var/www/miq/vmdb/app/models/mixins/inter_region_api_method_relay.rb:32:in `block (2 levels) in api_relay_method'
/var/www/miq/vmdb/app/models/mixins/retirement_mixin.rb:16:in `block in retire'

Blocking: #18195 and ManageIQ/manageiq-ui-classic#4874

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1650335

@miq-bot add-label bug, blocker. hammer/yes, gaprindashvili/yes, core

@miq-bot

This comment has been minimized.

@yrudman
Copy link
Contributor Author

yrudman commented Nov 15, 2018

@miq-bot add-label hammer/yes

@yrudman yrudman force-pushed the accept-hash-object-as-result-of-inter-region-api-invocation branch from 59b2870 to 65aac7e Compare November 16, 2018 13:57
@yrudman
Copy link
Contributor Author

yrudman commented Nov 16, 2018

@miq-bot add-label blocker

@yrudman yrudman changed the title [WIP] Accept hash object as result of inter region api invocation Accept hash object as result of inter region api invocation Nov 16, 2018
@yrudman yrudman changed the title Accept hash object as result of inter region api invocation Accept Hash object as result of inter region api invocation Nov 16, 2018
@yrudman
Copy link
Contributor Author

yrudman commented Nov 16, 2018

\cc @gtanzillo @carbonin

@yrudman
Copy link
Contributor Author

yrudman commented Nov 16, 2018

@miq-bot remove-label wip

@miq-bot miq-bot removed the wip label Nov 16, 2018
@yrudman
Copy link
Contributor Author

yrudman commented Nov 16, 2018

@miq-bot assign @carbonin

@miq-bot
Copy link
Member

miq-bot commented Nov 16, 2018

Checked commits yrudman/manageiq@1e89ce1~...65aac7e with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. ⭐

@carbonin
Copy link
Member

@yrudman did you open a BZ against the API to standardize responses?

/cc @bdunne @abellotti

@carbonin
Copy link
Member

Also, do we know what happens in this case if we fail to retire the service? Will the client raise an Http error (I assume we will get a 5xx error of some sort) or will the hash contain a failure notification?

@yrudman
Copy link
Contributor Author

yrudman commented Nov 16, 2018

Also, do we know what happens in this case if we fail to retire the service? Will the client raise an Http error (I assume we will get a 5xx error of some sort) or will the hash contain a failure notification?

API Client is raising the same error which was raised on remote region:
If API raising "Yura Error something" when executing retire_resource` on remote server,
on global server the same error raised:

irb(main):011:0> s.retire
RuntimeError: Yura Error something
	from /opt/rh/cfme-gemset/gems/manageiq-api-client-0.3.2/lib/manageiq/api/client/connection.rb:111:in `check_response'
	from /opt/rh/cfme-gemset/gems/manageiq-api-client-0.3.2/lib/manageiq/api/client/connection.rb:102:in `send_request'
	from /opt/rh/cfme-gemset/gems/manageiq-api-client-0.3.2/lib/manageiq/api/client/connection.rb:34:in `post'
	from /opt/rh/cfme-gemset/gems/manageiq-api-client-0.3.2/lib/manageiq/api/client/client.rb:65:in `post'
	from /opt/rh/cfme-gemset/gems/manageiq-api-client-0.3.2/lib/manageiq/api/client/resource.rb:60:in `exec_action'
	from /opt/rh/cfme-gemset/gems/manageiq-api-client-0.3.2/lib/manageiq/api/client/resource.rb:46:in `method_missing'
	from /var/www/miq/vmdb/app/models/mixins/inter_region_api_method_relay.rb:76:in `public_send'
	from /var/www/miq/vmdb/app/models/mixins/inter_region_api_method_relay.rb:76:in `exec_api_call'

@carbonin
Copy link
Member

Okay, that's fine, just make sure to open a BZ against the API so we can remove this in the future.

@carbonin carbonin merged commit 0f85990 into ManageIQ:master Nov 16, 2018
@carbonin carbonin added this to the Sprint 99 Ending Nov 19, 2018 milestone Nov 16, 2018
@@ -80,6 +80,11 @@ def self.exec_api_call(region, collection_name, action, api_args = nil, id = nil
result.attributes
when ManageIQ::API::Client::Resource
instance_for_resource(result)
when Hash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is the wrong solution.
Vm retirement returns an action result, which I believe is correct.
However, retiring anything else (see api/base_controller/generic.rb) is returning the resource, which I believe is wrong.
I think retirement of anything should return the action result. @abellotti Any thoughts on this?

@carbonin
Copy link
Member

@bdunne I agree with you, but I don't think we're going to push an API refactoring for this in time to fix this blocker.

That's why I asked that a BZ be opened to address the API's return value inconsistencies.

@yrudman yrudman deleted the accept-hash-object-as-result-of-inter-region-api-invocation branch November 16, 2018 20:32
@bdunne
Copy link
Member

bdunne commented Nov 16, 2018

I wouldn't call it a refactoring... It's a bug in the API that retiring different things gives you different responses (resource hash vs action result).

a BZ be opened to address the API's return value inconsistencies

Tracking down and fixing all of the API response inconsistencies is an exponentially harder task than fixing the retirement responses and I'm afraid that it will never happen due to the difficulty level.

@carbonin
Copy link
Member

I think Yuri was also concerned with introducing breaking API changes by backporting the switch from resource to action result.

We could also fix the API for hammer and backport only this to Gaprindashvili. But I don't know what kind of compatibility rules we follow (or don't follow) for the manageiq REST API. @abellotti ?

@yrudman
Copy link
Contributor Author

yrudman commented Nov 16, 2018

I've started working on changing return value : ManageIQ/manageiq-api#511.
However, API is out for quite some time and I am not sure if PM should get involved too, since some clients may be affected

simaishi pushed a commit that referenced this pull request Nov 16, 2018
…f-inter-region-api-invocation

Accept Hash object as result of inter region api invocation

(cherry picked from commit 0f85990)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1650335
@simaishi
Copy link
Contributor

Hammer backport details:

$ git log -1
commit 96f2924c85b7ad09eb5095f0688eb64b0e5ac1b5
Author: Nick Carboni <ncarboni@redhat.com>
Date:   Fri Nov 16 15:16:59 2018 -0500

    Merge pull request #18210 from yrudman/accept-hash-object-as-result-of-inter-region-api-invocation
    
    Accept Hash object as result of inter region api invocation
    
    (cherry picked from commit 0f8599059c5cb192be92e3dc7fbb10382874ba56)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1650335

@yrudman
Copy link
Contributor Author

yrudman commented Nov 16, 2018

I think we should proceed for now with this solution (even if it looks wrong) since it is closing blockers for hammer and gaprindashvili and discuss/decide when we want to do breaking changes on API

@yrudman
Copy link
Contributor Author

yrudman commented Nov 16, 2018

@carbonin @bdunne API's return value inconsistencies BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1650696

simaishi pushed a commit that referenced this pull request Nov 19, 2018
…f-inter-region-api-invocation

Accept Hash object as result of inter region api invocation

(cherry picked from commit 0f85990)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1650691
@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit 3a18916dbc986e58a0c385663314057498580f9f
Author: Nick Carboni <ncarboni@redhat.com>
Date:   Fri Nov 16 15:16:59 2018 -0500

    Merge pull request #18210 from yrudman/accept-hash-object-as-result-of-inter-region-api-invocation
    
    Accept Hash object as result of inter region api invocation
    
    (cherry picked from commit 0f8599059c5cb192be92e3dc7fbb10382874ba56)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1650691

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants