-
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] Raise an error if terraform runner run fails #47
base: master
Are you sure you want to change the base?
[WIP] Raise an error if terraform runner run fails #47
Conversation
3e79fb1
to
2617071
Compare
response = create_stack_job( | ||
template_path, | ||
:input_vars => input_vars, | ||
:tags => tags, | ||
:credentials => credentials, | ||
:env_vars => env_vars | ||
) | ||
|
||
raise Terraform::Runner::Error, response.error_message if response.status == "FAILED" |
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.
@putmanoj can you help out here? I'm seeing in ResponseAsync that status is a string like: "SUCCESS", "FAILED", "CANCELLED"
, but if I submit a create_stack_job I see status is 401:
#<Terraform::Runner::Response:0x00007f94dcb031c8
@action=nil,
@created_at=nil,
@details=nil,
@error_message=nil,
@message="You do not have the necessary credentials.",
@stack_id=nil,
@stack_job_end_time=nil,
@stack_job_start_time=nil,
@stack_name=nil,
@status=401>
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.
Also, when is message used vs error_message?
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.
Also, when is message used vs error_message?
The 'message' is the full terraform/opentofu command output (including error message)
whereas 'error_message' , in case fails, cause of the failure or it only contains the error message for the failure.
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.
Okay, I have a failure posted above and there is only an entry in message
and not error_message
is that normal?
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 suppose we can have some improvement here.
But in this case the terraform command was not executed, as there is auth failure when calling the API.
For now to complete the dev test, you could use this example 'TOKEN' -> https://github.ibm.com/Orpheus/terraform-runner/blob/main/examples/simple-template-hcl/01-create-stack.sh#L11
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.
@putmanoj this isn't dev this is on an appliance, what is the plan for auth in prod?
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.
For now you could hardcode the above token and continue.
We can continue the discussion on the channel
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.
Opened to track this issue #49
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.
@putmanoj circling back to this question, I know we are tackling the auth issue separately but how do I tell when a terraform response is success/failure and how do I get the error response?
2617071
to
abda20e
Compare
Checked commits agrare/manageiq-providers-embedded_terraform@1d7f755~...abda20e with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint |
This pull request is not mergeable. Please rebase and repush. |
This pull request has been automatically marked as stale because it has not been updated for at least 3 months. If these changes are still valid, please remove the |
If the Terraform::Runner.run call fails there is no stack_id returned which means that any error message returned by the opentofu-runner API is lost.
Re-work how the API response is handled so that the error message is available if the initial call fails.
Fixes #45