Skip to content
Snippets Groups Projects

Enhance exception handling of ActionCommands

2 unresolved threads

Fix #337 Catches exceptions in the Action excec method. Otherwise can the setup and teardown methods are interruppted and the kafka topics are not removed after an experiment.

fix NullPointer exception by FindAndFirst() by checking for failture first enhance normal logging in case of problematic commands

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
23 val exitCode = ActionCommand(client = client)
24 .exec(
25 matchLabels = selector.pod.matchLabels,
26 container = selector.container,
27 timeout = exec.timeoutSeconds,
28 command = exec.command
29 )
26 30 if(exitCode != 0){
27 throw ActionCommandFailedException("Error while executing action, finished with exit code $exitCode")
31 logger.info("Actions exit code was not zero instead: $exitCode")
32 logger.info("Selector: ${selector.pod.matchLabels}, container: ${selector.container}")
33 logger.info("Command: ${exec.command.joinToString(separator = " ")}")
34 }
35 }
36 catch (e: Exception){
37 logger.info { e.stackTraceToString() }
  • assigned to @she

  • Sören Henning mentioned in issue #337

    mentioned in issue #337

  • 95 95
    96 96 return if (status.status.equals("Success")) {
    97 97 0
    98 } else status.details.causes.stream()
    98 } else if (status.status.equals("Failure")){
    99 throw ActionCommandFailedException("Could not determine the exit code, status is failure")
    100 }
    101 else { status.details.causes.stream()
    99 102 .filter { it.reason.equals("ExitCode") }
    • Condition should be it.reason != null && it.reason.equals("ExitCode") in order to prevent NullPointerException. Also, when the NullPointerException is prevented, the original Error is logged to stdout which makes the behaviour of the application more comprehensive.

      Edited by Simon Ehrenstein
    • Author Developer

      If i remember correctly, is status.details.causes not always set. This results in an kind of "empty" stream - which will in turn trigger the NullPointeException observed. But i will review this tomorrow with more time and therefore: Without guarantees

    • Maybe we can organize a bit the possible outcomes a bit and first document which field is null/not set/empty/throws exceptions under which conditions.

    • Please register or sign in to reply
  • Sören Henning changed milestone to %0.8.0

    changed milestone to %0.8.0

  • Sören Henning changed milestone to %0.9.0

    changed milestone to %0.9.0

  • Sören Henning changed target branch from master to main

    changed target branch from master to main

  • Sören Henning changed milestone to %0.10.0

    changed milestone to %0.10.0

  • Please register or sign in to reply
    Loading