-
Notifications
You must be signed in to change notification settings - Fork 10
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
Retire terraform runner stack #71
base: master
Are you sure you want to change the base?
Conversation
if template_id.nil? && action.downcase == 'retirement' | ||
template_id = config_info.dig(:provision, :configuration_script_payload_id) |
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.
Is this saying that when doing retirement use the provisioning workflow?
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.
By default, for terraform , same terraform template files, vars, but different action, ie when 'Retirement' action -> run destroy
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.
Could we set the configuration script payload on the retirement resource_action also so this would "just work" ?
16e9ab7
to
3d881e8
Compare
…id=<terraform-runner:stack_id> is passed
…his will be later used for retirement action
…nly used internally for Retirement action
a454b69
to
7205662
Compare
def update_service_instance_with_stack_id(action, service_instance_id, stack_id) | ||
if !action.nil? && action.downcase == 'provision' | ||
service_instance = ServiceTerraformTemplate.find_by(:id => service_instance_id) | ||
if !service_instance.nil? | ||
service_instance.preprocess(action, {:extra_vars => {:miq_terraform_stack_id => stack_id}}) | ||
_log.debug("updated service-instance/#{service_instance.to_json} with stack_id#{stack_id}") | ||
else | ||
_log.info("Not found service-instance/#{service_instance_id}") | ||
end | ||
else | ||
_log.debug("Not Provision action, no update to service-instance/#{service_instance_id} required") | ||
end | ||
end |
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.
Believe we discussed this in chat, but just to make sure this doesn't get lost I'll add here also.
I think the proper way to do this is to have the service retirement retire all of the related resources which in this case will be an OrchestrationStack. This would also work if in the future you had a service that ends up creating multiple terraform_stacks where what you have here would preclude that.
case action.downcase | ||
when 'retirement' | ||
retire_job_options = options[job_option_key('retirement')].deep_dup | ||
retire_job_options[:action] = action | ||
prov_job_options = options[job_option_key('provision')].deep_dup | ||
# if not already available in retirement options, (won't be available for terraform) | ||
# copy extra_vars,execution_ttl,verbosity,credentials,etc from provision action | ||
job_options = prov_job_options.deep_merge(retire_job_options) | ||
else |
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.
This doesn't seem right, shouldn't we set what we need in the options for the retirement action so we don't have to do this?
The destroy(retire) api from terraform-runner, uses
terraform-template
,input-vars
from provision action. And needsstack_id
created in provision action.template_id
&input-vars
are available in the Service instance, whereasstack_id
available in Job instance.stack_id
in Services,stack_id
in Job class, to use later when 'Retirement' is triggered.The Terraform::Runner runs 'Retirement' action with same run/run_async method
:miq_action => 'Retirement'
&:miq_terraform_stack_id => '<stack_id from terraform-runner>'
, otherwise runs 'Provision' action.