-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: change the Test Workflow orchestration mechanism to atomic inst…
…ructions (#5676) * fix(testworkflows): avoid unnecessary empty data in ContainerConfig * feat(testworkflows): add basic implementation to build list of operations / grouping them, based on the TestWorkflowProcessor's Stages * feat(testworkflows): migrate basics of container execution for handling multiple steps in single container * feat: support conditions with new Init Process kind * feat: encapsulate init process' container state * chore: rename container to setup * feat: support dynamic environment variables * feat: add mock for pause in the Init Process * feat: discriminate TestWorkflow instructions with ActionType * chore: rename Paused to PausedOnStart * chore: change StepData mutations * chore: extract action.Action to separate package * feat: move *Stage to separate package * chore: reorganize action files * chore: delete unused * chore: extract lightweight version of actions to avoid increase in Init Process size * feat: abstract the executions in the Init Process * fix: aborting Test Workflow processes * fix: support statuses properly in the Init Process * fix: parsing container logs * chore: delete debug information * feat: make the root operation constant * feat: support timeout for Test Workflow steps * feat: add back retry functionality for the Test Workflows * feat: support pause/resume for Test Workflows * chore: delete unused code * fix: watching services * fix: some unit tests * chore: add instructions check in unit test * chore: refactor action unit tests a bit * fix: build correct conditions when there are grouped steps * chore: adjust processor tests * chore: delete unused function * feat: streamline the output in the Init Process, to allow obfuscating sensitive words * feat: mask secret environment variables * chore: extract function to get last step * chore: unify internal machine for Init Process * chore: move step timeout logic to the Init Process main switch * fix: use default ContainerConfig for setup step container * feat: use /bin/sh instead of /.tktw/bin/sh in case the Init/Toolkit image is used * chore: fail property accessor in case of nullish value to access * feat: ensure that aborted step is considered aborted, not skipped * fix: machine for retry in the Init Process * chore: rename `instructions` related to Actions to `actions` * fix: send again toolkit/init image data along with Pod information from Test Workflow * chore: simplify StepStatusFromCode * fix: clean up printing in the Init Process * chore: clean up getting actions in Processor tests * chore: rename variable in Control Server * chore: extract control server options to separate file * chore: expose a bit configuration of sensitive words minimum length * chore: delete obsolete todos * fix: avoid copying binaries from the Init image when it's not necessary * fix: unit tests * fix: group conditions * chore: wrap errors * chore: reduce the size of Init Process * fix: detect the Toolkit properly * chore: rename SensitiveReadWriter to Obfuscator * feat: show last characters in the obfuscated log output * feat: make some environment variables sensitive by default * chore: first set of code review fixes * chore: make the 00 and 01 special groups constants * chore: log error for mkdir of working directory * chore: delete commented out code * fix: handle errors in the setup step
- Loading branch information
Showing
84 changed files
with
5,214 additions
and
2,512 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package commands | ||
|
||
import ( | ||
"slices" | ||
|
||
"github.com/kubeshop/testkube/cmd/testworkflow-init/constants" | ||
"github.com/kubeshop/testkube/cmd/testworkflow-init/data" | ||
"github.com/kubeshop/testkube/cmd/testworkflow-init/orchestration" | ||
"github.com/kubeshop/testkube/cmd/testworkflow-init/output" | ||
"github.com/kubeshop/testkube/pkg/expressions" | ||
"github.com/kubeshop/testkube/pkg/testworkflows/testworkflowprocessor/action/actiontypes/lite" | ||
) | ||
|
||
func Run(run lite.ActionExecute, container lite.LiteActionContainer) { | ||
machine := data.GetInternalTestWorkflowMachine() | ||
state := data.GetState() | ||
step := state.GetStep(run.Ref) | ||
|
||
// Abandon executing if the step was finished before | ||
if step.IsFinished() { | ||
return | ||
} | ||
|
||
// Obtain command to run | ||
command := make([]string, 0) | ||
if container.Config.Command != nil { | ||
command = slices.Clone(*container.Config.Command) | ||
} | ||
if container.Config.Args != nil { | ||
command = append(command, *container.Config.Args...) | ||
} | ||
|
||
// Ensure the command is not empty | ||
if len(command) == 0 { | ||
output.ExitErrorf(data.CodeInputError, "command is required") | ||
} | ||
|
||
// Resolve the command to run | ||
for i := range command { | ||
value, err := expressions.CompileAndResolveTemplate(command[i], machine, expressions.FinalizerFail) | ||
if err != nil { | ||
output.ExitErrorf(data.CodeInternal, "failed to compute argument '%d': %s", i, err.Error()) | ||
} | ||
command[i], _ = value.Static().StringValue() | ||
} | ||
|
||
// Run the operation | ||
execution := orchestration.Executions.Create(command[0], command[1:]) | ||
result, err := execution.Run() | ||
if err != nil { | ||
output.ExitErrorf(data.CodeInternal, "failed to execute: %v", err) | ||
} | ||
|
||
// Initialize local state | ||
var status data.StepStatus | ||
|
||
success := result.ExitCode == 0 | ||
|
||
// Compute the result | ||
if run.Negative { | ||
success = !success | ||
} | ||
if result.Aborted { | ||
status = data.StepStatusAborted | ||
} else if success { | ||
status = data.StepStatusPassed | ||
} else { | ||
status = data.StepStatusFailed | ||
} | ||
|
||
// Abandon saving execution data if the step has been finished before | ||
if step.IsFinished() { | ||
return | ||
} | ||
|
||
// Notify about the status | ||
step.SetStatus(status).SetExitCode(result.ExitCode) | ||
orchestration.FinishExecution(step, constants.ExecutionResult{ExitCode: result.ExitCode, Iteration: int(step.Iteration)}) | ||
} |
Oops, something went wrong.