Skip to content

Commit e5dc961

Browse files
committed
fix: Precedence of ContainerRuntimeExecutor and ContainerRuntimeExecutors (argoproj#7056)
Signed-off-by: Saravanan Balasubramanian <[email protected]>
1 parent 3f14c68 commit e5dc961

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

workflow/controller/controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,13 +1102,13 @@ func (wfc *WorkflowController) GetManagedNamespace() string {
11021102
}
11031103

11041104
func (wfc *WorkflowController) GetContainerRuntimeExecutor(labels labels.Labels) string {
1105-
if wfc.containerRuntimeExecutor != "" {
1106-
return wfc.containerRuntimeExecutor
1107-
}
11081105
executor, err := wfc.Config.GetContainerRuntimeExecutor(labels)
11091106
if err != nil {
11101107
log.WithError(err).Info("failed to determine container runtime executor")
11111108
}
1109+
if executor == "" && wfc.containerRuntimeExecutor != "" {
1110+
return wfc.containerRuntimeExecutor
1111+
}
11121112
return executor
11131113
}
11141114

workflow/controller/operator_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
apierr "k8s.io/apimachinery/pkg/api/errors"
2222
"k8s.io/apimachinery/pkg/api/resource"
2323
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24+
"k8s.io/apimachinery/pkg/labels"
2425
"k8s.io/apimachinery/pkg/runtime"
2526
"k8s.io/apimachinery/pkg/runtime/schema"
2627
"k8s.io/client-go/kubernetes/fake"
@@ -7413,6 +7414,26 @@ func TestBuildRetryStrategyLocalScope(t *testing.T) {
74137414
assert.Equal(t, "6", localScope[common.LocalVarRetriesLastDuration])
74147415
}
74157416

7417+
func TestGetContainerRuntimeExecutor(t *testing.T) {
7418+
cancel, controller := newController()
7419+
defer cancel()
7420+
controller.Config.ContainerRuntimeExecutor = "pns"
7421+
controller.Config.ContainerRuntimeExecutors = config.ContainerRuntimeExecutors{
7422+
{
7423+
Name: "emissary",
7424+
Selector: metav1.LabelSelector{
7425+
MatchLabels: map[string]string{
7426+
"workflows.argoproj.io/container-runtime-executor": "emissary",
7427+
},
7428+
},
7429+
},
7430+
}
7431+
executor := controller.GetContainerRuntimeExecutor(labels.Set{})
7432+
assert.Equal(t, common.ContainerRuntimeExecutorPNS, executor)
7433+
executor = controller.GetContainerRuntimeExecutor(labels.Set{"workflows.argoproj.io/container-runtime-executor": "emissary"})
7434+
assert.Equal(t, common.ContainerRuntimeExecutorEmissary, executor)
7435+
}
7436+
74167437
var exitHandlerWithRetryNodeParam = `
74177438
apiVersion: argoproj.io/v1alpha1
74187439
kind: Workflow

0 commit comments

Comments
 (0)