Skip to content

Commit

Permalink
AL-5682: Improve logging for terraform (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwaizer authored Jan 21, 2025
1 parent 4542da7 commit 7965e7a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions alts/worker/runners/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ def get_test_executor_params(self) -> dict:

def __terraform_init(self):
with FileLock(TF_INIT_LOCK_PATH, timeout=60, thread_local=False):
return local['terraform'].with_cwd(self._work_dir).run(
return local['terraform'].with_env(TF_LOG='TRACE').with_cwd(self._work_dir).run(
('init', '-no-color'),
timeout=CONFIG.provision_timeout,
)
Expand Down Expand Up @@ -703,7 +703,7 @@ def start_env(self):
cmd_args = ['apply', '--auto-approve', '-no-color']
if self.TF_VARIABLES_FILE:
cmd_args.extend(['--var-file', self.TF_VARIABLES_FILE])
return local['terraform'].with_cwd(self._work_dir).run(
return local['terraform'].with_env(TF_LOG='TRACE').with_cwd(self._work_dir).run(
args=cmd_args,
retcode=None,
timeout=CONFIG.provision_timeout,
Expand Down Expand Up @@ -1494,7 +1494,7 @@ def _stop_env(self):
cmd_args = ['destroy', '--auto-approve', '-no-color']
if self.TF_VARIABLES_FILE:
cmd_args.extend(['--var-file', self.TF_VARIABLES_FILE])
return local['terraform'].with_cwd(self._work_dir).run(
return local['terraform'].with_env(TF_LOG='TRACE').with_cwd(self._work_dir).run(
args=cmd_args,
retcode=None,
timeout=CONFIG.provision_timeout,
Expand Down Expand Up @@ -1715,7 +1715,7 @@ def start_env(self):
# VM gets its IP address only after deploy.
# To extract it, the `vm_ip` output should be defined
# in Terraform main file.
ip_exit_code, ip_stdout, ip_stderr = local['terraform'].with_cwd(
ip_exit_code, ip_stdout, ip_stderr = local['terraform'].with_env(TF_LOG='TRACE').with_cwd(
self._work_dir).run(
args=('output', '-raw', '-no-color', 'vm_ip'),
retcode=None,
Expand Down
2 changes: 1 addition & 1 deletion alts/worker/runners/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def clone_third_party_repo(
return test_repo_path

def _stop_env(self):
_, container_id, _ = local['terraform'].with_cwd(
_, container_id, _ = local['terraform'].with_env(TF_LOG='TRACE').with_cwd(
self._work_dir).run(
args=('output', '-raw', '-no-color', 'container_id'),
retcode=None,
Expand Down
2 changes: 1 addition & 1 deletion alts/worker/runners/opennebula.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def _stop_env(self):
'Cannot stop VM conventionally. Output:\n%s\nStderr:\n%s',
stop_out, stop_err
)
id_exit_code, vm_id, id_stderr = local['terraform'].with_cwd(
id_exit_code, vm_id, id_stderr = local['terraform'].with_env(TF_LOG='TRACE').with_cwd(
self._work_dir).run(
args=('output', '-raw', '-no-color', 'vm_id'),
retcode=None,
Expand Down

0 comments on commit 7965e7a

Please sign in to comment.