Skip to content

Commit

Permalink
fix: remove WorkflowSpec VolumeClaimTemplates patch key (#11662)
Browse files Browse the repository at this point in the history
Signed-off-by: sunyeongchoi <sn0716@naver.com>
  • Loading branch information
sunyeongchoi authored Oct 16, 2023
1 parent d654dc0 commit d1928e8
Showing 6 changed files with 73 additions and 17 deletions.
4 changes: 1 addition & 3 deletions api/jsonschema/schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions api/openapi-spec/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions pkg/apis/workflow/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions pkg/apis/workflow/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions pkg/apis/workflow/v1alpha1/workflow_types.go
Original file line number Diff line number Diff line change
@@ -290,9 +290,7 @@ type WorkflowSpec struct {
// VolumeClaimTemplates is a list of claims that containers are allowed to reference.
// The Workflow controller will create the claims at the beginning of the workflow
// and delete the claims upon completion of the workflow
// +patchStrategy=merge
// +patchMergeKey=name
VolumeClaimTemplates []apiv1.PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,6,opt,name=volumeClaimTemplates"`
VolumeClaimTemplates []apiv1.PersistentVolumeClaim `json:"volumeClaimTemplates,omitempty" protobuf:"bytes,6,opt,name=volumeClaimTemplates"`

// Parallelism limits the max total parallel pods that can execute at the same time in a workflow
Parallelism *int64 `json:"parallelism,omitempty" protobuf:"bytes,7,opt,name=parallelism"`
70 changes: 70 additions & 0 deletions workflow/controller/controller_test.go
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@ import (
"testing"
"time"

"k8s.io/apimachinery/pkg/api/resource"

"github.com/argoproj/pkg/sync"
"github.com/stretchr/testify/assert"
authorizationv1 "k8s.io/api/authorization/v1"
@@ -110,6 +112,41 @@ spec:
args: ["hello world"]
`

var testDefaultVolumeClaimTemplateWf = `
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: hello-world
labels:
foo: bar
spec:
volumeClaimTemplates:
- metadata:
name: workdir
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Mi
storageClassName: local-path
entrypoint: whalesay
serviceAccountName: whalesay
templates:
- name: whalesay
metadata:
annotations:
annotationKey1: "annotationValue1"
annotationKey2: "annotationValue2"
labels:
labelKey1: "labelValue1"
labelKey2: "labelValue2"
container:
image: docker/whalesay:latest
command: [cowsay]
args: ["hello world"]
`

var testDefaultWfTTL = `
apiVersion: argoproj.io/v1alpha1
kind: Workflow
@@ -295,6 +332,30 @@ func newControllerWithComplexDefaults() (context.CancelFunc, *WorkflowController
return cancel, controller
}

func newControllerWithDefaultsVolumeClaimTemplate() (context.CancelFunc, *WorkflowController) {
cancel, controller := newController(func(controller *WorkflowController) {
controller.Config.WorkflowDefaults = &wfv1.Workflow{
Spec: wfv1.WorkflowSpec{
VolumeClaimTemplates: []apiv1.PersistentVolumeClaim{{
ObjectMeta: metav1.ObjectMeta{
Name: "workdir",
},
Spec: apiv1.PersistentVolumeClaimSpec{
AccessModes: []apiv1.PersistentVolumeAccessMode{apiv1.ReadWriteOnce},
Resources: apiv1.ResourceRequirements{
Requests: apiv1.ResourceList{
apiv1.ResourceStorage: resource.MustParse("1Mi"),
},
},
StorageClassName: pointer.String("local-path"),
},
}},
},
}
})
return cancel, controller
}

func unmarshalArtifact(yamlStr string) *wfv1.Artifact {
var artifact wfv1.Artifact
wfv1.MustUnmarshal([]byte(yamlStr), &artifact)
@@ -497,6 +558,15 @@ func TestAddingWorkflowDefaultComplexTwo(t *testing.T) {
assert.Contains(t, workflow.Annotations, "annotation")
}

func TestAddingWorkflowDefaultVolumeClaimTemplate(t *testing.T) {
cancel, controller := newControllerWithDefaultsVolumeClaimTemplate()
defer cancel()
workflow := wfv1.MustUnmarshalWorkflow(testDefaultWf)
err := controller.setWorkflowDefaults(workflow)
assert.NoError(t, err)
assert.Equal(t, workflow, wfv1.MustUnmarshalWorkflow(testDefaultVolumeClaimTemplateWf))
}

func TestNamespacedController(t *testing.T) {
kubeClient := fake.Clientset{}
allowed := false

0 comments on commit d1928e8

Please sign in to comment.