Skip to content

Commit

Permalink
fix(controller): default volume/mount to emissary (#7125)
Browse files Browse the repository at this point in the history
Signed-off-by: Tianchu Zhao <evantczhao@gmail.com>
  • Loading branch information
tczhao authored and sarabala1979 committed Dec 15, 2021
1 parent 03a1314 commit 49b3f0c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
15 changes: 4 additions & 11 deletions workflow/controller/container_set_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ spec:
pod, err := getPod(woc, "pod")
assert.NoError(t, err)

socket := corev1.HostPathSocket
assert.ElementsMatch(t, []corev1.Volume{
{Name: "docker-sock", VolumeSource: corev1.VolumeSource{HostPath: &corev1.HostPathVolumeSource{Path: "/var/run/docker.sock", Type: &socket}}},
{Name: "var-run-argo", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
{Name: "workspace", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
}, pod.Spec.Volumes)

Expand All @@ -54,9 +53,7 @@ spec:
for _, c := range pod.Spec.Containers {
switch c.Name {
case common.WaitContainerName:
assert.ElementsMatch(t, []corev1.VolumeMount{
{Name: "docker-sock", MountPath: "/var/run/docker.sock", ReadOnly: true},
}, c.VolumeMounts)
assert.ElementsMatch(t, []corev1.VolumeMount{}, c.VolumeMounts)
case "ctr-0":
assert.ElementsMatch(t, []corev1.VolumeMount{
{Name: "workspace", MountPath: "/workspace"},
Expand Down Expand Up @@ -108,9 +105,8 @@ spec:
pod, err := getPod(woc, "pod")
assert.NoError(t, err)

socket := corev1.HostPathSocket
assert.ElementsMatch(t, []corev1.Volume{
{Name: "docker-sock", VolumeSource: corev1.VolumeSource{HostPath: &corev1.HostPathVolumeSource{Path: "/var/run/docker.sock", Type: &socket}}},
{Name: "var-run-argo", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
{Name: "workspace", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
{Name: "input-artifacts", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
}, pod.Spec.Volumes)
Expand All @@ -128,7 +124,6 @@ spec:
switch c.Name {
case common.WaitContainerName:
assert.ElementsMatch(t, []corev1.VolumeMount{
{Name: "docker-sock", MountPath: "/var/run/docker.sock", ReadOnly: true},
{Name: "workspace", MountPath: "/mainctrfs/workspace"},
{Name: "input-artifacts", MountPath: "/mainctrfs/in/in-0", SubPath: "in-0"},
}, c.VolumeMounts)
Expand Down Expand Up @@ -184,9 +179,8 @@ spec:
pod, err := getPod(woc, "pod")
assert.NoError(t, err)

socket := corev1.HostPathSocket
assert.ElementsMatch(t, []corev1.Volume{
{Name: "docker-sock", VolumeSource: corev1.VolumeSource{HostPath: &corev1.HostPathVolumeSource{Path: "/var/run/docker.sock", Type: &socket}}},
{Name: "var-run-argo", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
{Name: "workspace", VolumeSource: corev1.VolumeSource{EmptyDir: &corev1.EmptyDirVolumeSource{}}},
}, pod.Spec.Volumes)

Expand All @@ -197,7 +191,6 @@ spec:
switch c.Name {
case common.WaitContainerName:
assert.ElementsMatch(t, []corev1.VolumeMount{
{Name: "docker-sock", MountPath: "/var/run/docker.sock", ReadOnly: true},
{Name: "workspace", MountPath: "/mainctrfs/workspace"},
}, c.VolumeMounts)
case "main":
Expand Down
8 changes: 4 additions & 4 deletions workflow/controller/workflowpod.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ func (woc *wfOperationCtx) newWaitContainer(tmpl *wfv1.Template) *apiv1.Containe
// in order to SIGTERM/SIGKILL the pid
ctr.SecurityContext.Privileged = pointer.BoolPtr(true)
}
case "", common.ContainerRuntimeExecutorDocker:
case common.ContainerRuntimeExecutorDocker:
ctr.VolumeMounts = append(ctr.VolumeMounts, woc.getVolumeMountDockerSock(tmpl))
}
return ctr
Expand Down Expand Up @@ -638,10 +638,10 @@ func (woc *wfOperationCtx) createVolumes(tmpl *wfv1.Template) []apiv1.Volume {
}
switch woc.getContainerRuntimeExecutor() {
case common.ContainerRuntimeExecutorKubelet, common.ContainerRuntimeExecutorK8sAPI, common.ContainerRuntimeExecutorPNS:
case common.ContainerRuntimeExecutorEmissary:
volumes = append(volumes, volumeVarArgo)
default:
case common.ContainerRuntimeExecutorDocker:
volumes = append(volumes, woc.getVolumeDockerSock(tmpl))
default:
volumes = append(volumes, volumeVarArgo)
}
volumes = append(volumes, tmpl.Volumes...)
return volumes
Expand Down
2 changes: 2 additions & 0 deletions workflow/controller/workflowpod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,7 @@ spec:
func TestHybridWfVolumesWindows(t *testing.T) {
wf := wfv1.MustUnmarshalWorkflow(helloWindowsWf)
woc := newWoc(*wf)
woc.controller.Config.ContainerRuntimeExecutor = common.ContainerRuntimeExecutorDocker

ctx := context.Background()
mainCtr := woc.execWf.Spec.Templates[0].Container
Expand Down Expand Up @@ -1586,6 +1587,7 @@ func TestWindowsUNCPathsAreRemoved(t *testing.T) {
func TestHybridWfVolumesLinux(t *testing.T) {
wf := wfv1.MustUnmarshalWorkflow(helloLinuxWf)
woc := newWoc(*wf)
woc.controller.Config.ContainerRuntimeExecutor = common.ContainerRuntimeExecutorDocker

ctx := context.Background()
mainCtr := woc.execWf.Spec.Templates[0].Container
Expand Down
4 changes: 2 additions & 2 deletions workflow/validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,7 @@ func TestBaseImageOutputVerify(t *testing.T) {
wfNonPathOutputParam := unmarshalWf(nonPathOutputParameter)
var err error

for _, executor := range []string{common.ContainerRuntimeExecutorK8sAPI, common.ContainerRuntimeExecutorKubelet, common.ContainerRuntimeExecutorPNS, common.ContainerRuntimeExecutorDocker, ""} {
for _, executor := range []string{common.ContainerRuntimeExecutorK8sAPI, common.ContainerRuntimeExecutorKubelet, common.ContainerRuntimeExecutorPNS, common.ContainerRuntimeExecutorDocker, common.ContainerRuntimeExecutorDocker, common.ContainerRuntimeExecutorEmissary, ""} {
switch executor {
case common.ContainerRuntimeExecutorK8sAPI, common.ContainerRuntimeExecutorKubelet:
_, err = ValidateWorkflow(wftmplGetter, cwftmplGetter, wfBaseOutArt, ValidateOpts{ContainerRuntimeExecutor: executor})
Expand All @@ -1644,7 +1644,7 @@ func TestBaseImageOutputVerify(t *testing.T) {
assert.NoError(t, err)
_, err = ValidateWorkflow(wftmplGetter, cwftmplGetter, wfBaseWithEmptyDirOutArt, ValidateOpts{ContainerRuntimeExecutor: executor})
assert.Error(t, err)
case common.ContainerRuntimeExecutorDocker, "":
case common.ContainerRuntimeExecutorDocker, common.ContainerRuntimeExecutorEmissary, "":
_, err = ValidateWorkflow(wftmplGetter, cwftmplGetter, wfBaseOutArt, ValidateOpts{ContainerRuntimeExecutor: executor})
assert.NoError(t, err)
_, err = ValidateWorkflow(wftmplGetter, cwftmplGetter, wfBaseOutParam, ValidateOpts{ContainerRuntimeExecutor: executor})
Expand Down

0 comments on commit 49b3f0c

Please sign in to comment.