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

Use valid api-version string if settings.yml value is invalid #275

Merged
merged 12 commits into from
Nov 7, 2018
Merged

Use valid api-version string if settings.yml value is invalid #275

merged 12 commits into from
Nov 7, 2018

Conversation

djberg96
Copy link
Collaborator

@djberg96 djberg96 commented Jul 10, 2018

If a user sets an invalid api-version string in the config/settings.yml file, then the refresh parser will bomb with an error from Azure. This could happen because they modified it manually, or because their environment has different values that are considered valid from what we specify by default.

This PR handles that possibility gracefully by checking the api-version specified in the settings.yml file versus the list of possible values that the Azure REST API tells us are valid. If there's a match, then things proceed normally.

If not, however, then we pull the most recent api-version string from the list of valid values and use that instead, logging a warning for good measure.

WIP until I can add some specs.

@miq-bot miq-bot added the wip label Jul 10, 2018
@djberg96
Copy link
Collaborator Author

Note that because this makes one extra REST API call internally, the specs will fail using the current cassettes. Those will need to be regenerated, but atm we cannot because of current internal issues.

"#{service.provider}/#{service.service_name} for EMS #{@ems.name}; " \
"using '#{valid_version_string}' instead."

_log.warn(message)
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to detect this at the time it's set in the settings? I can show you where to do it...my only concern is if it makes a call out to the provider (can't tell from this code if it does or not).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It does make one extra call internally to get that list.

Choose a reason for hiding this comment

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

I would like to see how to do that @Fryguy

@djberg96 djberg96 changed the title [WIP] Use valid api-version string if settings.yml value is invalid Use valid api-version string if settings.yml value is invalid Jul 20, 2018
@djberg96 djberg96 requested a review from bronaghs July 20, 2018 13:50
@djberg96 djberg96 removed the wip label Jul 20, 2018
@miq-bot
Copy link
Member

miq-bot commented Nov 6, 2018

Some comments on commits https://github.com/djberg96/manageiq-providers-azure/compare/7c0f52585e5f2d3b2d7a02ee94452362ad71436d~...9f93c661d4abf55d1dd72cedd2dcaa78cac18a29

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher.yml

  • 💣 💥 🔥 🚒 - 15528 - Detected cfme
  • 💣 💥 🔥 🚒 - 15630 - Detected cfme
  • 💣 💥 🔥 🚒 - 5911 - Detected cfme
  • 💣 💥 🔥 🚒 - 6821 - Detected cfme
  • 💣 💥 🔥 🚒 - 9010 - Detected cfme
  • 💣 💥 🔥 🚒 - 9061 - Detected cfme
  • 💣 💥 🔥 🚒 - 9112 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_inventory_object.yml

  • 💣 💥 🔥 🚒 - 10273 - Detected cfme
  • 💣 💥 🔥 🚒 - 10324 - Detected cfme
  • 💣 💥 🔥 🚒 - 10375 - Detected cfme
  • 💣 💥 🔥 🚒 - 17993 - Detected cfme
  • 💣 💥 🔥 🚒 - 18095 - Detected cfme
  • 💣 💥 🔥 🚒 - 7111 - Detected cfme
  • 💣 💥 🔥 🚒 - 9549 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_0/lb_created_by_stack_refresh.yml

  • 💣 💥 🔥 🚒 - 7162 - Detected cfme
  • 💣 💥 🔥 🚒 - 7213 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_0/lb_refresh.yml

  • 💣 💥 🔥 🚒 - 7162 - Detected cfme
  • 💣 💥 🔥 🚒 - 7213 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_0/lb_vms_refresh.yml

  • 💣 💥 🔥 🚒 - 7113 - Detected cfme
  • 💣 💥 🔥 🚒 - 7164 - Detected cfme
  • 💣 💥 🔥 🚒 - 8070 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_0/lb_with_vms_refresh.yml

  • 💣 💥 🔥 🚒 - 7111 - Detected cfme
  • 💣 💥 🔥 🚒 - 7164 - Detected cfme
  • 💣 💥 🔥 🚒 - 7215 - Detected cfme
  • 💣 💥 🔥 🚒 - 8121 - Detected cfme
  • 💣 💥 🔥 🚒 - 8328 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_0/lbs_refresh.yml

  • 💣 💥 🔥 🚒 - 7108 - Detected cfme
  • 💣 💥 🔥 🚒 - 7159 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_0/multiple_targets_refresh.yml

  • 💣 💥 🔥 🚒 - 7111 - Detected cfme
  • 💣 💥 🔥 🚒 - 7957 - Detected cfme
  • 💣 💥 🔥 🚒 - 8008 - Detected cfme
  • 💣 💥 🔥 🚒 - 8946 - Detected cfme
  • 💣 💥 🔥 🚒 - 9048 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_0/network_port_refresh.yml

  • 💣 💥 🔥 🚒 - 7111 - Detected cfme
  • 💣 💥 🔥 🚒 - 7318 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_0/powered_off_vm_refresh.yml

  • 💣 💥 🔥 🚒 - 7113 - Detected cfme
  • 💣 💥 🔥 🚒 - 7164 - Detected cfme
  • 💣 💥 🔥 🚒 - 7995 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_0/powered_on_vm_refresh.yml

  • 💣 💥 🔥 🚒 - 7113 - Detected cfme
  • 💣 💥 🔥 🚒 - 7164 - Detected cfme
  • 💣 💥 🔥 🚒 - 7997 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_0/vm_with_managed_disk_refresh.yml

  • 💣 💥 🔥 🚒 - 7113 - Detected cfme
  • 💣 💥 🔥 🚒 - 7164 - Detected cfme
  • 💣 💥 🔥 🚒 - 8001 - Detected cfme
  • 💣 💥 🔥 🚒 - 8052 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_500/lb_created_by_stack_refresh.yml

  • 💣 💥 🔥 🚒 - 7121 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_500/lb_refresh.yml

  • 💣 💥 🔥 🚒 - 7121 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_500/lb_vms_refresh.yml

  • 💣 💥 🔥 🚒 - 7136 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_500/lb_with_vms_refresh.yml

  • 💣 💥 🔥 🚒 - 7121 - Detected cfme
  • 💣 💥 🔥 🚒 - 7335 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_500/multiple_targets_refresh.yml

  • 💣 💥 🔥 🚒 - 7175 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_500/network_port_refresh.yml

  • 💣 💥 🔥 🚒 - 7120 - Detected cfme
  • 💣 💥 🔥 🚒 - 7202 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_500/powered_off_vm_refresh.yml

  • 💣 💥 🔥 🚒 - 7137 - Detected cfme
  • 💣 💥 🔥 🚒 - 7199 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_500/powered_on_vm_refresh.yml

  • 💣 💥 🔥 🚒 - 7138 - Detected cfme
  • 💣 💥 🔥 🚒 - 7200 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted/targeted_api_collection_threshold_500/vm_with_managed_disk_refresh.yml

  • 💣 💥 🔥 🚒 - 7143 - Detected cfme
  • 💣 💥 🔥 🚒 - 7205 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted_scope/lb_refresh.yml

  • 💣 💥 🔥 🚒 - 7121 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted_scope/lb_vms_refresh.yml

  • 💣 💥 🔥 🚒 - 7136 - Detected cfme
  • 💣 💥 🔥 🚒 - 7215 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted_scope/lb_with_vms_refresh.yml

  • 💣 💥 🔥 🚒 - 7121 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted_scope/lbs_refresh.yml

  • 💣 💥 🔥 🚒 - 7067 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted_scope/multiple_targets_refresh.yml

  • 💣 💥 🔥 🚒 - 7175 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted_scope/orchestration_stack_refresh.yml

  • 💣 💥 🔥 🚒 - 7219 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted_scope/orchestration_stack_vm_refresh.yml

  • 💣 💥 🔥 🚒 - 7136 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted_scope/powered_off_vm_refresh.yml

  • 💣 💥 🔥 🚒 - 7137 - Detected cfme
  • 💣 💥 🔥 🚒 - 7199 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted_scope/powered_on_vm_refresh.yml

  • 💣 💥 🔥 🚒 - 7138 - Detected cfme
  • 💣 💥 🔥 🚒 - 7200 - Detected cfme

spec/vcr_cassettes/manageiq/providers/azure/cloud_manager/refresher_targeted_scope/vm_with_managed_disk_refresh.yml

  • 💣 💥 🔥 🚒 - 7143 - Detected cfme
  • 💣 💥 🔥 🚒 - 7205 - Detected cfme

@miq-bot
Copy link
Member

miq-bot commented Nov 6, 2018

Checked commits https://github.com/djberg96/manageiq-providers-azure/compare/7c0f52585e5f2d3b2d7a02ee94452362ad71436d~...9f93c661d4abf55d1dd72cedd2dcaa78cac18a29 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
5 files checked, 2 offenses detected

spec/models/manageiq/providers/azure/cloud_manager/targeted_refresher_scope_spec.rb

@djberg96
Copy link
Collaborator Author

djberg96 commented Nov 6, 2018

@Ladas Not sure why, but another targeted refresh spec is failing after regenerating the cassettes, so I commented out the offending spec for now. Something about the vm from an orchestration template it doesn't like, but I'm not sure what.

Other than that, it's ready to go.

@djberg96 djberg96 requested a review from Ladas November 6, 2018 21:03
Copy link
Contributor

@Ladas Ladas left a comment

Choose a reason for hiding this comment

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

👍 looks good

we should start to look at all those commented out specs now :-)

# strings using the config/settings.yml from the provider repo.

def cached_resource_provider_service(config)
@cached_resource_provider_service ||= resource_provider_service(config)
Copy link
Contributor

Choose a reason for hiding this comment

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

if this is something that rarely changes, we could probably wrap it to cache_with_timeout block?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't know about cache_with_timeout but perhaps we can switch it to that if you prefer.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, for the things that do not change (or not frequently) it's perfect

@Ladas Ladas self-assigned this Nov 7, 2018
@Ladas Ladas merged commit ac91282 into ManageIQ:master Nov 7, 2018
@Ladas Ladas added this to the Sprint 99 Ending Nov 19, 2018 milestone Nov 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants