-
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
[WIP] To Show terraform output in Services #72
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ def start | |
|
||
def pre_execute | ||
checkout_git_repository | ||
signal(:execute) | ||
route_signal(:execute) | ||
end | ||
|
||
def execute | ||
|
@@ -27,28 +27,65 @@ def execute | |
|
||
options[:terraform_stack_id] = response.stack_id | ||
save! | ||
|
||
queue_poll_runner | ||
route_signal(:poll_runner) | ||
#queue_poll_runner | ||
end | ||
|
||
def poll_runner | ||
if running? | ||
queue_poll_runner | ||
else | ||
signal(:post_execute) | ||
logs_update | ||
route_signal(:post_execute) | ||
end | ||
end | ||
|
||
def post_execute | ||
cleanup_git_repository | ||
|
||
|
||
#cleanup_git_repository | ||
|
||
return queue_signal(:finish, message, status) if success? | ||
|
||
#queue_signal(:finish, message, status) | ||
return queue_signal(:abort, "Failed to run ansible", "error") unless success? | ||
_log.error("Failed to run template: [#{error_message}]") | ||
|
||
abort_job("Failed to run template", "error") | ||
end | ||
|
||
def logs_update | ||
terraform_response = { | ||
stack_id: stack_response&.response&.stack_id, | ||
stack_name: stack_response&.response&.stack_name, | ||
status: stack_response&.response&.status, | ||
stack_job_end_time: stack_response&.response&.stack_job_end_time, | ||
stack_job_start_time: stack_response&.response&.stack_job_start_time, | ||
created_at: stack_response&.response&.created_at, | ||
message: stack_response&.response&.message, | ||
error_message: stack_response&.response&.error_message | ||
} | ||
|
||
miq_task.context_data ||= {} | ||
miq_task.context_data[:terraform_response] = terraform_response | ||
context[:terraform_response] = terraform_response | ||
|
||
update!(:context => context, :started_on => context[:terraform_response][:stack_job_start_time]) | ||
miq_task.update(context_data: miq_task.context_data) | ||
end | ||
|
||
def queue_signal(*args, deliver_on: nil, msg_timeout: nil) | ||
role = options[:role] || "ems_operations" | ||
priority = options[:priority] || MiqQueue::NORMAL_PRIORITY | ||
super(*args, :msg_timeout => msg_timeout, :priority => priority, :role => role, :deliver_on => deliver_on, :server_guid => MiqServer.my_server.guid) | ||
end | ||
|
||
def route_signal(*args, deliver_on: nil) | ||
if MiqEnvironment::Command.is_podified? | ||
signal(*args) | ||
else | ||
Comment on lines
+82
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jaisejose1123 do we need this for terraform? The reason it is like this in embedded_ansible is because the files/directories related to the ansible-runner execution are literally on the pod's filesystem so we have to run it on the same pod, but this has a number of drawbacks and something we want to get away from. With the opentofu-runner any pod in the namespace should be able to hit that API so any pod could run the next state. |
||
queue_signal(*args, :deliver_on => deliver_on) | ||
end | ||
end | ||
|
||
alias initializing dispatch_start | ||
alias finish process_finished | ||
alias abort_job process_abort | ||
|
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.
Are we no longer cleaning up the git repository?