-
Notifications
You must be signed in to change notification settings - Fork 897
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
[EmbeddedAnsible] Better handle ConfigurationScriptSource status/last_updated_on/last_update_error #19061
[EmbeddedAnsible] Better handle ConfigurationScriptSource status/last_updated_on/last_update_error #19061
Conversation
@miq-bot add_label changelog/yes, core, embedded ansible, enhancement, ivanchuk/yes @Fryguy please review, since I think you will have the most to say with this one Note: This is also addressing this 'bug'/oversight that was brought up by @sbulage here: https://gitter.im/ManageIQ/manageiq-providers-embedded_ansible?at=5d354941437a3a134832eb4c cc @carbonin |
I would say yes. |
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. Would merge but travis is red.
When a `EmbeddedAnsible::AutomationManager::ConfigurationScriptSource` is created and has been sync'd, have it update the `.status` field to be "successful", matching the `awx` results.
To simulate ansible/awx, set `.status` for ConfigurationScriptSource to 'new' when a new EmbeddedAnsible repo is first created. To do this, `CrudCommon.create_in_provider` was overwritten to append the `sync` action to the `super` call (instead of in `raw_create_in_provider`. Since these are two atomic actions, and a `Rugged::NetworkError` shouldn't cause the whole process to fail, splitting the code up like this allows a creation to happen, but it to fail on the sync without the record being lost and deleted in the process. As a result, there are a minor amount of extra DB calls in a successful use case, but it means that a user isn't required to resubmit the form fields to try again and can just do a provider refresh when there is a failure to re-attempt a sync.
Provides "error" status when a `ConfigurationScriptSource#sync` fails.
2875ce9
to
e7ad3a5
Compare
Looks good to me, but could you fix the |
Sure, though the |
Unlike the ansible_tower provider, we haven't been implementing the `last_update_error` and `last_updated_on` values when syncing. This does the following: - Always updates `#last_updated_on` when completing a `#sync` - On error: Formats and sets `#last_update_error` - On success: Removes any previous errors from `#last_update_error` The ERROR_MAX_SIZE value is pulled from the `AnsibleTower` provider.
Splits up the actions for updating the database and refreshing the git repository into two atomic actions, similar to repo#create_in_provider. Also, to slightly DRY things up a bit, #sync_and_notify was added as well and was used in both the create and update methods.
1acb803
to
1738d60
Compare
Checked commits NickLaMuro/manageiq@9c86b54~...1738d60 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 app/models/manageiq/providers/embedded_ansible/automation_manager/configuration_script_source.rb
|
…olumn [EmbeddedAnsible] Better handle ConfigurationScriptSource status/last_updated_on/last_update_error (cherry picked from commit 4e0783d)
Ivanchuk backport details:
|
Currently, we don't set the status when doing a repo (ConfigurationScriptSource) sync. With this change, we now:
'new'
status'running'
at the beginning of#sync
last_update_on
is updated toTime.now
'error'
andlast_update_error
to provide the ruby error and stacktrace'successful'
and clearlast_update_error
Worth noting: A "create" action is now done in two transactions and
.notify
(fromCrudCommon
). One for creating the record in the DB record and one for starting the sync. This is mostly because they really are two atomic actions. If a.create!
passes, but the.sync
fails, we shouldn't delete the record and just provide a notification in the UI and update the status.Also, if there was an error, a simple refresh of the provider will re-attempt the sync, or if there is something like a credential error, the user can update and the
.sync
will be fired again.TODO:
Handle translations (seperate PR?)