-
Notifications
You must be signed in to change notification settings - Fork 105
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
Terraform output shown in logs as a single string without new lines. #2627
base: master
Are you sure you want to change the base?
Conversation
Hi @bkopilov. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bkopilov, danmanor The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/ok-to-test |
@@ -74,6 +74,10 @@ def apply( | |||
return_value, output, err = self.tf.apply( | |||
no_color=IsFlagged, refresh=refresh, input=False, skip_plan=True, capture_output=capture_output | |||
) | |||
# print terraform output line by line without \n | |||
if output and type(output) is str: | |||
log.info(output) |
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.
better to store a file somewhere, I fear it can expose credentials publicly in Prow in case of vsphere or nutatix cc @danmanor
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.
it it really the "terraform" output, or the output log of the resulting of terraform apply
?
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.
The terraform outut printed anyway but with \n and shown in single line .
It always in test_infra.log . i just take the same output and print it with a way that translate the \n to new line in output.
it was better to fix it in terraform code ... but ...
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.
can't we fix it? Logs are already hard to read, printing twice the output would be less friendly?
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.
The terrfaform package , inside runs the cmd for apply and return the output .
Terraform.apply: (self, dir_or_plan=None, input=False, skip_plan=False, no_color=IsFlagged, **kwargs) │
│ apply │
│ refer to https://terraform.io/docs/commands/apply.html │
│ no-color is flagged by default │
│ :param no_color: disable color of stdout │
│ :param input: disable prompt for a missing variable │
│ :param dir_or_plan: folder relative to working folder │
│ :param skip_plan: force apply without plan (default: false) │
│ :param kwargs: same as kwags in method 'cmd' │
│ :returns return_code, stdout, stderr
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.
The terraform package use subproccess module and run:
p = subprocess.Popen(cmds, stdout=stdout, stderr=stderr,
293 cwd=working_folder, env=environ_vars)
294
295 synchronous = kwargs.pop('synchronous', True)
296 if not synchronous:
297 return p, None, None
298
299 out, err = p.communicate()
300 ret_code = p.returncode
301 log.debug('output: {o}'.format(o=out))
302
303 if ret_code == 0:
304 self.read_state_file()
305 else:
306 log.warn('error: {e}'.format(e=err))
307
308 self.temp_var_files.clean_up()
309 if capture_output is True:
310 out = out.decode('utf-8')
311 err = err.decode('utf-8')
312 else:
313 out = None
314 err = None
315
316 if ret_code != 0 and raise_on_error:
317 raise TerraformCommandError(
318 ret_code, ' '.join(cmds), out=out, err=err)
319
320 return ret_code, out, err
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.
log.debug('output: {o}'.format(o=out))
we can just disable log debug for this package?
/hold |
@bkopilov why do we need to print it on the log output? we have very few outputs actually: |
Not critical .... we can skip it |
…lines. Print the terraform output to log.info which print new lines and its clear to read
251a27a
to
d6dfc9a
Compare
New changes are detected. LGTM label has been removed. |
@bkopilov: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Print the terraform output to log.info which print new lines and its clear to read