Skip to content

Commit fd85955

Browse files
committed
Make sonobuoy handler more robust
- do blanket cleaup before run, so leftovers don't interfere - output ABORT result in case of, well, an abort - divert sonobuoy stdout to stderr because! Signed-off-by: Matthias Büchse <matthias.buechse@alasca.cloud>
1 parent b642307 commit fd85955

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Tests/kaas/sonobuoy_handler/sonobuoy_handler.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import shlex
77
import shutil
88
import subprocess
9+
import sys
910

1011
import yaml
1112

@@ -65,7 +66,7 @@ def _invoke_sonobuoy(self, *args, **kwargs):
6566
inv_args = (self.sonobuoy, "--kubeconfig", self.kubeconfig_path) + args
6667
logger.debug(f'invoking {" ".join(inv_args)}')
6768
# we had capture_output=True, but I don't see why -- let the caller decide
68-
return subprocess.run(args=inv_args, check=True, **kwargs)
69+
return subprocess.run(args=inv_args, check=True, stdout=sys.stderr, **kwargs)
6970

7071
def _sonobuoy_run(self):
7172
self._invoke_sonobuoy("run", "--wait", *self.args)
@@ -113,13 +114,15 @@ def run(self):
113114
logger.info(f"running sonobuoy for testcase {self.check_name}")
114115
self._preflight_check()
115116
try:
117+
self._sonobuoy_delete() # remove leftovers from previous run, if any
116118
self._sonobuoy_run()
117119
counter = self._sonobuoy_retrieve_result()
118120
return_code = self._eval_result(counter)
119121
print(self.check_name + ": " + ("PASS", "FAIL")[min(1, return_code)])
120122
return return_code
121123
except BaseException:
122-
logger.exception("something went wrong")
124+
print(self.check_name + ": ABORT")
125+
logger.debug("something went wrong", exc_info=True)
123126
return 112
124127
finally:
125128
self._sonobuoy_delete()

0 commit comments

Comments
 (0)