Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ workerSelector:
workload: benchmark-worker
volumes:
- name: external-storage
externalVolumeTemplate:
capacity: 1Gi
storageClassName: ${STORAGE_CLASS_NAME}
external:
template:
capacity: 1Gi
storageClassName: ${STORAGE_CLASS_NAME}
containers:
- name: glutton-storage
image: ko://go.ate.dev/substrate/cmd/benchmarking/glutton
Expand Down
7 changes: 4 additions & 3 deletions cmd/ate-setup/internal/demos/counter/counter.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ func (d *demo) externalVolumeValues(e *steps.Env) map[string]string {
"EXTERNAL_VOLUME_MOUNTS": " - name: external-data\n" +
" mountPath: /external-data",
"EXTERNAL_VOLUMES": "- name: external-data\n" +
" externalVolumeTemplate:\n" +
" capacity: 1Gi\n" +
" storageClassName: " + sc,
" external:\n" +
" template:\n" +
" capacity: 1Gi\n" +
" storageClassName: " + sc,
}
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/ate-setup/internal/demos/counter/counter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ func TestExternalVolumeRenders(t *testing.T) {
for _, want := range []string{
"--validate-existing-file-path=/external-data/test.txt",
"mountPath: /external-data",
"externalVolumeTemplate:",
"external:",
"template:",
tc.wantSC,
} {
if !strings.Contains(string(manifest), want) {
Expand Down
6 changes: 3 additions & 3 deletions cmd/ateapi/internal/apivalidation/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ func ValidateCustom_WorkerAssignment_WorkerSpiffeId(_ context.Context, _ operati
return validateSPIFFEID(fldPath, *value)
}

func ValidateCustom_ExternalVolume_VolumeType(_ context.Context, _ operation.Operation, fldPath *field.Path, value, _ *string) field.ErrorList {
func ValidateCustom_ExternalVolumeStatus_VolumeType(_ context.Context, _ operation.Operation, fldPath *field.Path, value, _ *string) field.ErrorList {
return resources.ValidateVolumeType(fldPath, *value)
}

func ValidateCustom_ExternalVolume_StorageVolumeId(_ context.Context, _ operation.Operation, fldPath *field.Path, value, _ *string) field.ErrorList {
func ValidateCustom_ExternalVolumeStatus_StorageVolumeId(_ context.Context, _ operation.Operation, fldPath *field.Path, value, _ *string) field.ErrorList {
return resources.ValidateStorageVolumeID(fldPath, *value)
}

func ValidateCustom_ExternalVolume_VolumeContext(_ context.Context, _ operation.Operation, fldPath *field.Path, value, _ map[string]string) field.ErrorList {
func ValidateCustom_ExternalVolumeStatus_VolumeContext(_ context.Context, _ operation.Operation, fldPath *field.Path, value, _ map[string]string) field.ErrorList {
return resources.ValidateCSIMap(fldPath, value)
}
42 changes: 21 additions & 21 deletions cmd/ateapi/internal/apivalidation/actor_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ func TestValidateCreateActorTemplateRequest(t *testing.T) {
func TestValidateCreateActorTemplateRequest_PreviewRestricted(t *testing.T) {
setPreviewForTest(t, "ALL")
req := &ateapipb.CreateActorTemplateRequest{ActorTemplate: validActorTemplate(func(tmpl *ateapipb.ActorTemplate) {
tmpl.Volumes = []*ateapipb.Volume{{Name: "data", ExternalVolumeTemplate: &ateapipb.ExternalVolumeTemplate{Capacity: "10Gi", StorageClassName: "fast-ssd"}}}
tmpl.Volumes = []*ateapipb.Volume{{Name: "data", External: &ateapipb.ExternalVolumeSource{Template: &ateapipb.ExternalVolumeTemplate{Capacity: "10Gi", StorageClassName: "fast-ssd"}}}}
})}

t.Run("allowed", func(t *testing.T) {
assertValidateErr(t, ValidateCreateActorTemplateRequest(context.Background(), req), nil)
})
t.Run("restricted", func(t *testing.T) {
ctx := preview.ContextWithOptOut(context.Background())
want := field.ErrorList{field.Forbidden(field.NewPath("actor_template", "volumes").Index(0).Child("external_volume_template"), "")}
want := field.ErrorList{field.Forbidden(field.NewPath("actor_template", "volumes").Index(0).Child("external"), "")}
assertValidateErr(t, ValidateCreateActorTemplateRequest(ctx, req), want)
})
}
Expand Down Expand Up @@ -771,52 +771,52 @@ func TestValidateActorTemplate(t *testing.T) {
}, {
name: "valid external volume template",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Volumes = []*ateapipb.Volume{{Name: "data", ExternalVolumeTemplate: &ateapipb.ExternalVolumeTemplate{Capacity: "10Gi", StorageClassName: "fast-ssd"}}}
tmpl.Volumes = []*ateapipb.Volume{{Name: "data", External: &ateapipb.ExternalVolumeSource{Template: &ateapipb.ExternalVolumeTemplate{Capacity: "10Gi", StorageClassName: "fast-ssd"}}}}
},
want: field.ErrorList{field.Forbidden(field.NewPath("volumes").Index(0).Child("external_volume_template"), "")},
want: field.ErrorList{field.Forbidden(field.NewPath("volumes").Index(0).Child("external"), "")},
wantWithPreview: map[string]field.ErrorList{"ALL": nil},
}, {
name: "external volume template missing capacity",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Volumes = []*ateapipb.Volume{{Name: "data", ExternalVolumeTemplate: &ateapipb.ExternalVolumeTemplate{StorageClassName: "fast-ssd"}}}
tmpl.Volumes = []*ateapipb.Volume{{Name: "data", External: &ateapipb.ExternalVolumeSource{Template: &ateapipb.ExternalVolumeTemplate{StorageClassName: "fast-ssd"}}}}
},
want: field.ErrorList{field.Forbidden(field.NewPath("volumes").Index(0).Child("external_volume_template"), "")},
wantWithPreview: map[string]field.ErrorList{"ALL": {field.Required(field.NewPath("volumes").Index(0).Child("external_volume_template", "capacity"), "")}},
want: field.ErrorList{field.Forbidden(field.NewPath("volumes").Index(0).Child("external"), "")},
wantWithPreview: map[string]field.ErrorList{"ALL": {field.Required(field.NewPath("volumes").Index(0).Child("external", "template", "capacity"), "")}},
}, {
name: "external volume template malformed capacity",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Volumes = []*ateapipb.Volume{{Name: "data", ExternalVolumeTemplate: &ateapipb.ExternalVolumeTemplate{Capacity: "ten gigs", StorageClassName: "fast-ssd"}}}
tmpl.Volumes = []*ateapipb.Volume{{Name: "data", External: &ateapipb.ExternalVolumeSource{Template: &ateapipb.ExternalVolumeTemplate{Capacity: "ten gigs", StorageClassName: "fast-ssd"}}}}
},
want: field.ErrorList{field.Forbidden(field.NewPath("volumes").Index(0).Child("external_volume_template"), "")},
wantWithPreview: map[string]field.ErrorList{"ALL": {field.Invalid(field.NewPath("volumes").Index(0).Child("external_volume_template", "capacity"), nil, "")}},
want: field.ErrorList{field.Forbidden(field.NewPath("volumes").Index(0).Child("external"), "")},
wantWithPreview: map[string]field.ErrorList{"ALL": {field.Invalid(field.NewPath("volumes").Index(0).Child("external", "template", "capacity"), nil, "")}},
}, {
name: "external volume template capacity at the length bound",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Volumes = []*ateapipb.Volume{{Name: "data", ExternalVolumeTemplate: &ateapipb.ExternalVolumeTemplate{Capacity: strings.Repeat("1", 30) + "Gi", StorageClassName: "fast-ssd"}}}
tmpl.Volumes = []*ateapipb.Volume{{Name: "data", External: &ateapipb.ExternalVolumeSource{Template: &ateapipb.ExternalVolumeTemplate{Capacity: strings.Repeat("1", 30) + "Gi", StorageClassName: "fast-ssd"}}}}
},
want: field.ErrorList{field.Forbidden(field.NewPath("volumes").Index(0).Child("external_volume_template"), "")},
want: field.ErrorList{field.Forbidden(field.NewPath("volumes").Index(0).Child("external"), "")},
wantWithPreview: map[string]field.ErrorList{"ALL": nil},
}, {
name: "external volume template capacity too long",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Volumes = []*ateapipb.Volume{{Name: "data", ExternalVolumeTemplate: &ateapipb.ExternalVolumeTemplate{Capacity: strings.Repeat("1", 31) + "Gi", StorageClassName: "fast-ssd"}}}
tmpl.Volumes = []*ateapipb.Volume{{Name: "data", External: &ateapipb.ExternalVolumeSource{Template: &ateapipb.ExternalVolumeTemplate{Capacity: strings.Repeat("1", 31) + "Gi", StorageClassName: "fast-ssd"}}}}
},
want: field.ErrorList{field.Forbidden(field.NewPath("volumes").Index(0).Child("external_volume_template"), "")},
wantWithPreview: map[string]field.ErrorList{"ALL": {field.TooLong(field.NewPath("volumes").Index(0).Child("external_volume_template", "capacity"), nil, 32).WithOrigin("maxLength")}},
want: field.ErrorList{field.Forbidden(field.NewPath("volumes").Index(0).Child("external"), "")},
wantWithPreview: map[string]field.ErrorList{"ALL": {field.TooLong(field.NewPath("volumes").Index(0).Child("external", "template", "capacity"), nil, 32).WithOrigin("maxLength")}},
}, {
name: "external volume template missing storage_class_name",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Volumes = []*ateapipb.Volume{{Name: "data", ExternalVolumeTemplate: &ateapipb.ExternalVolumeTemplate{Capacity: "10Gi"}}}
tmpl.Volumes = []*ateapipb.Volume{{Name: "data", External: &ateapipb.ExternalVolumeSource{Template: &ateapipb.ExternalVolumeTemplate{Capacity: "10Gi"}}}}
},
want: field.ErrorList{field.Forbidden(field.NewPath("volumes").Index(0).Child("external_volume_template"), "")},
wantWithPreview: map[string]field.ErrorList{"ALL": {field.Required(field.NewPath("volumes").Index(0).Child("external_volume_template", "storage_class_name"), "")}},
want: field.ErrorList{field.Forbidden(field.NewPath("volumes").Index(0).Child("external"), "")},
wantWithPreview: map[string]field.ErrorList{"ALL": {field.Required(field.NewPath("volumes").Index(0).Child("external", "template", "storage_class_name"), "")}},
}, {
name: "external volume template invalid storage_class_name",
mutate: func(tmpl *ateapipb.ActorTemplate) {
tmpl.Volumes = []*ateapipb.Volume{{Name: "data", ExternalVolumeTemplate: &ateapipb.ExternalVolumeTemplate{Capacity: "10Gi", StorageClassName: "Fast SSD"}}}
tmpl.Volumes = []*ateapipb.Volume{{Name: "data", External: &ateapipb.ExternalVolumeSource{Template: &ateapipb.ExternalVolumeTemplate{Capacity: "10Gi", StorageClassName: "Fast SSD"}}}}
},
want: field.ErrorList{field.Forbidden(field.NewPath("volumes").Index(0).Child("external_volume_template"), "")},
wantWithPreview: map[string]field.ErrorList{"ALL": {field.Invalid(field.NewPath("volumes").Index(0).Child("external_volume_template", "storage_class_name"), nil, "").WithOrigin("format=k8s-long-name")}},
want: field.ErrorList{field.Forbidden(field.NewPath("volumes").Index(0).Child("external"), "")},
wantWithPreview: map[string]field.ErrorList{"ALL": {field.Invalid(field.NewPath("volumes").Index(0).Child("external", "template", "storage_class_name"), nil, "").WithOrigin("format=k8s-long-name")}},
}, {
name: "valid resources",
mutate: func(tmpl *ateapipb.ActorTemplate) {
Expand Down
28 changes: 14 additions & 14 deletions cmd/ateapi/internal/apivalidation/actor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -620,59 +620,59 @@ func TestValidateActorUpdate(t *testing.T) {
name: "adding a volume",
oldVal: validActor(withActorStatus()),
newVal: validActor(withActorStatus(func(s *ateapipb.ActorStatus) {
s.ExternalVolumes = []*ateapipb.ExternalVolume{{Name: "vol-a", VolumeType: "substrate.io/mock"}}
s.ExternalVolumes = &ateapipb.ExternalVolumes{Volumes: []*ateapipb.ExternalVolumeStatus{{Name: "vol-a", VolumeType: "substrate.io/mock"}}}
})),
want: nil,
wantWithPreview: map[string]field.ErrorList{"ALL": nil},
}, {
name: "adding a volume to an actor with no status",
oldVal: validActor(),
newVal: validActor(withActorStatus(func(s *ateapipb.ActorStatus) {
s.ExternalVolumes = []*ateapipb.ExternalVolume{{Name: "vol-a", VolumeType: "substrate.io/mock"}}
s.ExternalVolumes = &ateapipb.ExternalVolumes{Volumes: []*ateapipb.ExternalVolumeStatus{{Name: "vol-a", VolumeType: "substrate.io/mock"}}}
})),
want: nil,
wantWithPreview: map[string]field.ErrorList{"ALL": nil},
}, {
name: "provisioning transition on an existing volume",
oldVal: validInput(withStatus(func(s *ateapipb.ActorStatus) {
s.ExternalVolumes = []*ateapipb.ExternalVolume{{Name: "vol-a", VolumeType: "substrate.io/mock"}}
s.ExternalVolumes = &ateapipb.ExternalVolumes{Volumes: []*ateapipb.ExternalVolumeStatus{{Name: "vol-a", VolumeType: "substrate.io/mock"}}}
})),
newVal: validActor(withActorStatus(func(s *ateapipb.ActorStatus) {
s.ExternalVolumes = []*ateapipb.ExternalVolume{{
s.ExternalVolumes = &ateapipb.ExternalVolumes{Volumes: []*ateapipb.ExternalVolumeStatus{{
Name: "vol-a",
VolumeType: "substrate.io/mock",
StorageVolumeId: "csi-426d29b7",
VolumeContext: map[string]string{"attachment": "iqn.2026-08.io.ate:vol-a"},
}}
}}}
})),
want: nil,
wantWithPreview: map[string]field.ErrorList{"ALL": nil},
}, {
name: "duplicate external_volumes volume_name",
oldVal: validActor(withActorStatus()),
newVal: validActor(withActorStatus(func(s *ateapipb.ActorStatus) {
s.ExternalVolumes = []*ateapipb.ExternalVolume{
s.ExternalVolumes = &ateapipb.ExternalVolumes{Volumes: []*ateapipb.ExternalVolumeStatus{
{Name: "vol-a", VolumeType: "substrate.io/mock"},
{Name: "vol-a", VolumeType: "substrate.io/mock"},
}
}}
})),
want: field.ErrorList{field.Duplicate(field.NewPath("status", "external_volumes").Index(1), nil)},
want: field.ErrorList{field.Duplicate(field.NewPath("status", "external_volumes", "volumes").Index(1), nil)},
wantWithPreview: map[string]field.ErrorList{
"ALL": {field.Duplicate(field.NewPath("status", "external_volumes").Index(1), nil)},
"ALL": {field.Duplicate(field.NewPath("status", "external_volumes", "volumes").Index(1), nil)},
},
}, {
name: "too many external_volumes",
oldVal: validActor(withActorStatus()),
newVal: validActor(withActorStatus(func(s *ateapipb.ActorStatus) {
vols := make([]*ateapipb.ExternalVolume, 33)
vols := make([]*ateapipb.ExternalVolumeStatus, 33)
for i := range vols {
vols[i] = &ateapipb.ExternalVolume{Name: fmt.Sprintf("vol-%d", i), VolumeType: "substrate.io/mock"}
vols[i] = &ateapipb.ExternalVolumeStatus{Name: fmt.Sprintf("vol-%d", i), VolumeType: "substrate.io/mock"}
}
s.ExternalVolumes = vols
s.ExternalVolumes = &ateapipb.ExternalVolumes{Volumes: vols}
})),
want: field.ErrorList{field.TooMany(field.NewPath("status", "external_volumes"), 33, 32).WithOrigin("maxItems")},
want: field.ErrorList{field.TooMany(field.NewPath("status", "external_volumes", "volumes"), 33, 32).WithOrigin("maxItems")},
wantWithPreview: map[string]field.ErrorList{
"ALL": {field.TooMany(field.NewPath("status", "external_volumes"), 33, 32).WithOrigin("maxItems")},
"ALL": {field.TooMany(field.NewPath("status", "external_volumes", "volumes"), 33, 32).WithOrigin("maxItems")},
},
}}
for _, tt := range tests {
Expand Down
Loading
Loading