Skip to content

Commit

Permalink
fix: 'fetch' operation for parallel steps (#5615)
Browse files Browse the repository at this point in the history
  • Loading branch information
rangoo94 authored Jun 27, 2024
1 parent f1e9cc2 commit e249f5d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/tcl/testworkflow-toolkit/spawn/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/kubeshop/testkube/pkg/api/v1/testkube"
"github.com/kubeshop/testkube/pkg/expressions"
"github.com/kubeshop/testkube/pkg/testworkflows/testworkflowcontroller"
"github.com/kubeshop/testkube/pkg/testworkflows/testworkflowprocessor"
"github.com/kubeshop/testkube/pkg/testworkflows/testworkflowprocessor/constants"
)

Expand Down Expand Up @@ -173,6 +174,7 @@ func ProcessFetch(transferSrv transfer.Server, fetch []testworkflowsv1.StepParal
Env: []corev1.EnvVar{
{Name: "TK_NS", Value: env.Namespace()},
{Name: "TK_REF", Value: env.Ref()},
testworkflowprocessor.BypassToolkitCheck,
},
Args: &result,
},
Expand Down
12 changes: 11 additions & 1 deletion pkg/testworkflows/testworkflowprocessor/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ import (

"github.com/kubeshop/testkube/internal/common"
"github.com/kubeshop/testkube/pkg/expressions"
"github.com/kubeshop/testkube/pkg/rand"
"github.com/kubeshop/testkube/pkg/testworkflows/testworkflowprocessor/constants"
)

var BypassToolkitCheck = corev1.EnvVar{
Name: "TK_TC_SECURITY",
Value: rand.String(20),
}

func AnnotateControlledBy(obj metav1.Object, rootId, id string) {
labels := obj.GetLabels()
if labels == nil {
Expand Down Expand Up @@ -122,8 +128,12 @@ func buildKubernetesContainers(stage Stage, init *initProcess, fsGroup *int64, m
init.ResetResults()
}

bypass := false
refEnvVar := ""
for _, e := range cr.Env {
if e.Name == BypassToolkitCheck.Name && e.Value == BypassToolkitCheck.Value {
bypass = true
}
if e.Name == "TK_REF" {
refEnvVar = e.Value
}
Expand All @@ -135,7 +145,7 @@ func buildKubernetesContainers(stage Stage, init *initProcess, fsGroup *int64, m
SetCommand(cr.Command...).
SetArgs(cr.Args...).
SetWorkingDir(cr.WorkingDir).
SetToolkit(cr.Image == constants.DefaultToolkitImage && c.Ref() == refEnvVar)
SetToolkit(bypass || (cr.Image == constants.DefaultToolkitImage && c.Ref() == refEnvVar))

for _, env := range cr.Env {
if strings.Contains(env.Value, "{{") {
Expand Down

0 comments on commit e249f5d

Please sign in to comment.