Skip to content

Commit

Permalink
fix: Precedence of ContainerRuntimeExecutor and ContainerRuntimeExecu…
Browse files Browse the repository at this point in the history
…tors (#7056)

Signed-off-by: Saravanan Balasubramanian <sarabala1979@gmail.com>
  • Loading branch information
sarabala1979 authored Oct 26, 2021
1 parent 56ee941 commit 4734cbc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
6 changes: 3 additions & 3 deletions workflow/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1102,13 +1102,13 @@ func (wfc *WorkflowController) GetManagedNamespace() string {
}

func (wfc *WorkflowController) GetContainerRuntimeExecutor(labels labels.Labels) string {
if wfc.containerRuntimeExecutor != "" {
return wfc.containerRuntimeExecutor
}
executor, err := wfc.Config.GetContainerRuntimeExecutor(labels)
if err != nil {
log.WithError(err).Info("failed to determine container runtime executor")
}
if executor == "" && wfc.containerRuntimeExecutor != "" {
return wfc.containerRuntimeExecutor
}
return executor
}

Expand Down
21 changes: 21 additions & 0 deletions workflow/controller/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
apierr "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/kubernetes/fake"
Expand Down Expand Up @@ -7426,6 +7427,26 @@ func TestBuildRetryStrategyLocalScope(t *testing.T) {
assert.Equal(t, "6", localScope[common.LocalVarRetriesLastDuration])
}

func TestGetContainerRuntimeExecutor(t *testing.T) {
cancel, controller := newController()
defer cancel()
controller.Config.ContainerRuntimeExecutor = "pns"
controller.Config.ContainerRuntimeExecutors = config.ContainerRuntimeExecutors{
{
Name: "emissary",
Selector: metav1.LabelSelector{
MatchLabels: map[string]string{
"workflows.argoproj.io/container-runtime-executor": "emissary",
},
},
},
}
executor := controller.GetContainerRuntimeExecutor(labels.Set{})
assert.Equal(t, common.ContainerRuntimeExecutorPNS, executor)
executor = controller.GetContainerRuntimeExecutor(labels.Set{"workflows.argoproj.io/container-runtime-executor": "emissary"})
assert.Equal(t, common.ContainerRuntimeExecutorEmissary, executor)
}

var exitHandlerWithRetryNodeParam = `
apiVersion: argoproj.io/v1alpha1
kind: Workflow
Expand Down

0 comments on commit 4734cbc

Please sign in to comment.