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
Renderer fails when calling validate_import_vm #3
Conversation
This is moved PR [1] from the main repo |
@@ -31,7 +31,8 @@ def import_vm(source_vm_id, target_params) | |||
end | |||
|
|||
def validate_import_vm | |||
api_version >= '4.0' | |||
version = highest_supported_api_version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can use: (highest_supported_api_version is almost entirely memorized, if the caching fails it will return nil and not run twice anyway)
highest_supported_api_version >= '4' if highest_supported_api_version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or actually:
highest_supported_api_version && highest_supported_api_version >= '4'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
When using automation we see that there is an issue in validate_import_vm and there is a time when api_version is not avialbale. We need to make sure that validation passes.
Checked commit pkliczewski@a048839 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -31,7 +31,7 @@ def import_vm(source_vm_id, target_params) | |||
end | |||
|
|||
def validate_import_vm | |||
api_version >= '4.0' | |||
highest_supported_api_version && highest_supported_api_version >= '4' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find >=
on Strings dangerous and strange.
Also highest_supported_api_version
seems to return 3
(int) as a default....
Consider some of those conversions:
[3] pry(main)> 3 >= '4'
ArgumentError: comparison of Fixnum with String failed
from (pry):3:in `>='
[4] pry(main)> 3.to_i >= 4
=> false
[5] pry(main)> '3.0'.to_i
=> 3
[6] pry(main)> Integer('3.0')
ArgumentError: invalid value for Integer(): "3.0"
from (pry):6:in `Integer'
[7] pry(main)> '3.0beta'.to_i
=> 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I double checked the code and we seems to return a string
2.3.0 :001 > ems = ExtManagementSystem.last
PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0
ExtManagementSystem Load (0.4ms) SELECT "ext_management_systems".* FROM "ext_management_systems" ORDER BY "ext_management_systems"."id" DESC LIMIT $1 [["LIMIT", 1]]
ExtManagementSystem Inst Including Associations (6430.5ms - 1rows)
=> #<ManageIQ::Providers::Redhat::InfraManager id: 11, name: "ovirt", created_on: "2017-04-11 14:18:50", updated_on: "2017-04-11 14:19:15", guid: "c89c81a0-1ec1-11e7-b1c4-c85b76722276", zone_id: 1, type: "ManageIQ::Providers::Redhat::InfraManager", api_version: "4.2.0_master.", uid_ems: nil, host_default_vnc_port_start: nil, host_default_vnc_port_end: nil, provider_region: nil, last_refresh_error: nil, last_refresh_date: "2017-04-11 14:19:15", provider_id: nil, realm: nil, tenant_id: 1, project: nil, parent_ems_id: nil, subscription: nil, last_metrics_error: nil, last_metrics_update_date: nil, last_metrics_success_date: nil, tenant_mapping_enabled: nil>
2.3.0 :002 > ems.highest_supported_api_version
Authentication Load (0.7ms) SELECT "authentications".* FROM "authentications" WHERE "authentications"."resource_id" = $1 AND "authentications"."resource_type" = $2 [["resource_id", 11], ["resource_type", "ExtManagementSystem"]]
Authentication Inst Including Associations (105.1ms - 1rows)
Endpoint Load (0.3ms) SELECT "endpoints".* FROM "endpoints" WHERE "endpoints"."resource_id" = $1 AND "endpoints"."resource_type" = $2 [["resource_id", 11], ["resource_type", "ExtManagementSystem"]]
Endpoint Inst Including Associations (16.4ms - 2rows)
=> "4"
I understand that it looks strange but this is how the code works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, ok I just wonder why this returns Integer(3)
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@durandom good point, will change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here: #10
Fine backport (to manageiq repo) details:
|
Add CodeClimate test coverage reporter
mapping from "powering_up" to "on"
When using automation we see that there is an issue in validate_import_vm
and there is a time when api_version is not avialbale. We need to make sure
that validation passes.