From cab0c3b58fb063df93b1ce000442b5c033efad89 Mon Sep 17 00:00:00 2001 From: Grant Linville Date: Wed, 13 Dec 2023 16:54:32 -0500 Subject: [PATCH] Revert "Resolved offerings (#2369)" This reverts commit dbd950dcf3d71a9f1d5bb74efda3f949576f6b05. Signed-off-by: Grant Linville --- docs/docs/40-admin/03-computeclasses.md | 1 - pkg/apis/api.acorn.io/v1/types.go | 5 +- pkg/apis/internal.acorn.io/v1/appinstance.go | 39 ++- .../v1/zz_generated.deepcopy.go | 143 +++++------ .../testdata/TestAll/acorn_all_-o_json.golden | 2 +- .../testdata/TestAll/acorn_all_-o_yaml.golden | 2 +- pkg/controller/appdefinition/deploy.go | 22 -- .../testdata/TestComputeMem.golden | 6 +- .../testdata/acorn/basic/expected.golden | 4 +- .../testdata/acorn/labels/expected.golden | 4 +- .../testdata/assignnamespace/expected.golden | 4 +- .../with-local-image/expected.golden | 2 +- .../expected.golden | 16 +- .../all-set-overwrite-computeclass/input.yaml | 15 +- .../computeclass/all-set/expected.golden | 16 +- .../testdata/computeclass/all-set/input.yaml | 15 +- .../computeclass/container/expected.golden | 16 +- .../computeclass/container/input.yaml | 15 +- .../different-computeclass/expected.golden | 17 +- .../different-computeclass/input.yaml | 15 +- .../testdata/computeclass/job/expected.golden | 16 +- .../testdata/computeclass/job/input.yaml | 15 +- .../expected.golden | 16 +- .../input.yaml | 15 +- .../sidecar/expected.yaml.d/appinstance.yaml | 9 +- .../testdata/computeclass/sidecar/input.yaml | 9 +- .../two-containers/expected.golden | 17 +- .../computeclass/two-containers/input.yaml | 15 +- .../expected.golden | 16 +- .../with-acornfile-computeclass/input.yaml | 15 +- .../testdata/depends-ready/expected.golden | 2 +- .../testdata/depends/expected.golden | 2 +- .../testdata/deployspec/basic/expected.golden | 2 +- .../filter-user-labels/expected.golden | 2 +- .../deployspec/karpenter/expected.golden | 2 +- .../deployspec/labels/expected.golden | 2 +- .../deployspec/metrics/expected.golden | 2 +- .../deployspec/no-user-labels/expected.golden | 2 +- .../deployspec/pre-stop/basic/expected.golden | 2 +- .../deployspec/pre-stop/dev/expected.golden | 2 +- .../deployspec/pre-stop/job/expected.golden | 2 +- .../pre-stop/no-ports/expected.golden | 2 +- .../ports-only-sidecar/expected.golden | 2 +- .../pre-stop/stateful/expected.golden | 4 +- .../deployspec/pre-stop/stateful/input.yaml | 2 +- .../testdata/deployspec/scale/expected.golden | 2 +- .../testdata/deployspec/stop/expected.golden | 2 +- .../testdata/files-bug/expected.golden | 2 +- .../testdata/files/expected.golden | 2 +- .../testdata/globalenv/expected.golden | 4 +- .../testdata/ingress/basic/expected.golden | 2 +- .../ingress/clusterdomainport/expected.golden | 2 +- .../testdata/ingress/labels/expected.golden | 2 +- .../ingress/letsencrypt/expected.golden | 2 +- .../ingress/prefix/prefix-1/expected.golden | 2 +- .../ingress/prefix/prefix-2/expected.golden | 2 +- .../testdata/interpolation/expected.golden | 2 +- .../testdata/job/basic/expected.golden | 2 +- .../job/event-jobs-create-app/expected.golden | 2 +- .../job/event-jobs-delete-app/expected.golden | 2 +- .../job/event-jobs-start-app/expected.golden | 2 +- .../job/event-jobs-stop-app/expected.golden | 2 +- .../expected.golden | 2 +- .../job/event-jobs-update-app/expected.golden | 2 +- .../expected.golden | 2 +- .../expected.golden | 2 +- .../testdata/job/labels/expected.golden | 2 +- .../testdata/link/expected.golden | 2 +- .../memory/all-set-overwrite/expected.golden | 16 +- .../memory/all-set-overwrite/input.yaml | 17 +- .../testdata/memory/all-set/expected.golden | 16 +- .../testdata/memory/all-set/input.yaml | 15 +- .../testdata/memory/container/expected.golden | 16 +- .../testdata/memory/container/input.yaml | 15 +- .../testdata/memory/job/expected.golden | 16 +- .../testdata/memory/job/input.yaml | 15 +- .../expected.golden | 16 +- .../overwrite-acornfile-memory/input.yaml | 15 +- .../testdata/memory/sidecar/expected.golden | 16 +- .../testdata/memory/sidecar/input.yaml | 15 +- .../memory/two-containers/expected.golden | 17 +- .../testdata/memory/two-containers/input.yaml | 15 +- .../with-acornfile-memory/expected.golden | 16 +- .../memory/with-acornfile-memory/input.yaml | 15 +- .../testdata/parseappimage/expected.golden | 2 +- .../testdata/parsedevmode/expected.golden | 2 +- .../testdata/permissions/both/expected.golden | 2 +- .../bothwithnopermissions/expected.golden | 2 +- .../permissions/container/expected.golden | 2 +- .../containerwithnamespace/expected.golden | 2 +- .../differentpermissions/expected.golden | 2 +- .../testdata/permissions/job/expected.golden | 2 +- .../multiplecontainers/expected.golden | 2 +- .../permissions/multiplejobs/expected.golden | 2 +- .../testdata/probes/expected.golden | 2 +- .../pullsecrets/custom/expected.golden | 2 +- .../pullsecrets/default/expected.golden | 2 +- .../testdata/router/expected.golden | 2 +- .../testdata/secret/expected.golden | 2 +- .../testdata/service/alias/expected.golden | 2 +- .../testdata/service/basic/expected.golden | 2 +- .../testdata/template/expected.golden | 2 +- .../expected.golden | 14 +- .../input.yaml | 2 +- .../configure-but-no-bind/expected.golden | 2 +- .../volumes/contextdir/expected.golden | 2 +- .../testdata/volumes/defaults/expected.golden | 4 +- .../testdata/volumes/defaults/input.yaml | 2 +- .../testdata/volumes/empty/expected.golden | 2 +- .../volumes/ephemeral-bound/expected.golden | 2 +- .../volumes/ephemeral/expected.golden | 2 +- .../volumes/inactive-class/expected.golden | 4 +- .../volumes/inactive-class/input.yaml | 2 +- .../volumes/named-bound/expected.golden | 2 +- .../testdata/volumes/named/expected.golden | 2 +- .../volumes/no-default-class/expected.golden | 2 +- .../testdata/volumes/preload/expected.golden | 2 +- .../volumes/reuse-existing/expected.golden | 2 +- pkg/controller/appdefinition/volume.go | 19 +- pkg/controller/appstatus/check.go | 2 +- pkg/controller/appstatus/check_test.go | 2 +- .../defaults.go} | 20 +- pkg/controller/defaults/memory.go | 84 +++++++ pkg/controller/defaults/memory_test.go | 74 ++++++ .../{resolvedofferings => defaults}/region.go | 4 +- .../region_test.go | 2 +- .../memory}/all-set-overwrite/existing.yaml | 0 .../memory/all-set-overwrite}/expected.golden | 18 +- .../memory}/all-set-overwrite/input.yaml | 0 .../testdata/memory}/all-set/existing.yaml | 0 .../testdata/memory/all-set/expected.golden | 61 +++++ .../testdata/memory}/all-set/input.yaml | 0 .../testdata/memory}/container/existing.yaml | 0 .../memory/container}/expected.golden | 19 +- .../testdata/memory}/container/input.yaml | 0 .../testdata/memory}/job/existing.yaml | 0 .../testdata/memory/job}/expected.golden | 19 +- .../testdata/memory}/job/input.yaml | 0 .../overwrite-acornfile-memory/existing.yaml | 0 .../expected.golden | 17 +- .../overwrite-acornfile-memory/input.yaml | 0 .../memory}/same-generation/expected.golden | 15 +- .../memory}/same-generation/input.yaml | 13 +- .../testdata/memory}/sidecar/existing.yaml | 0 .../testdata/memory}/sidecar/expected.golden | 17 +- .../testdata/memory}/sidecar/input.yaml | 0 .../existing.yaml | 0 .../expected.yaml | 6 +- .../two-ccc-defaults-should-error/input.yaml | 0 .../memory}/two-containers/existing.yaml | 0 .../memory}/two-containers/expected.golden | 17 +- .../memory}/two-containers/input.yaml | 0 .../existing.yaml | 0 .../expected.yaml | 6 +- .../two-pcc-defaults-should-error/input.yaml | 0 .../with-acornfile-memory/existing.yaml | 0 .../with-acornfile-memory/expected.golden | 17 +- .../memory}/with-acornfile-memory/input.yaml | 0 .../testdata/region/default/existing.yaml | 0 .../testdata/region/default}/expected.golden | 14 +- .../testdata/region/default/input.yaml | 0 .../project-default-status/existing.yaml | 0 .../project-default-status}/expected.golden | 14 +- .../region/project-default-status/input.yaml | 0 .../region/region-on-spec/existing.yaml | 0 .../region/region-on-spec/expected.golden | 13 +- .../testdata/region/region-on-spec/input.yaml | 0 .../existing.yaml | 0 .../expected.golden | 17 +- .../input.yaml | 0 .../existing.yaml | 0 .../expected.golden | 6 +- .../volume-class-defaults-same-gen/input.yaml | 0 .../volume-class-defaults-set/existing.yaml | 24 ++ .../volume-class-defaults-set/expected.golden | 54 +++++ .../volume-class-defaults-set/input.yaml | 26 ++ .../existing.yaml | 0 .../expected.golden | 16 +- .../input.yaml | 0 .../existing.yaml | 0 .../expected.golden | 17 +- .../input.yaml | 0 .../volume-class-fill-defaults/existing.yaml | 0 .../expected.golden | 17 +- .../volume-class-fill-defaults/input.yaml | 0 .../existing.yaml | 0 .../expected.golden | 16 +- .../input.yaml | 0 .../volume-class-fill-size/existing.yaml | 0 .../volume-class-fill-size/expected.golden | 19 +- .../volume-class-fill-size/input.yaml | 0 .../existing.yaml | 0 .../expected.yaml | 4 +- .../input.yaml | 0 .../existing.yaml | 0 .../expected.yaml | 4 +- .../input.yaml | 0 pkg/controller/defaults/volumeclass.go | 95 ++++++++ .../volumeclass_test.go | 6 +- pkg/controller/quota/quota.go | 14 +- .../status-default-volume-size/input.yaml | 4 +- .../resolvedofferings/computeclass.go | 123 ---------- .../resolvedofferings/computeclass_test.go | 86 ------- .../existing.yaml | 31 --- .../expected.golden | 68 ------ .../input.yaml | 32 --- .../all-set-overwrite/expected.golden | 65 ----- .../compute-class-default/existing.yaml | 31 --- .../compute-class-default/expected.golden | 67 ------ .../compute-class-default/input.yaml | 31 --- .../user-override-compute-class/existing.yaml | 31 --- .../expected.golden | 70 ------ .../user-override-compute-class/input.yaml | 34 --- .../resolvedofferings/volumeclass.go | 99 -------- pkg/controller/routes.go | 8 +- pkg/controller/scheduling/scheduling.go | 8 +- .../expected.golden | 13 +- .../all-set-overwrite-computeclass/input.yaml | 13 +- .../computeclass/all-set/expected.golden | 13 +- .../testdata/computeclass/all-set/input.yaml | 13 +- .../computeclass/container/expected.golden | 13 +- .../computeclass/container/input.yaml | 14 +- .../different-computeclass/expected.golden | 13 +- .../different-computeclass/input.yaml | 13 +- .../expected.golden | 13 +- .../different-digest-generation/input.yaml | 13 +- .../expected.golden | 13 +- .../input.yaml | 13 +- .../testdata/computeclass/job/expected.golden | 13 +- .../testdata/computeclass/job/input.yaml | 13 +- .../expected.golden | 13 +- .../input.yaml | 13 +- .../priority-class/expected.golden | 13 +- .../computeclass/priority-class/input.yaml | 13 +- .../same-digest-generation/expected.golden | 13 +- .../same-digest-generation/input.yaml | 13 +- .../same-generation/expected.golden | 13 +- .../computeclass/same-generation/input.yaml | 14 +- .../computeclass/sidecar/expected.yaml | 7 +- .../testdata/computeclass/sidecar/input.yaml | 7 +- .../expected.yaml | 13 +- .../two-ccc-defaults-should-error/input.yaml | 13 +- .../two-containers/expected.golden | 13 +- .../computeclass/two-containers/input.yaml | 13 +- .../expected.yaml | 13 +- .../two-pcc-defaults-should-error/input.yaml | 13 +- .../expected.golden | 13 +- .../with-acornfile-computeclass/input.yaml | 13 +- .../memory/all-set-overwrite/expected.golden | 13 +- .../memory/all-set-overwrite/input.yaml | 13 +- .../testdata/memory/all-set/expected.golden | 13 +- .../testdata/memory/all-set/input.yaml | 13 +- .../testdata/memory/container/expected.golden | 19 +- .../testdata/memory/container/input.yaml | 13 +- .../testdata/memory/job/expected.golden | 19 +- .../scheduling/testdata/memory/job/input.yaml | 13 +- .../expected.golden | 19 +- .../overwrite-acornfile-memory/input.yaml | 13 +- .../memory/same-generation/expected.golden | 13 +- .../memory/same-generation/input.yaml | 13 +- .../testdata/memory/sidecar/expected.golden | 2 +- .../memory/two-containers/expected.golden | 13 +- .../testdata/memory/two-containers/input.yaml | 13 +- .../with-acornfile-memory/expected.golden | 19 +- .../memory/with-acornfile-memory/input.yaml | 13 +- .../tolerations/container/expected.golden | 2 +- .../testdata/tolerations/container/input.yaml | 1 + .../testdata/tolerations/job/expected.golden | 2 +- .../testdata/tolerations/job/input.yaml | 1 + pkg/labels/labels.go | 1 - pkg/openapi/generated/openapi_generated.go | 223 ++++++++---------- .../apigroups/acorn/apps/validator.go | 28 ++- .../apigroups/acorn/apps/validator_test.go | 2 +- .../acorn/projects/validator_test.go | 42 +--- pkg/volume/volume.go | 63 +---- 275 files changed, 1352 insertions(+), 2166 deletions(-) rename pkg/controller/{resolvedofferings/resolvedofferings.go => defaults/defaults.go} (63%) create mode 100644 pkg/controller/defaults/memory.go create mode 100644 pkg/controller/defaults/memory_test.go rename pkg/controller/{resolvedofferings => defaults}/region.go (91%) rename pkg/controller/{resolvedofferings => defaults}/region_test.go (95%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/all-set-overwrite/existing.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass/all-set => defaults/testdata/memory/all-set-overwrite}/expected.golden (86%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/all-set-overwrite/input.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/all-set/existing.yaml (100%) create mode 100644 pkg/controller/defaults/testdata/memory/all-set/expected.golden rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/all-set/input.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/container/existing.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass/job => defaults/testdata/memory/container}/expected.golden (86%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/container/input.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/job/existing.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass/container => defaults/testdata/memory/job}/expected.golden (84%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/job/input.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/overwrite-acornfile-memory/existing.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/overwrite-acornfile-memory/expected.golden (86%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/overwrite-acornfile-memory/input.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/same-generation/expected.golden (86%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/same-generation/input.yaml (83%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/sidecar/existing.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/sidecar/expected.golden (86%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/sidecar/input.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/two-ccc-defaults-should-error/existing.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass/two-pcc-defaults-should-error => defaults/testdata/memory/two-ccc-defaults-should-error}/expected.yaml (94%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/two-ccc-defaults-should-error/input.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/two-containers/existing.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/two-containers/expected.golden (86%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/two-containers/input.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/two-pcc-defaults-should-error/existing.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass/two-ccc-defaults-should-error => defaults/testdata/memory/two-pcc-defaults-should-error}/expected.yaml (94%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/two-pcc-defaults-should-error/input.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/with-acornfile-memory/existing.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/with-acornfile-memory/expected.golden (85%) rename pkg/controller/{resolvedofferings/testdata/computeclass => defaults/testdata/memory}/with-acornfile-memory/input.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/region/default/existing.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/region/project-default-status => defaults/testdata/region/default}/expected.golden (82%) rename pkg/controller/{resolvedofferings => defaults}/testdata/region/default/input.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/region/project-default-status/existing.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/region/default => defaults/testdata/region/project-default-status}/expected.golden (82%) rename pkg/controller/{resolvedofferings => defaults}/testdata/region/project-default-status/input.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/region/region-on-spec/existing.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/region/region-on-spec/expected.golden (80%) rename pkg/controller/{resolvedofferings => defaults}/testdata/region/region-on-spec/input.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/cluster-and-project-class-same-name/existing.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/cluster-and-project-class-same-name/expected.golden (84%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/cluster-and-project-class-same-name/input.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-defaults-same-gen/existing.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-defaults-same-gen/expected.golden (85%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-defaults-same-gen/input.yaml (100%) create mode 100644 pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/existing.yaml create mode 100644 pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/expected.golden create mode 100644 pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/input.yaml rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-fill-cluster-default/existing.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-fill-cluster-default/expected.golden (86%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-fill-cluster-default/input.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-fill-defaults-with-bind/existing.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-fill-defaults-with-bind/expected.golden (84%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-fill-defaults-with-bind/input.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-fill-defaults/existing.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-fill-defaults/expected.golden (83%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-fill-defaults/input.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-fill-project-default/existing.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-fill-project-default/expected.golden (87%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-fill-project-default/input.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-fill-size/existing.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-fill-size/expected.golden (80%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-fill-size/input.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-two-cluster-defaults/existing.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/volumeclass/volume-class-two-project-defaults => defaults/testdata/volumeclass/volume-class-two-cluster-defaults}/expected.yaml (74%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-two-cluster-defaults/input.yaml (100%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-two-project-defaults/existing.yaml (100%) rename pkg/controller/{resolvedofferings/testdata/volumeclass/volume-class-two-cluster-defaults => defaults/testdata/volumeclass/volume-class-two-project-defaults}/expected.yaml (74%) rename pkg/controller/{resolvedofferings => defaults}/testdata/volumeclass/volume-class-two-project-defaults/input.yaml (100%) create mode 100644 pkg/controller/defaults/volumeclass.go rename pkg/controller/{resolvedofferings => defaults}/volumeclass_test.go (92%) delete mode 100644 pkg/controller/resolvedofferings/computeclass.go delete mode 100644 pkg/controller/resolvedofferings/computeclass_test.go delete mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/existing.yaml delete mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/expected.golden delete mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/input.yaml delete mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/all-set-overwrite/expected.golden delete mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/existing.yaml delete mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/expected.golden delete mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/input.yaml delete mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/existing.yaml delete mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/expected.golden delete mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/input.yaml delete mode 100644 pkg/controller/resolvedofferings/volumeclass.go diff --git a/docs/docs/40-admin/03-computeclasses.md b/docs/docs/40-admin/03-computeclasses.md index 58b322c03..1445417d8 100644 --- a/docs/docs/40-admin/03-computeclasses.md +++ b/docs/docs/40-admin/03-computeclasses.md @@ -40,7 +40,6 @@ affinity: # The same affinity fields for Pods operator: In values: - bar -supportedRegions: ["local"] # should always be set to ["local"] ``` If `memory.min`, `memory.max`, `memory.values`, `affinity`, and `tolerations` are not given, then there are no scheduling rules for workloads using the compute class. diff --git a/pkg/apis/api.acorn.io/v1/types.go b/pkg/apis/api.acorn.io/v1/types.go index 843112c8d..5dfa25c81 100644 --- a/pkg/apis/api.acorn.io/v1/types.go +++ b/pkg/apis/api.acorn.io/v1/types.go @@ -23,7 +23,10 @@ func (in *App) GetStopped() bool { } func (in *App) GetRegion() string { - return in.Status.ResolvedOfferings.Region + if in.Spec.Region != "" { + return in.Spec.Region + } + return in.Status.Defaults.Region } type Acornfile v1.AppSpec diff --git a/pkg/apis/internal.acorn.io/v1/appinstance.go b/pkg/apis/internal.acorn.io/v1/appinstance.go index 54ea42cca..deccdebca 100644 --- a/pkg/apis/internal.acorn.io/v1/appinstance.go +++ b/pkg/apis/internal.acorn.io/v1/appinstance.go @@ -14,7 +14,7 @@ type AppInstanceCondition string var ( AppInstanceConditionDefined = "defined" - AppInstanceConditionResolvedOfferings = "resolved-offerings" + AppInstanceConditionDefaults = "defaults" AppInstanceConditionScheduling = "scheduling" AppInstanceConditionNamespace = "namespace" AppInstanceConditionParsed = "parsed" @@ -52,18 +52,23 @@ type AppInstance struct { } func (in *AppInstance) HasRegion(region string) bool { - return in.Status.ResolvedOfferings.Region == region + return in.Status.Defaults.Region == region || in.Spec.Region == region } func (in *AppInstance) GetRegion() string { - return in.Status.ResolvedOfferings.Region + if in.Spec.Region != "" { + return in.Spec.Region + } + return in.Status.Defaults.Region } func (in *AppInstance) SetDefaultRegion(region string) { - if in.Spec.Region != "" { - in.Status.ResolvedOfferings.Region = in.Spec.Region - } else if in.Status.ResolvedOfferings.Region == "" { - in.Status.ResolvedOfferings.Region = region + if in.Spec.Region == "" { + if in.Status.Defaults.Region == "" { + in.Status.Defaults.Region = region + } + } else { + in.Status.Defaults.Region = "" } } @@ -204,7 +209,7 @@ type AppInstanceStatus struct { AppStatus AppStatus `json:"appStatus,omitempty"` Scheduling map[string]Scheduling `json:"scheduling,omitempty"` Conditions []Condition `json:"conditions,omitempty"` - ResolvedOfferings ResolvedOfferings `json:"resolvedOfferings,omitempty"` + Defaults Defaults `json:"defaults,omitempty"` Summary CommonSummary `json:"summary,omitempty"` Permissions []Permissions `json:"permissions,omitempty"` // Permissions given to this appInstance (only containers within, not nested Acorns/Services) DeniedConsumerPermissions []Permissions `json:"deniedConsumerPermissions,omitempty"` // Permissions given to this appInstance by a consumed service, which it is not authorized to have @@ -224,25 +229,19 @@ type AppStatusStaged struct { ImageAllowed *bool `json:"imageAllowed,omitempty"` } -type ResolvedOfferings struct { - Volumes map[string]VolumeResolvedOffering `json:"volumes,omitempty"` - VolumeSize *resource.Quantity `json:"volumeSize,omitempty"` - Containers map[string]ContainerResolvedOffering `json:"containers,omitempty"` - Region string `json:"region,omitempty"` +type Defaults struct { + VolumeSize *resource.Quantity `json:"volumeSize,omitempty"` + Volumes map[string]VolumeDefault `json:"volumes,omitempty"` + Memory map[string]*int64 `json:"memory,omitempty"` + Region string `json:"region,omitempty"` } -type VolumeResolvedOffering struct { +type VolumeDefault struct { Class string `json:"class,omitempty"` Size Quantity `json:"size,omitempty"` AccessModes AccessModes `json:"accessModes,omitempty"` } -type ContainerResolvedOffering struct { - Class string `json:"class,omitempty"` - Memory *int64 `json:"memory,omitempty"` - CPUScaler *float64 `json:"cpuScaler,omitempty"` -} - type Scheduling struct { Requirements corev1.ResourceRequirements `json:"requirements,omitempty"` Affinity *corev1.Affinity `json:"affinity,omitempty"` diff --git a/pkg/apis/internal.acorn.io/v1/zz_generated.deepcopy.go b/pkg/apis/internal.acorn.io/v1/zz_generated.deepcopy.go index 018136105..4723a1893 100644 --- a/pkg/apis/internal.acorn.io/v1/zz_generated.deepcopy.go +++ b/pkg/apis/internal.acorn.io/v1/zz_generated.deepcopy.go @@ -584,7 +584,7 @@ func (in *AppInstanceStatus) DeepCopyInto(out *AppInstanceStatus) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - in.ResolvedOfferings.DeepCopyInto(&out.ResolvedOfferings) + in.Defaults.DeepCopyInto(&out.Defaults) in.Summary.DeepCopyInto(&out.Summary) if in.Permissions != nil { in, out := &in.Permissions, &out.Permissions @@ -1344,31 +1344,6 @@ func (in *ContainerImageBuilderSpec) DeepCopy() *ContainerImageBuilderSpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ContainerResolvedOffering) DeepCopyInto(out *ContainerResolvedOffering) { - *out = *in - if in.Memory != nil { - in, out := &in.Memory, &out.Memory - *out = new(int64) - **out = **in - } - if in.CPUScaler != nil { - in, out := &in.CPUScaler, &out.CPUScaler - *out = new(float64) - **out = **in - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerResolvedOffering. -func (in *ContainerResolvedOffering) DeepCopy() *ContainerResolvedOffering { - if in == nil { - return nil - } - out := new(ContainerResolvedOffering) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ContainerStatus) DeepCopyInto(out *ContainerStatus) { *out = *in @@ -1399,6 +1374,48 @@ func (in *ContainerStatus) DeepCopy() *ContainerStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Defaults) DeepCopyInto(out *Defaults) { + *out = *in + if in.VolumeSize != nil { + in, out := &in.VolumeSize, &out.VolumeSize + x := (*in).DeepCopy() + *out = &x + } + if in.Volumes != nil { + in, out := &in.Volumes, &out.Volumes + *out = make(map[string]VolumeDefault, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + } + if in.Memory != nil { + in, out := &in.Memory, &out.Memory + *out = make(map[string]*int64, len(*in)) + for key, val := range *in { + var outVal *int64 + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = new(int64) + **out = **in + } + (*out)[key] = outVal + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Defaults. +func (in *Defaults) DeepCopy() *Defaults { + if in == nil { + return nil + } + out := new(Defaults) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in Dependencies) DeepCopyInto(out *Dependencies) { { @@ -2767,40 +2784,6 @@ func (in *ReplicasSummary) DeepCopy() *ReplicasSummary { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResolvedOfferings) DeepCopyInto(out *ResolvedOfferings) { - *out = *in - if in.Volumes != nil { - in, out := &in.Volumes, &out.Volumes - *out = make(map[string]VolumeResolvedOffering, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - } - if in.VolumeSize != nil { - in, out := &in.VolumeSize, &out.VolumeSize - x := (*in).DeepCopy() - *out = &x - } - if in.Containers != nil { - in, out := &in.Containers, &out.Containers - *out = make(map[string]ContainerResolvedOffering, len(*in)) - for key, val := range *in { - (*out)[key] = *val.DeepCopy() - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResolvedOfferings. -func (in *ResolvedOfferings) DeepCopy() *ResolvedOfferings { - if in == nil { - return nil - } - out := new(ResolvedOfferings) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Route) DeepCopyInto(out *Route) { *out = *in @@ -3619,6 +3602,26 @@ func (in VolumeBindings) DeepCopy() VolumeBindings { return *out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VolumeDefault) DeepCopyInto(out *VolumeDefault) { + *out = *in + if in.AccessModes != nil { + in, out := &in.AccessModes, &out.AccessModes + *out = make(AccessModes, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeDefault. +func (in *VolumeDefault) DeepCopy() *VolumeDefault { + if in == nil { + return nil + } + out := new(VolumeDefault) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VolumeMount) DeepCopyInto(out *VolumeMount) { *out = *in @@ -3669,26 +3672,6 @@ func (in *VolumeRequest) DeepCopy() *VolumeRequest { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *VolumeResolvedOffering) DeepCopyInto(out *VolumeResolvedOffering) { - *out = *in - if in.AccessModes != nil { - in, out := &in.AccessModes, &out.AccessModes - *out = make(AccessModes, len(*in)) - copy(*out, *in) - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeResolvedOffering. -func (in *VolumeResolvedOffering) DeepCopy() *VolumeResolvedOffering { - if in == nil { - return nil - } - out := new(VolumeResolvedOffering) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VolumeSecretMount) DeepCopyInto(out *VolumeSecretMount) { *out = *in diff --git a/pkg/cli/testdata/TestAll/acorn_all_-o_json.golden b/pkg/cli/testdata/TestAll/acorn_all_-o_json.golden index b6172d9e2..0b362c571 100644 --- a/pkg/cli/testdata/TestAll/acorn_all_-o_json.golden +++ b/pkg/cli/testdata/TestAll/acorn_all_-o_json.golden @@ -31,7 +31,7 @@ ACORNS: }, "appSpec": {}, "appStatus": {}, - "resolvedOfferings": {}, + "defaults": {}, "summary": {} } } diff --git a/pkg/cli/testdata/TestAll/acorn_all_-o_yaml.golden b/pkg/cli/testdata/TestAll/acorn_all_-o_yaml.golden index 93a96a578..a8f6731ff 100644 --- a/pkg/cli/testdata/TestAll/acorn_all_-o_yaml.golden +++ b/pkg/cli/testdata/TestAll/acorn_all_-o_yaml.golden @@ -17,7 +17,7 @@ items: appSpec: {} appStatus: {} columns: {} - resolvedOfferings: {} + defaults: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/deploy.go b/pkg/controller/appdefinition/deploy.go index d9dd1495b..fa2c20270 100644 --- a/pkg/controller/appdefinition/deploy.go +++ b/pkg/controller/appdefinition/deploy.go @@ -597,34 +597,12 @@ func containerAnnotation(container v1.Container) string { return string(json) } -func resolvedOfferingsAnnotation(appInstance *v1.AppInstance, container v1.Container) (string, error) { - if resolved, exists := appInstance.Status.ResolvedOfferings.Containers[container.Name]; exists { - data, err := convert.EncodeToMap(resolved) - if err != nil { - return "", err - } - - j, err := json.Marshal(data) - if err != nil { - return "", err - } - - return string(j), nil - } - return "", nil -} - func podAnnotations(appInstance *v1.AppInstance, container v1.Container) map[string]string { annotations := map[string]string{ labels.AcornContainerSpec: containerAnnotation(container), } addPrometheusAnnotations(annotations, container) - offerings, err := resolvedOfferingsAnnotation(appInstance, container) - if err == nil && offerings != "" { - annotations[labels.AcornContainerResolvedOfferings] = offerings - } - images := map[string]string{} addImageAnnotations(images, appInstance, container) diff --git a/pkg/controller/appdefinition/testdata/TestComputeMem.golden b/pkg/controller/appdefinition/testdata/TestComputeMem.golden index 0d26719a6..9f160e2a5 100644 --- a/pkg/controller/appdefinition/testdata/TestComputeMem.golden +++ b/pkg/controller/appdefinition/testdata/TestComputeMem.golden @@ -116,7 +116,7 @@ status: appSpec: {} appStatus: {} columns: {} - resolvedOfferings: {} + defaults: {} staged: appImage: buildContext: {} @@ -157,7 +157,7 @@ status: appSpec: {} appStatus: {} columns: {} - resolvedOfferings: {} + defaults: {} staged: appImage: buildContext: {} @@ -200,8 +200,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/acorn/basic/expected.golden b/pkg/controller/appdefinition/testdata/acorn/basic/expected.golden index 4d13f27b0..a86ce4724 100644 --- a/pkg/controller/appdefinition/testdata/acorn/basic/expected.golden +++ b/pkg/controller/appdefinition/testdata/acorn/basic/expected.golden @@ -132,7 +132,7 @@ status: appSpec: {} appStatus: {} columns: {} - resolvedOfferings: {} + defaults: {} staged: appImage: buildContext: {} @@ -212,8 +212,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/acorn/labels/expected.golden b/pkg/controller/appdefinition/testdata/acorn/labels/expected.golden index 583250909..94f10fed6 100644 --- a/pkg/controller/appdefinition/testdata/acorn/labels/expected.golden +++ b/pkg/controller/appdefinition/testdata/acorn/labels/expected.golden @@ -150,7 +150,7 @@ status: appSpec: {} appStatus: {} columns: {} - resolvedOfferings: {} + defaults: {} staged: appImage: buildContext: {} @@ -254,8 +254,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/assignnamespace/expected.golden b/pkg/controller/appdefinition/testdata/assignnamespace/expected.golden index 9a356ca61..b101e1c8c 100644 --- a/pkg/controller/appdefinition/testdata/assignnamespace/expected.golden +++ b/pkg/controller/appdefinition/testdata/assignnamespace/expected.golden @@ -19,8 +19,8 @@ status: status: "True" success: true type: namespace + defaults: {} namespace: default-1234567890ab - resolvedOfferings: {} staged: appImage: buildContext: {} @@ -50,8 +50,8 @@ status: status: "True" success: true type: namespace + defaults: {} namespace: default-1234567890ab - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/autoupgrade/with-local-image/expected.golden b/pkg/controller/appdefinition/testdata/autoupgrade/with-local-image/expected.golden index aceec1cbf..518c57d7f 100644 --- a/pkg/controller/appdefinition/testdata/autoupgrade/with-local-image/expected.golden +++ b/pkg/controller/appdefinition/testdata/autoupgrade/with-local-image/expected.golden @@ -21,8 +21,8 @@ status: status: "True" success: true type: image-pull + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/computeclass/all-set-overwrite-computeclass/expected.golden b/pkg/controller/appdefinition/testdata/computeclass/all-set-overwrite-computeclass/expected.golden index 08bd1be57..753f7bcfc 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/all-set-overwrite-computeclass/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/all-set-overwrite-computeclass/expected.golden @@ -55,7 +55,6 @@ spec: template: metadata: annotations: - acorn.io/container-resolved-offerings: '{"memory":0}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"image":"image-name","metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null,"sidecars":{"left":{"image":"foo","metrics":{},"ports":[{"port":90,"protocol":"tcp","targetPort":91}],"probes":null}}}' karpenter.sh/do-not-evict: "true" creationTimestamp: null @@ -225,7 +224,7 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults reason: Success status: "True" success: true @@ -234,16 +233,13 @@ status: status: "True" success: true type: defined + defaults: + memory: + "": 0 + left: 2097152 + oneimage: 2097152 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 2097152 - oneimage: - memory: 2097152 scheduling: left: requirements: diff --git a/pkg/controller/appdefinition/testdata/computeclass/all-set-overwrite-computeclass/input.yaml b/pkg/controller/appdefinition/testdata/computeclass/all-set-overwrite-computeclass/input.yaml index b5ce2e734..4c19157f4 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/all-set-overwrite-computeclass/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/all-set-overwrite-computeclass/input.yaml @@ -36,14 +36,11 @@ status: requests: cpu: 2m memory: 2Mi - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 2097152 # 2Mi - oneimage: - memory: 2097152 # 2Mi + defaults: + memory: + "": 0 + left: 2097152 # 2Mi + oneimage: 2097152 # 2Mi namespace: app-created-namespace appImage: id: test @@ -66,7 +63,7 @@ status: dockerfile: "Dockerfile" context: "." conditions: - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true diff --git a/pkg/controller/appdefinition/testdata/computeclass/all-set/expected.golden b/pkg/controller/appdefinition/testdata/computeclass/all-set/expected.golden index 3ab0d4989..c8439e019 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/all-set/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/all-set/expected.golden @@ -55,7 +55,6 @@ spec: template: metadata: annotations: - acorn.io/container-resolved-offerings: '{"memory":0}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"image":"image-name","metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null,"sidecars":{"left":{"image":"foo","metrics":{},"ports":[{"port":90,"protocol":"tcp","targetPort":91}],"probes":null}}}' karpenter.sh/do-not-evict: "true" creationTimestamp: null @@ -224,7 +223,7 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults reason: Success status: "True" success: true @@ -233,16 +232,13 @@ status: status: "True" success: true type: defined + defaults: + memory: + "": 0 + left: 1048576 + oneimage: 1048576 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: diff --git a/pkg/controller/appdefinition/testdata/computeclass/all-set/input.yaml b/pkg/controller/appdefinition/testdata/computeclass/all-set/input.yaml index 6bf5330a7..44a71471a 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/all-set/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/all-set/input.yaml @@ -35,14 +35,11 @@ status: cpu: 1m memory: 1Mi namespace: app-created-namespace - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 # 1Mi - oneimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 + left: 1048576 # 1Mi + oneimage: 1048576 # 1Mi appImage: id: test appSpec: @@ -64,7 +61,7 @@ status: dockerfile: "Dockerfile" context: "." conditions: - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true diff --git a/pkg/controller/appdefinition/testdata/computeclass/container/expected.golden b/pkg/controller/appdefinition/testdata/computeclass/container/expected.golden index ebbe3bc3e..f22484471 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/container/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/container/expected.golden @@ -55,7 +55,6 @@ spec: template: metadata: annotations: - acorn.io/container-resolved-offerings: '{"memory":0}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"image":"image-name","metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null,"sidecars":{"left":{"image":"foo","metrics":{},"ports":[{"port":90,"protocol":"tcp","targetPort":91}],"probes":null}}}' karpenter.sh/do-not-evict: "true" creationTimestamp: null @@ -224,7 +223,7 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults reason: Success status: "True" success: true @@ -233,16 +232,13 @@ status: status: "True" success: true type: defined + defaults: + memory: + "": 0 + left: 1048576 + oneimage: 1048576 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: diff --git a/pkg/controller/appdefinition/testdata/computeclass/container/input.yaml b/pkg/controller/appdefinition/testdata/computeclass/container/input.yaml index 6d55f8c75..e6f0f9a4b 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/container/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/container/input.yaml @@ -35,14 +35,11 @@ status: cpu: 1m memory: 1Mi namespace: app-created-namespace - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 # 1Mi - oneimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 + left: 1048576 # 1Mi + oneimage: 1048576 # 1Mi appImage: id: test appSpec: @@ -64,7 +61,7 @@ status: dockerfile: "Dockerfile" context: "." conditions: - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true diff --git a/pkg/controller/appdefinition/testdata/computeclass/different-computeclass/expected.golden b/pkg/controller/appdefinition/testdata/computeclass/different-computeclass/expected.golden index a9cb45cb4..ab86edaf4 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/different-computeclass/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/different-computeclass/expected.golden @@ -69,7 +69,6 @@ spec: template: metadata: annotations: - acorn.io/container-resolved-offerings: '{"memory":0}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"image":"image-name","metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null}' karpenter.sh/do-not-evict: "true" creationTimestamp: null @@ -187,7 +186,6 @@ spec: template: metadata: annotations: - acorn.io/container-resolved-offerings: '{"memory":0}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"image":"image-name","metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null}' karpenter.sh/do-not-evict: "true" creationTimestamp: null @@ -374,7 +372,7 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults reason: Success status: "True" success: true @@ -383,16 +381,13 @@ status: status: "True" success: true type: defined + defaults: + memory: + "": 0 + oneimage: 2097152 + twoimage: 1048576 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - oneimage: - memory: 2097152 - twoimage: - memory: 1048576 scheduling: oneimage: affinity: diff --git a/pkg/controller/appdefinition/testdata/computeclass/different-computeclass/input.yaml b/pkg/controller/appdefinition/testdata/computeclass/different-computeclass/input.yaml index 30b47c5e8..988d8cff3 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/different-computeclass/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/different-computeclass/input.yaml @@ -44,14 +44,11 @@ status: requests: cpu: 1m memory: 1Mi - resolvedOfferings: - containers: - "": - memory: 0 - oneimage: - memory: 2097152 # 2Mi - twoimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 + oneimage: 2097152 # 2Mi + twoimage: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test @@ -76,7 +73,7 @@ status: dockerfile: "Dockerfile" context: "." conditions: - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true diff --git a/pkg/controller/appdefinition/testdata/computeclass/job/expected.golden b/pkg/controller/appdefinition/testdata/computeclass/job/expected.golden index 8edc9de67..d55c1e3ef 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/job/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/job/expected.golden @@ -54,7 +54,6 @@ spec: metadata: annotations: acorn.io/config-hash: "" - acorn.io/container-resolved-offerings: '{"memory":0}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"image":"image-name","metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null,"sidecars":{"left":{"image":"foo","metrics":{},"ports":[{"port":90,"protocol":"tcp","targetPort":91}],"probes":null}}}' creationTimestamp: null labels: @@ -223,7 +222,7 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults reason: Success status: "True" success: true @@ -232,16 +231,13 @@ status: status: "True" success: true type: defined + defaults: + memory: + "": 0 + left: 1048576 + oneimage: 1048576 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: diff --git a/pkg/controller/appdefinition/testdata/computeclass/job/input.yaml b/pkg/controller/appdefinition/testdata/computeclass/job/input.yaml index d2af853a8..8cc04fd1a 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/job/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/job/input.yaml @@ -35,14 +35,11 @@ status: cpu: 1m memory: 1Mi namespace: app-created-namespace - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 # 1Mi - oneimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 + left: 1048576 # 1Mi + oneimage: 1048576 # 1Mi appImage: id: test appSpec: @@ -64,7 +61,7 @@ status: dockerfile: "Dockerfile" context: "." conditions: - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true diff --git a/pkg/controller/appdefinition/testdata/computeclass/overwrite-acornfile-computeclass/expected.golden b/pkg/controller/appdefinition/testdata/computeclass/overwrite-acornfile-computeclass/expected.golden index 8e2f55105..3d86319f1 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/overwrite-acornfile-computeclass/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/overwrite-acornfile-computeclass/expected.golden @@ -55,7 +55,6 @@ spec: template: metadata: annotations: - acorn.io/container-resolved-offerings: '{"memory":0}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"class":"sample-compute-class-01","image":"image-name","metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null,"sidecars":{"left":{"image":"foo","metrics":{},"ports":[{"port":90,"protocol":"tcp","targetPort":91}],"probes":null}}}' karpenter.sh/do-not-evict: "true" creationTimestamp: null @@ -225,7 +224,7 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults reason: Success status: "True" success: true @@ -234,16 +233,13 @@ status: status: "True" success: true type: defined + defaults: + memory: + "": 0 + left: 1048576 + oneimage: 1048576 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: diff --git a/pkg/controller/appdefinition/testdata/computeclass/overwrite-acornfile-computeclass/input.yaml b/pkg/controller/appdefinition/testdata/computeclass/overwrite-acornfile-computeclass/input.yaml index 92ba08394..b8c256e35 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/overwrite-acornfile-computeclass/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/overwrite-acornfile-computeclass/input.yaml @@ -34,14 +34,11 @@ status: requests: cpu: 1m memory: 1Mi - resolvedOfferings: - containers: - "": - memory: 0 # 1Mi - left: - memory: 1048576 # 1Mi - oneimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 # 1Mi + left: 1048576 # 1Mi + oneimage: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test @@ -65,7 +62,7 @@ status: context: "." class: sample-compute-class-01 conditions: - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true diff --git a/pkg/controller/appdefinition/testdata/computeclass/sidecar/expected.yaml.d/appinstance.yaml b/pkg/controller/appdefinition/testdata/computeclass/sidecar/expected.yaml.d/appinstance.yaml index 2f0fc0b93..24247810e 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/sidecar/expected.yaml.d/appinstance.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/sidecar/expected.yaml.d/appinstance.yaml @@ -9,10 +9,9 @@ spec: computeClass: left: sample-compute-class status: - resolvedOfferings: - containers: - left: - memory: 1048576 # 1Mi + defaults: + memory: + left: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test @@ -35,7 +34,7 @@ status: dockerfile: "Dockerfile" context: "." conditions: - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true diff --git a/pkg/controller/appdefinition/testdata/computeclass/sidecar/input.yaml b/pkg/controller/appdefinition/testdata/computeclass/sidecar/input.yaml index 484e175aa..b0735abee 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/sidecar/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/sidecar/input.yaml @@ -9,10 +9,9 @@ spec: computeClass: left: sample-compute-class status: - resolvedOfferings: - containers: - left: - memory: 1048576 # 1Mi + defaults: + memory: + left: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test @@ -35,7 +34,7 @@ status: dockerfile: "Dockerfile" context: "." conditions: - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true diff --git a/pkg/controller/appdefinition/testdata/computeclass/two-containers/expected.golden b/pkg/controller/appdefinition/testdata/computeclass/two-containers/expected.golden index 1e40639fc..fbe43e572 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/two-containers/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/two-containers/expected.golden @@ -69,7 +69,6 @@ spec: template: metadata: annotations: - acorn.io/container-resolved-offerings: '{"memory":0}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"image":"image-name","metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null}' karpenter.sh/do-not-evict: "true" creationTimestamp: null @@ -187,7 +186,6 @@ spec: template: metadata: annotations: - acorn.io/container-resolved-offerings: '{"memory":0}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"image":"image-name","metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null}' karpenter.sh/do-not-evict: "true" creationTimestamp: null @@ -359,7 +357,7 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults reason: Success status: "True" success: true @@ -368,16 +366,13 @@ status: status: "True" success: true type: defined + defaults: + memory: + "": 0 + oneimage: 1048576 + twoimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - oneimage: - memory: 1048576 - twoimage: - memory: 0 scheduling: oneimage: affinity: diff --git a/pkg/controller/appdefinition/testdata/computeclass/two-containers/input.yaml b/pkg/controller/appdefinition/testdata/computeclass/two-containers/input.yaml index 4a93fcd3c..88d33e222 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/two-containers/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/two-containers/input.yaml @@ -29,14 +29,11 @@ status: memory: 1Mi twoimage: requirements: {} - resolvedOfferings: - containers: - "": - memory: 0 - oneimage: - memory: 1048576 # 1Mi - twoimage: - memory: 0 + defaults: + memory: + "": 0 + oneimage: 1048576 # 1Mi + twoimage: 0 namespace: app-created-namespace appImage: id: test @@ -61,7 +58,7 @@ status: dockerfile: "Dockerfile" context: "." conditions: - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true diff --git a/pkg/controller/appdefinition/testdata/computeclass/with-acornfile-computeclass/expected.golden b/pkg/controller/appdefinition/testdata/computeclass/with-acornfile-computeclass/expected.golden index 293cb72f1..51ed2acd7 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/with-acornfile-computeclass/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/with-acornfile-computeclass/expected.golden @@ -55,7 +55,6 @@ spec: template: metadata: annotations: - acorn.io/container-resolved-offerings: '{"memory":0}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"class":"sample-compute-class","image":"image-name","metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null,"sidecars":{"left":{"image":"foo","metrics":{},"ports":[{"port":90,"protocol":"tcp","targetPort":91}],"probes":null}}}' karpenter.sh/do-not-evict: "true" creationTimestamp: null @@ -223,7 +222,7 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults reason: Success status: "True" success: true @@ -232,16 +231,13 @@ status: status: "True" success: true type: defined + defaults: + memory: + "": 0 + left: 1048576 + oneimage: 1048576 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: diff --git a/pkg/controller/appdefinition/testdata/computeclass/with-acornfile-computeclass/input.yaml b/pkg/controller/appdefinition/testdata/computeclass/with-acornfile-computeclass/input.yaml index 519aa0bc5..eb2a79f02 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/with-acornfile-computeclass/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/with-acornfile-computeclass/input.yaml @@ -32,14 +32,11 @@ status: requests: cpu: 1m memory: 1Mi - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 # 1Mi - oneimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 # 1Mi + left: 1048576 # 1Mi + oneimage: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test @@ -63,7 +60,7 @@ status: context: "." class: sample-compute-class conditions: - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true diff --git a/pkg/controller/appdefinition/testdata/depends-ready/expected.golden b/pkg/controller/appdefinition/testdata/depends-ready/expected.golden index 46ef557e5..2f1522d5f 100644 --- a/pkg/controller/appdefinition/testdata/depends-ready/expected.golden +++ b/pkg/controller/appdefinition/testdata/depends-ready/expected.golden @@ -305,8 +305,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/depends/expected.golden b/pkg/controller/appdefinition/testdata/depends/expected.golden index a561abed7..196da524b 100644 --- a/pkg/controller/appdefinition/testdata/depends/expected.golden +++ b/pkg/controller/appdefinition/testdata/depends/expected.golden @@ -309,8 +309,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/deployspec/basic/expected.golden b/pkg/controller/appdefinition/testdata/deployspec/basic/expected.golden index cee64d11c..a028b5f70 100644 --- a/pkg/controller/appdefinition/testdata/deployspec/basic/expected.golden +++ b/pkg/controller/appdefinition/testdata/deployspec/basic/expected.golden @@ -321,8 +321,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/deployspec/filter-user-labels/expected.golden b/pkg/controller/appdefinition/testdata/deployspec/filter-user-labels/expected.golden index 174b24878..00b17fa2e 100644 --- a/pkg/controller/appdefinition/testdata/deployspec/filter-user-labels/expected.golden +++ b/pkg/controller/appdefinition/testdata/deployspec/filter-user-labels/expected.golden @@ -456,8 +456,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/deployspec/karpenter/expected.golden b/pkg/controller/appdefinition/testdata/deployspec/karpenter/expected.golden index 24f1a0d48..14b2a2576 100644 --- a/pkg/controller/appdefinition/testdata/deployspec/karpenter/expected.golden +++ b/pkg/controller/appdefinition/testdata/deployspec/karpenter/expected.golden @@ -378,8 +378,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/deployspec/labels/expected.golden b/pkg/controller/appdefinition/testdata/deployspec/labels/expected.golden index 0332365f0..433591b2a 100644 --- a/pkg/controller/appdefinition/testdata/deployspec/labels/expected.golden +++ b/pkg/controller/appdefinition/testdata/deployspec/labels/expected.golden @@ -462,8 +462,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/deployspec/metrics/expected.golden b/pkg/controller/appdefinition/testdata/deployspec/metrics/expected.golden index f9e9eb7df..0c9f1513d 100644 --- a/pkg/controller/appdefinition/testdata/deployspec/metrics/expected.golden +++ b/pkg/controller/appdefinition/testdata/deployspec/metrics/expected.golden @@ -183,8 +183,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/deployspec/no-user-labels/expected.golden b/pkg/controller/appdefinition/testdata/deployspec/no-user-labels/expected.golden index 500829302..c8f2931de 100644 --- a/pkg/controller/appdefinition/testdata/deployspec/no-user-labels/expected.golden +++ b/pkg/controller/appdefinition/testdata/deployspec/no-user-labels/expected.golden @@ -329,8 +329,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/deployspec/pre-stop/basic/expected.golden b/pkg/controller/appdefinition/testdata/deployspec/pre-stop/basic/expected.golden index 9b482facb..5580aa20a 100644 --- a/pkg/controller/appdefinition/testdata/deployspec/pre-stop/basic/expected.golden +++ b/pkg/controller/appdefinition/testdata/deployspec/pre-stop/basic/expected.golden @@ -354,8 +354,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/deployspec/pre-stop/dev/expected.golden b/pkg/controller/appdefinition/testdata/deployspec/pre-stop/dev/expected.golden index d97fe8d75..48fcbbf4b 100644 --- a/pkg/controller/appdefinition/testdata/deployspec/pre-stop/dev/expected.golden +++ b/pkg/controller/appdefinition/testdata/deployspec/pre-stop/dev/expected.golden @@ -321,6 +321,7 @@ status: status: "True" success: true type: defined + defaults: {} devSession: client: imageSource: {} @@ -328,7 +329,6 @@ status: sessionStartTime: null sessionTimeoutSeconds: 60 namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/deployspec/pre-stop/job/expected.golden b/pkg/controller/appdefinition/testdata/deployspec/pre-stop/job/expected.golden index 7eafe3890..2bff587a0 100644 --- a/pkg/controller/appdefinition/testdata/deployspec/pre-stop/job/expected.golden +++ b/pkg/controller/appdefinition/testdata/deployspec/pre-stop/job/expected.golden @@ -202,8 +202,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/deployspec/pre-stop/no-ports/expected.golden b/pkg/controller/appdefinition/testdata/deployspec/pre-stop/no-ports/expected.golden index 57ccc4d56..7313fda09 100644 --- a/pkg/controller/appdefinition/testdata/deployspec/pre-stop/no-ports/expected.golden +++ b/pkg/controller/appdefinition/testdata/deployspec/pre-stop/no-ports/expected.golden @@ -266,8 +266,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/deployspec/pre-stop/ports-only-sidecar/expected.golden b/pkg/controller/appdefinition/testdata/deployspec/pre-stop/ports-only-sidecar/expected.golden index b974fa03c..73f601540 100644 --- a/pkg/controller/appdefinition/testdata/deployspec/pre-stop/ports-only-sidecar/expected.golden +++ b/pkg/controller/appdefinition/testdata/deployspec/pre-stop/ports-only-sidecar/expected.golden @@ -333,8 +333,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/deployspec/pre-stop/stateful/expected.golden b/pkg/controller/appdefinition/testdata/deployspec/pre-stop/stateful/expected.golden index 664dea179..76b530280 100644 --- a/pkg/controller/appdefinition/testdata/deployspec/pre-stop/stateful/expected.golden +++ b/pkg/controller/appdefinition/testdata/deployspec/pre-stop/stateful/expected.golden @@ -219,14 +219,14 @@ status: status: "True" success: true type: defined - namespace: app-created-namespace - resolvedOfferings: + defaults: volumes: foo: accessModes: - readWriteOnce class: test-custom-class size: 3Gi + namespace: app-created-namespace staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/deployspec/pre-stop/stateful/input.yaml b/pkg/controller/appdefinition/testdata/deployspec/pre-stop/stateful/input.yaml index 5a3d79e32..3138c7dfc 100644 --- a/pkg/controller/appdefinition/testdata/deployspec/pre-stop/stateful/input.yaml +++ b/pkg/controller/appdefinition/testdata/deployspec/pre-stop/stateful/input.yaml @@ -23,7 +23,7 @@ status: protocol: http volumes: foo: {} - resolvedOfferings: + defaults: volumes: foo: class: test-custom-class diff --git a/pkg/controller/appdefinition/testdata/deployspec/scale/expected.golden b/pkg/controller/appdefinition/testdata/deployspec/scale/expected.golden index 8da340724..fdbd5ffb5 100644 --- a/pkg/controller/appdefinition/testdata/deployspec/scale/expected.golden +++ b/pkg/controller/appdefinition/testdata/deployspec/scale/expected.golden @@ -258,8 +258,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/deployspec/stop/expected.golden b/pkg/controller/appdefinition/testdata/deployspec/stop/expected.golden index e6c4ce2d7..1d48b868a 100644 --- a/pkg/controller/appdefinition/testdata/deployspec/stop/expected.golden +++ b/pkg/controller/appdefinition/testdata/deployspec/stop/expected.golden @@ -259,8 +259,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/files-bug/expected.golden b/pkg/controller/appdefinition/testdata/files-bug/expected.golden index f47299fa0..afc121717 100644 --- a/pkg/controller/appdefinition/testdata/files-bug/expected.golden +++ b/pkg/controller/appdefinition/testdata/files-bug/expected.golden @@ -184,8 +184,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/files/expected.golden b/pkg/controller/appdefinition/testdata/files/expected.golden index 0e9cadc5f..d43240798 100644 --- a/pkg/controller/appdefinition/testdata/files/expected.golden +++ b/pkg/controller/appdefinition/testdata/files/expected.golden @@ -216,8 +216,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/globalenv/expected.golden b/pkg/controller/appdefinition/testdata/globalenv/expected.golden index 449887ff5..ac5d939ed 100644 --- a/pkg/controller/appdefinition/testdata/globalenv/expected.golden +++ b/pkg/controller/appdefinition/testdata/globalenv/expected.golden @@ -189,7 +189,7 @@ status: appSpec: {} appStatus: {} columns: {} - resolvedOfferings: {} + defaults: {} staged: appImage: buildContext: {} @@ -239,8 +239,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/ingress/basic/expected.golden b/pkg/controller/appdefinition/testdata/ingress/basic/expected.golden index 06b946244..d337c144e 100644 --- a/pkg/controller/appdefinition/testdata/ingress/basic/expected.golden +++ b/pkg/controller/appdefinition/testdata/ingress/basic/expected.golden @@ -391,8 +391,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/ingress/clusterdomainport/expected.golden b/pkg/controller/appdefinition/testdata/ingress/clusterdomainport/expected.golden index e17cae1d4..c32622804 100644 --- a/pkg/controller/appdefinition/testdata/ingress/clusterdomainport/expected.golden +++ b/pkg/controller/appdefinition/testdata/ingress/clusterdomainport/expected.golden @@ -184,8 +184,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/ingress/labels/expected.golden b/pkg/controller/appdefinition/testdata/ingress/labels/expected.golden index 109d7ca49..b20bb6058 100644 --- a/pkg/controller/appdefinition/testdata/ingress/labels/expected.golden +++ b/pkg/controller/appdefinition/testdata/ingress/labels/expected.golden @@ -260,8 +260,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/ingress/letsencrypt/expected.golden b/pkg/controller/appdefinition/testdata/ingress/letsencrypt/expected.golden index 3085a9e96..0a1b5ff82 100644 --- a/pkg/controller/appdefinition/testdata/ingress/letsencrypt/expected.golden +++ b/pkg/controller/appdefinition/testdata/ingress/letsencrypt/expected.golden @@ -353,8 +353,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/ingress/prefix/prefix-1/expected.golden b/pkg/controller/appdefinition/testdata/ingress/prefix/prefix-1/expected.golden index 160b5a604..5adec7492 100644 --- a/pkg/controller/appdefinition/testdata/ingress/prefix/prefix-1/expected.golden +++ b/pkg/controller/appdefinition/testdata/ingress/prefix/prefix-1/expected.golden @@ -262,8 +262,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/ingress/prefix/prefix-2/expected.golden b/pkg/controller/appdefinition/testdata/ingress/prefix/prefix-2/expected.golden index db48c9a91..f9029bea9 100644 --- a/pkg/controller/appdefinition/testdata/ingress/prefix/prefix-2/expected.golden +++ b/pkg/controller/appdefinition/testdata/ingress/prefix/prefix-2/expected.golden @@ -262,8 +262,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/interpolation/expected.golden b/pkg/controller/appdefinition/testdata/interpolation/expected.golden index 2d16b34ba..69b515efd 100644 --- a/pkg/controller/appdefinition/testdata/interpolation/expected.golden +++ b/pkg/controller/appdefinition/testdata/interpolation/expected.golden @@ -182,8 +182,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/job/basic/expected.golden b/pkg/controller/appdefinition/testdata/job/basic/expected.golden index 7eafe3890..2bff587a0 100644 --- a/pkg/controller/appdefinition/testdata/job/basic/expected.golden +++ b/pkg/controller/appdefinition/testdata/job/basic/expected.golden @@ -202,8 +202,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/job/event-jobs-create-app/expected.golden b/pkg/controller/appdefinition/testdata/job/event-jobs-create-app/expected.golden index 9ce390c5b..87c677958 100644 --- a/pkg/controller/appdefinition/testdata/job/event-jobs-create-app/expected.golden +++ b/pkg/controller/appdefinition/testdata/job/event-jobs-create-app/expected.golden @@ -159,8 +159,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/job/event-jobs-delete-app/expected.golden b/pkg/controller/appdefinition/testdata/job/event-jobs-delete-app/expected.golden index b8c08bd10..fa87005d9 100644 --- a/pkg/controller/appdefinition/testdata/job/event-jobs-delete-app/expected.golden +++ b/pkg/controller/appdefinition/testdata/job/event-jobs-delete-app/expected.golden @@ -161,8 +161,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/job/event-jobs-start-app/expected.golden b/pkg/controller/appdefinition/testdata/job/event-jobs-start-app/expected.golden index 04a5d930d..ab44576db 100644 --- a/pkg/controller/appdefinition/testdata/job/event-jobs-start-app/expected.golden +++ b/pkg/controller/appdefinition/testdata/job/event-jobs-start-app/expected.golden @@ -160,8 +160,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/job/event-jobs-stop-app/expected.golden b/pkg/controller/appdefinition/testdata/job/event-jobs-stop-app/expected.golden index 289436a4e..6c530fcc2 100644 --- a/pkg/controller/appdefinition/testdata/job/event-jobs-stop-app/expected.golden +++ b/pkg/controller/appdefinition/testdata/job/event-jobs-stop-app/expected.golden @@ -160,8 +160,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/job/event-jobs-update-app-with-create/expected.golden b/pkg/controller/appdefinition/testdata/job/event-jobs-update-app-with-create/expected.golden index d764fc47a..c8b39e86c 100644 --- a/pkg/controller/appdefinition/testdata/job/event-jobs-update-app-with-create/expected.golden +++ b/pkg/controller/appdefinition/testdata/job/event-jobs-update-app-with-create/expected.golden @@ -261,8 +261,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/job/event-jobs-update-app/expected.golden b/pkg/controller/appdefinition/testdata/job/event-jobs-update-app/expected.golden index e0348e8ea..7097cc0f5 100644 --- a/pkg/controller/appdefinition/testdata/job/event-jobs-update-app/expected.golden +++ b/pkg/controller/appdefinition/testdata/job/event-jobs-update-app/expected.golden @@ -160,8 +160,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/job/event-jobs-update-create-job/expected.golden b/pkg/controller/appdefinition/testdata/job/event-jobs-update-create-job/expected.golden index 64639593e..72f9ed126 100644 --- a/pkg/controller/appdefinition/testdata/job/event-jobs-update-create-job/expected.golden +++ b/pkg/controller/appdefinition/testdata/job/event-jobs-update-create-job/expected.golden @@ -137,8 +137,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/job/event-jobs-update-generation-one/expected.golden b/pkg/controller/appdefinition/testdata/job/event-jobs-update-generation-one/expected.golden index 318820f66..7c53a953e 100644 --- a/pkg/controller/appdefinition/testdata/job/event-jobs-update-generation-one/expected.golden +++ b/pkg/controller/appdefinition/testdata/job/event-jobs-update-generation-one/expected.golden @@ -58,8 +58,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/job/labels/expected.golden b/pkg/controller/appdefinition/testdata/job/labels/expected.golden index a9188e648..042d05c80 100644 --- a/pkg/controller/appdefinition/testdata/job/labels/expected.golden +++ b/pkg/controller/appdefinition/testdata/job/labels/expected.golden @@ -263,8 +263,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/link/expected.golden b/pkg/controller/appdefinition/testdata/link/expected.golden index b050a2435..1438c99a6 100644 --- a/pkg/controller/appdefinition/testdata/link/expected.golden +++ b/pkg/controller/appdefinition/testdata/link/expected.golden @@ -57,8 +57,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/memory/all-set-overwrite/expected.golden b/pkg/controller/appdefinition/testdata/memory/all-set-overwrite/expected.golden index f02687a07..49d97c1ff 100644 --- a/pkg/controller/appdefinition/testdata/memory/all-set-overwrite/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/all-set-overwrite/expected.golden @@ -55,7 +55,6 @@ spec: template: metadata: annotations: - acorn.io/container-resolved-offerings: '{"memory":1048576}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"image":"image-name","metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null,"sidecars":{"left":{"image":"foo","metrics":{},"ports":[{"port":90,"protocol":"tcp","targetPort":91}],"probes":null}}}' karpenter.sh/do-not-evict: "true" creationTimestamp: null @@ -218,21 +217,18 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults reason: Success status: "True" success: true type: defined + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 1048576 - left: - memory: 2097152 - oneimage: - memory: 2097152 scheduling: left: requirements: diff --git a/pkg/controller/appdefinition/testdata/memory/all-set-overwrite/input.yaml b/pkg/controller/appdefinition/testdata/memory/all-set-overwrite/input.yaml index f3a43f53d..06b83139c 100644 --- a/pkg/controller/appdefinition/testdata/memory/all-set-overwrite/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/all-set-overwrite/input.yaml @@ -8,17 +8,14 @@ spec: image: test memory: "": 1048576 # 1Mi - oneimage: 2097152 # 2Mi + oneimage: 2097152 # 2Mi status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 1048576 - left: - memory: 2097152 - oneimage: - memory: 2097152 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 scheduling: oneimage: requirements: @@ -58,7 +55,7 @@ status: reason: Success status: "True" success: true - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true diff --git a/pkg/controller/appdefinition/testdata/memory/all-set/expected.golden b/pkg/controller/appdefinition/testdata/memory/all-set/expected.golden index 2a9a3117c..3061aede9 100644 --- a/pkg/controller/appdefinition/testdata/memory/all-set/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/all-set/expected.golden @@ -55,7 +55,6 @@ spec: template: metadata: annotations: - acorn.io/container-resolved-offerings: '{"memory":1048576}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"image":"image-name","metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null,"sidecars":{"left":{"image":"foo","metrics":{},"ports":[{"port":90,"protocol":"tcp","targetPort":91}],"probes":null}}}' karpenter.sh/do-not-evict: "true" creationTimestamp: null @@ -217,21 +216,18 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults reason: Success status: "True" success: true type: defined + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 1048576 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: diff --git a/pkg/controller/appdefinition/testdata/memory/all-set/input.yaml b/pkg/controller/appdefinition/testdata/memory/all-set/input.yaml index 35b6232cf..04304d372 100644 --- a/pkg/controller/appdefinition/testdata/memory/all-set/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/all-set/input.yaml @@ -10,14 +10,11 @@ spec: "": 1048576 # 1Mi status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 1048576 - left: - memory: 1048576 - oneimage: - memory: 1048576 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 scheduling: oneimage: requirements: @@ -57,7 +54,7 @@ status: reason: Success status: "True" success: true - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true diff --git a/pkg/controller/appdefinition/testdata/memory/container/expected.golden b/pkg/controller/appdefinition/testdata/memory/container/expected.golden index 1ddbaf6b4..c45e9957d 100644 --- a/pkg/controller/appdefinition/testdata/memory/container/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/container/expected.golden @@ -55,7 +55,6 @@ spec: template: metadata: annotations: - acorn.io/container-resolved-offerings: '{"memory":0}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"image":"image-name","metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null,"sidecars":{"left":{"image":"foo","metrics":{},"ports":[{"port":90,"protocol":"tcp","targetPort":91}],"probes":null}}}' karpenter.sh/do-not-evict: "true" creationTimestamp: null @@ -213,21 +212,18 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults reason: Success status: "True" success: true type: defined + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: {} diff --git a/pkg/controller/appdefinition/testdata/memory/container/input.yaml b/pkg/controller/appdefinition/testdata/memory/container/input.yaml index 98ec2d2f4..b460aafb5 100644 --- a/pkg/controller/appdefinition/testdata/memory/container/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/container/input.yaml @@ -10,14 +10,11 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 scheduling: oneimage: requirements: @@ -53,7 +50,7 @@ status: reason: Success status: "True" success: true - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true diff --git a/pkg/controller/appdefinition/testdata/memory/job/expected.golden b/pkg/controller/appdefinition/testdata/memory/job/expected.golden index 868e57bbc..e277de6ee 100644 --- a/pkg/controller/appdefinition/testdata/memory/job/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/job/expected.golden @@ -54,7 +54,6 @@ spec: metadata: annotations: acorn.io/config-hash: "" - acorn.io/container-resolved-offerings: '{"memory":0}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"image":"image-name","metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null,"sidecars":{"left":{"image":"foo","metrics":{},"ports":[{"port":90,"protocol":"tcp","targetPort":91}],"probes":null}}}' creationTimestamp: null labels: @@ -212,21 +211,18 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults reason: Success status: "True" success: true type: defined + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: {} diff --git a/pkg/controller/appdefinition/testdata/memory/job/input.yaml b/pkg/controller/appdefinition/testdata/memory/job/input.yaml index aca5df3ea..54754e7ae 100644 --- a/pkg/controller/appdefinition/testdata/memory/job/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/job/input.yaml @@ -10,14 +10,11 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 scheduling: oneimage: requirements: @@ -53,7 +50,7 @@ status: reason: Success status: "True" success: true - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true diff --git a/pkg/controller/appdefinition/testdata/memory/overwrite-acornfile-memory/expected.golden b/pkg/controller/appdefinition/testdata/memory/overwrite-acornfile-memory/expected.golden index 66859076e..f0209f8e7 100644 --- a/pkg/controller/appdefinition/testdata/memory/overwrite-acornfile-memory/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/overwrite-acornfile-memory/expected.golden @@ -55,7 +55,6 @@ spec: template: metadata: annotations: - acorn.io/container-resolved-offerings: '{"memory":0}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"image":"image-name","memory":2097152,"metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null,"sidecars":{"left":{"image":"foo","metrics":{},"ports":[{"port":90,"protocol":"tcp","targetPort":91}],"probes":null}}}' karpenter.sh/do-not-evict: "true" creationTimestamp: null @@ -214,21 +213,18 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults reason: Success status: "True" success: true type: defined + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: {} diff --git a/pkg/controller/appdefinition/testdata/memory/overwrite-acornfile-memory/input.yaml b/pkg/controller/appdefinition/testdata/memory/overwrite-acornfile-memory/input.yaml index dc7795ff9..c24384faa 100644 --- a/pkg/controller/appdefinition/testdata/memory/overwrite-acornfile-memory/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/overwrite-acornfile-memory/input.yaml @@ -10,14 +10,11 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 scheduling: oneimage: requirements: @@ -54,7 +51,7 @@ status: reason: Success status: "True" success: true - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true \ No newline at end of file diff --git a/pkg/controller/appdefinition/testdata/memory/sidecar/expected.golden b/pkg/controller/appdefinition/testdata/memory/sidecar/expected.golden index 92ab40fe8..809eda4e5 100644 --- a/pkg/controller/appdefinition/testdata/memory/sidecar/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/sidecar/expected.golden @@ -55,7 +55,6 @@ spec: template: metadata: annotations: - acorn.io/container-resolved-offerings: '{"memory":0}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"image":"image-name","metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null,"sidecars":{"left":{"image":"foo","metrics":{},"ports":[{"port":90,"protocol":"tcp","targetPort":91}],"probes":null}}}' karpenter.sh/do-not-evict: "true" creationTimestamp: null @@ -213,21 +212,18 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults reason: Success status: "True" success: true type: defined + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: diff --git a/pkg/controller/appdefinition/testdata/memory/sidecar/input.yaml b/pkg/controller/appdefinition/testdata/memory/sidecar/input.yaml index 108eef008..5cd0d67f5 100644 --- a/pkg/controller/appdefinition/testdata/memory/sidecar/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/sidecar/input.yaml @@ -10,14 +10,11 @@ spec: left: 1048576 # 1Mi status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 scheduling: left: requirements: @@ -53,7 +50,7 @@ status: reason: Success status: "True" success: true - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true \ No newline at end of file diff --git a/pkg/controller/appdefinition/testdata/memory/two-containers/expected.golden b/pkg/controller/appdefinition/testdata/memory/two-containers/expected.golden index 6815838d8..8e77fabaf 100644 --- a/pkg/controller/appdefinition/testdata/memory/two-containers/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/two-containers/expected.golden @@ -69,7 +69,6 @@ spec: template: metadata: annotations: - acorn.io/container-resolved-offerings: '{"memory":0}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"image":"image-name","metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null}' karpenter.sh/do-not-evict: "true" creationTimestamp: null @@ -177,7 +176,6 @@ spec: template: metadata: annotations: - acorn.io/container-resolved-offerings: '{"memory":0}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"image":"image-name","metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null}' karpenter.sh/do-not-evict: "true" creationTimestamp: null @@ -353,21 +351,18 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults reason: Success status: "True" success: true type: defined + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: oneimage: requirements: diff --git a/pkg/controller/appdefinition/testdata/memory/two-containers/input.yaml b/pkg/controller/appdefinition/testdata/memory/two-containers/input.yaml index ebd84d84b..e8bb0a5d0 100644 --- a/pkg/controller/appdefinition/testdata/memory/two-containers/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/two-containers/input.yaml @@ -10,14 +10,11 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 scheduling: oneimage: requirements: @@ -55,7 +52,7 @@ status: reason: Success status: "True" success: true - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true \ No newline at end of file diff --git a/pkg/controller/appdefinition/testdata/memory/with-acornfile-memory/expected.golden b/pkg/controller/appdefinition/testdata/memory/with-acornfile-memory/expected.golden index 813803baf..81b34f14d 100644 --- a/pkg/controller/appdefinition/testdata/memory/with-acornfile-memory/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/with-acornfile-memory/expected.golden @@ -55,7 +55,6 @@ spec: template: metadata: annotations: - acorn.io/container-resolved-offerings: '{"memory":0}' acorn.io/container-spec: '{"build":{"context":".","dockerfile":"Dockerfile"},"image":"image-name","memory":1048576,"metrics":{},"ports":[{"port":80,"protocol":"http","targetPort":81}],"probes":null,"sidecars":{"left":{"image":"foo","metrics":{},"ports":[{"port":90,"protocol":"tcp","targetPort":91}],"probes":null}}}' karpenter.sh/do-not-evict: "true" creationTimestamp: null @@ -212,21 +211,18 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults reason: Success status: "True" success: true type: defined + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: {} diff --git a/pkg/controller/appdefinition/testdata/memory/with-acornfile-memory/input.yaml b/pkg/controller/appdefinition/testdata/memory/with-acornfile-memory/input.yaml index a70ef9c68..7c9be6ae2 100644 --- a/pkg/controller/appdefinition/testdata/memory/with-acornfile-memory/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/with-acornfile-memory/input.yaml @@ -8,14 +8,11 @@ spec: image: test status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 scheduling: oneimage: requirements: @@ -52,7 +49,7 @@ status: reason: Success status: "True" success: true - - type: resolved-offerings + - type: defaults reason: Success status: "True" success: true \ No newline at end of file diff --git a/pkg/controller/appdefinition/testdata/parseappimage/expected.golden b/pkg/controller/appdefinition/testdata/parseappimage/expected.golden index 50ac38954..a79beef26 100644 --- a/pkg/controller/appdefinition/testdata/parseappimage/expected.golden +++ b/pkg/controller/appdefinition/testdata/parseappimage/expected.golden @@ -51,7 +51,7 @@ status: status: "True" success: true type: parsed - resolvedOfferings: {} + defaults: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/parsedevmode/expected.golden b/pkg/controller/appdefinition/testdata/parsedevmode/expected.golden index 0b4d6ed00..96e7c3d53 100644 --- a/pkg/controller/appdefinition/testdata/parsedevmode/expected.golden +++ b/pkg/controller/appdefinition/testdata/parsedevmode/expected.golden @@ -38,12 +38,12 @@ status: status: "True" success: true type: parsed + defaults: {} devSession: client: imageSource: {} sessionRenewTime: null sessionStartTime: null - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/permissions/both/expected.golden b/pkg/controller/appdefinition/testdata/permissions/both/expected.golden index 2d2be71de..b88ec07ab 100644 --- a/pkg/controller/appdefinition/testdata/permissions/both/expected.golden +++ b/pkg/controller/appdefinition/testdata/permissions/both/expected.golden @@ -615,6 +615,7 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace permissions: - rules: @@ -649,7 +650,6 @@ status: verbs: - patch serviceName: twoimage - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/permissions/bothwithnopermissions/expected.golden b/pkg/controller/appdefinition/testdata/permissions/bothwithnopermissions/expected.golden index b39179aa4..da8ee9cc1 100644 --- a/pkg/controller/appdefinition/testdata/permissions/bothwithnopermissions/expected.golden +++ b/pkg/controller/appdefinition/testdata/permissions/bothwithnopermissions/expected.golden @@ -384,8 +384,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/permissions/container/expected.golden b/pkg/controller/appdefinition/testdata/permissions/container/expected.golden index b5978ceec..933fda07e 100644 --- a/pkg/controller/appdefinition/testdata/permissions/container/expected.golden +++ b/pkg/controller/appdefinition/testdata/permissions/container/expected.golden @@ -317,6 +317,7 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace permissions: - rules: @@ -335,7 +336,6 @@ status: verbs: - patch serviceName: oneimage - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/permissions/containerwithnamespace/expected.golden b/pkg/controller/appdefinition/testdata/permissions/containerwithnamespace/expected.golden index 1e020adba..57cd48fe9 100644 --- a/pkg/controller/appdefinition/testdata/permissions/containerwithnamespace/expected.golden +++ b/pkg/controller/appdefinition/testdata/permissions/containerwithnamespace/expected.golden @@ -424,6 +424,7 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace permissions: - rules: @@ -451,7 +452,6 @@ status: verbs: - patch serviceName: oneimage - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/permissions/differentpermissions/expected.golden b/pkg/controller/appdefinition/testdata/permissions/differentpermissions/expected.golden index 042418f98..65710f6a8 100644 --- a/pkg/controller/appdefinition/testdata/permissions/differentpermissions/expected.golden +++ b/pkg/controller/appdefinition/testdata/permissions/differentpermissions/expected.golden @@ -611,6 +611,7 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace permissions: - rules: @@ -645,7 +646,6 @@ status: verbs: - delete serviceName: twoimage - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/permissions/job/expected.golden b/pkg/controller/appdefinition/testdata/permissions/job/expected.golden index fbbec57f3..637fd487f 100644 --- a/pkg/controller/appdefinition/testdata/permissions/job/expected.golden +++ b/pkg/controller/appdefinition/testdata/permissions/job/expected.golden @@ -320,6 +320,7 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace permissions: - rules: @@ -338,7 +339,6 @@ status: verbs: - patch serviceName: oneimage - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/permissions/multiplecontainers/expected.golden b/pkg/controller/appdefinition/testdata/permissions/multiplecontainers/expected.golden index e32ae618f..471abe52a 100644 --- a/pkg/controller/appdefinition/testdata/permissions/multiplecontainers/expected.golden +++ b/pkg/controller/appdefinition/testdata/permissions/multiplecontainers/expected.golden @@ -611,6 +611,7 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace permissions: - rules: @@ -645,7 +646,6 @@ status: verbs: - patch serviceName: twoimage - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/permissions/multiplejobs/expected.golden b/pkg/controller/appdefinition/testdata/permissions/multiplejobs/expected.golden index d94874b00..00b9615a1 100644 --- a/pkg/controller/appdefinition/testdata/permissions/multiplejobs/expected.golden +++ b/pkg/controller/appdefinition/testdata/permissions/multiplejobs/expected.golden @@ -616,6 +616,7 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace permissions: - rules: @@ -650,7 +651,6 @@ status: verbs: - patch serviceName: twoimage - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/probes/expected.golden b/pkg/controller/appdefinition/testdata/probes/expected.golden index f15b0ddb9..fda5df155 100644 --- a/pkg/controller/appdefinition/testdata/probes/expected.golden +++ b/pkg/controller/appdefinition/testdata/probes/expected.golden @@ -368,8 +368,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/pullsecrets/custom/expected.golden b/pkg/controller/appdefinition/testdata/pullsecrets/custom/expected.golden index 8ed9c6846..1a4d3cdc7 100644 --- a/pkg/controller/appdefinition/testdata/pullsecrets/custom/expected.golden +++ b/pkg/controller/appdefinition/testdata/pullsecrets/custom/expected.golden @@ -260,8 +260,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/pullsecrets/default/expected.golden b/pkg/controller/appdefinition/testdata/pullsecrets/default/expected.golden index 3e2bcf6af..6609cd71f 100644 --- a/pkg/controller/appdefinition/testdata/pullsecrets/default/expected.golden +++ b/pkg/controller/appdefinition/testdata/pullsecrets/default/expected.golden @@ -260,8 +260,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/router/expected.golden b/pkg/controller/appdefinition/testdata/router/expected.golden index d08953833..24c438c25 100644 --- a/pkg/controller/appdefinition/testdata/router/expected.golden +++ b/pkg/controller/appdefinition/testdata/router/expected.golden @@ -277,8 +277,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/secret/expected.golden b/pkg/controller/appdefinition/testdata/secret/expected.golden index 098dc3b87..df36efc17 100644 --- a/pkg/controller/appdefinition/testdata/secret/expected.golden +++ b/pkg/controller/appdefinition/testdata/secret/expected.golden @@ -241,8 +241,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/service/alias/expected.golden b/pkg/controller/appdefinition/testdata/service/alias/expected.golden index 5f8004199..51cd2ebc9 100644 --- a/pkg/controller/appdefinition/testdata/service/alias/expected.golden +++ b/pkg/controller/appdefinition/testdata/service/alias/expected.golden @@ -586,8 +586,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/service/basic/expected.golden b/pkg/controller/appdefinition/testdata/service/basic/expected.golden index 4de94d130..45f12af58 100644 --- a/pkg/controller/appdefinition/testdata/service/basic/expected.golden +++ b/pkg/controller/appdefinition/testdata/service/basic/expected.golden @@ -386,8 +386,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/template/expected.golden b/pkg/controller/appdefinition/testdata/template/expected.golden index 914553a18..bc1ff8f49 100644 --- a/pkg/controller/appdefinition/testdata/template/expected.golden +++ b/pkg/controller/appdefinition/testdata/template/expected.golden @@ -137,8 +137,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/volumes/cluster-default-with-bind-combos/expected.golden b/pkg/controller/appdefinition/testdata/volumes/cluster-default-with-bind-combos/expected.golden index 8be28dc2a..6dd4f518c 100644 --- a/pkg/controller/appdefinition/testdata/volumes/cluster-default-with-bind-combos/expected.golden +++ b/pkg/controller/appdefinition/testdata/volumes/cluster-default-with-bind-combos/expected.golden @@ -134,7 +134,7 @@ metadata: acorn.io/app-namespace: app-namespace acorn.io/managed: "true" acorn.io/public-name: app-name.bar - acorn.io/volume-class: "" + acorn.io/volume-class: test-custom-class acorn.io/volume-name: bar name: bar namespace: app-created-namespace @@ -144,7 +144,7 @@ spec: resources: requests: storage: 6Gi - storageClassName: "" + storageClassName: custom-class status: {} --- @@ -159,17 +159,17 @@ metadata: acorn.io/app-namespace: app-namespace acorn.io/managed: "true" acorn.io/public-name: app-name.foo - acorn.io/volume-class: "" + acorn.io/volume-class: test-custom-class acorn.io/volume-name: foo name: foo namespace: app-created-namespace spec: accessModes: - - ReadWriteMany + - ReadWriteOnce resources: requests: storage: 3Gi - storageClassName: "" + storageClassName: custom-class status: {} --- @@ -225,8 +225,7 @@ status: status: "True" success: true type: defined - namespace: app-created-namespace - resolvedOfferings: + defaults: volumes: bar: accessModes: @@ -237,6 +236,7 @@ status: - readWriteMany class: test-custom-class-default size: 2Gi + namespace: app-created-namespace staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/volumes/cluster-default-with-bind-combos/input.yaml b/pkg/controller/appdefinition/testdata/volumes/cluster-default-with-bind-combos/input.yaml index b6d658b19..043bc7802 100644 --- a/pkg/controller/appdefinition/testdata/volumes/cluster-default-with-bind-combos/input.yaml +++ b/pkg/controller/appdefinition/testdata/volumes/cluster-default-with-bind-combos/input.yaml @@ -34,7 +34,7 @@ status: bar: class: test-custom-class-request size: 6Gi - resolvedOfferings: + defaults: volumes: foo: class: test-custom-class-default diff --git a/pkg/controller/appdefinition/testdata/volumes/configure-but-no-bind/expected.golden b/pkg/controller/appdefinition/testdata/volumes/configure-but-no-bind/expected.golden index 68cfc2066..6626b5c6f 100644 --- a/pkg/controller/appdefinition/testdata/volumes/configure-but-no-bind/expected.golden +++ b/pkg/controller/appdefinition/testdata/volumes/configure-but-no-bind/expected.golden @@ -183,8 +183,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/volumes/contextdir/expected.golden b/pkg/controller/appdefinition/testdata/volumes/contextdir/expected.golden index 838047a92..041e7e82a 100644 --- a/pkg/controller/appdefinition/testdata/volumes/contextdir/expected.golden +++ b/pkg/controller/appdefinition/testdata/volumes/contextdir/expected.golden @@ -151,8 +151,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/volumes/defaults/expected.golden b/pkg/controller/appdefinition/testdata/volumes/defaults/expected.golden index 3716d8f39..1d6ccdd46 100644 --- a/pkg/controller/appdefinition/testdata/volumes/defaults/expected.golden +++ b/pkg/controller/appdefinition/testdata/volumes/defaults/expected.golden @@ -177,14 +177,14 @@ status: status: "True" success: true type: defined - namespace: app-created-namespace - resolvedOfferings: + defaults: volumes: foo: accessModes: - readWriteOnce class: test-custom-class size: 3Gi + namespace: app-created-namespace staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/volumes/defaults/input.yaml b/pkg/controller/appdefinition/testdata/volumes/defaults/input.yaml index 2e17957a7..b2ea7057b 100644 --- a/pkg/controller/appdefinition/testdata/volumes/defaults/input.yaml +++ b/pkg/controller/appdefinition/testdata/volumes/defaults/input.yaml @@ -19,7 +19,7 @@ status: volume: foo volumes: foo: {} - resolvedOfferings: + defaults: volumes: foo: class: test-custom-class diff --git a/pkg/controller/appdefinition/testdata/volumes/empty/expected.golden b/pkg/controller/appdefinition/testdata/volumes/empty/expected.golden index d80e46239..aec68b6f4 100644 --- a/pkg/controller/appdefinition/testdata/volumes/empty/expected.golden +++ b/pkg/controller/appdefinition/testdata/volumes/empty/expected.golden @@ -175,8 +175,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/volumes/ephemeral-bound/expected.golden b/pkg/controller/appdefinition/testdata/volumes/ephemeral-bound/expected.golden index bb30239c9..9c5bcbe58 100644 --- a/pkg/controller/appdefinition/testdata/volumes/ephemeral-bound/expected.golden +++ b/pkg/controller/appdefinition/testdata/volumes/ephemeral-bound/expected.golden @@ -181,8 +181,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/volumes/ephemeral/expected.golden b/pkg/controller/appdefinition/testdata/volumes/ephemeral/expected.golden index 94d0b8634..d8c009787 100644 --- a/pkg/controller/appdefinition/testdata/volumes/ephemeral/expected.golden +++ b/pkg/controller/appdefinition/testdata/volumes/ephemeral/expected.golden @@ -152,8 +152,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/volumes/inactive-class/expected.golden b/pkg/controller/appdefinition/testdata/volumes/inactive-class/expected.golden index 3716d8f39..1d6ccdd46 100644 --- a/pkg/controller/appdefinition/testdata/volumes/inactive-class/expected.golden +++ b/pkg/controller/appdefinition/testdata/volumes/inactive-class/expected.golden @@ -177,14 +177,14 @@ status: status: "True" success: true type: defined - namespace: app-created-namespace - resolvedOfferings: + defaults: volumes: foo: accessModes: - readWriteOnce class: test-custom-class size: 3Gi + namespace: app-created-namespace staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/volumes/inactive-class/input.yaml b/pkg/controller/appdefinition/testdata/volumes/inactive-class/input.yaml index 2e17957a7..b2ea7057b 100644 --- a/pkg/controller/appdefinition/testdata/volumes/inactive-class/input.yaml +++ b/pkg/controller/appdefinition/testdata/volumes/inactive-class/input.yaml @@ -19,7 +19,7 @@ status: volume: foo volumes: foo: {} - resolvedOfferings: + defaults: volumes: foo: class: test-custom-class diff --git a/pkg/controller/appdefinition/testdata/volumes/named-bound/expected.golden b/pkg/controller/appdefinition/testdata/volumes/named-bound/expected.golden index 787b2bc30..0e446cd14 100644 --- a/pkg/controller/appdefinition/testdata/volumes/named-bound/expected.golden +++ b/pkg/controller/appdefinition/testdata/volumes/named-bound/expected.golden @@ -183,8 +183,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/volumes/named/expected.golden b/pkg/controller/appdefinition/testdata/volumes/named/expected.golden index 26121c773..59655bcf4 100644 --- a/pkg/controller/appdefinition/testdata/volumes/named/expected.golden +++ b/pkg/controller/appdefinition/testdata/volumes/named/expected.golden @@ -179,8 +179,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/volumes/no-default-class/expected.golden b/pkg/controller/appdefinition/testdata/volumes/no-default-class/expected.golden index d80e46239..aec68b6f4 100644 --- a/pkg/controller/appdefinition/testdata/volumes/no-default-class/expected.golden +++ b/pkg/controller/appdefinition/testdata/volumes/no-default-class/expected.golden @@ -175,8 +175,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/volumes/preload/expected.golden b/pkg/controller/appdefinition/testdata/volumes/preload/expected.golden index ff309fc6a..11cbffd17 100644 --- a/pkg/controller/appdefinition/testdata/volumes/preload/expected.golden +++ b/pkg/controller/appdefinition/testdata/volumes/preload/expected.golden @@ -238,8 +238,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/volumes/reuse-existing/expected.golden b/pkg/controller/appdefinition/testdata/volumes/reuse-existing/expected.golden index 80c707995..782822f5a 100644 --- a/pkg/controller/appdefinition/testdata/volumes/reuse-existing/expected.golden +++ b/pkg/controller/appdefinition/testdata/volumes/reuse-existing/expected.golden @@ -177,8 +177,8 @@ status: status: "True" success: true type: defined + defaults: {} namespace: app-created-namespace - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/volume.go b/pkg/controller/appdefinition/volume.go index 6374e08d9..2b8e9d0d6 100644 --- a/pkg/controller/appdefinition/volume.go +++ b/pkg/controller/appdefinition/volume.go @@ -19,6 +19,7 @@ import ( name2 "github.com/rancher/wrangler/pkg/name" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" klabels "k8s.io/apimachinery/pkg/labels" kclient "sigs.k8s.io/controller-runtime/pkg/client" @@ -112,7 +113,7 @@ func LookupExistingPV(req router.Request, appInstance *v1.AppInstance, volumeNam } func toPVCs(req router.Request, appInstance *v1.AppInstance) (result []kclient.Object, err error) { - volumeClasses, defaultVolumeClass, err := volume.GetVolumeClassInstances(req.Ctx, req.Client, appInstance.Namespace) + volumeClasses, _, err := volume.GetVolumeClassInstances(req.Ctx, req.Client, appInstance.Namespace) if err != nil { return nil, err } @@ -126,10 +127,7 @@ func toPVCs(req router.Request, appInstance *v1.AppInstance) (result []kclient.O continue } - volumeRequest, err = volume.ResolveVolumeRequest(req.Ctx, req.Client, volumeRequest, volumeBinding, volumeClasses, defaultVolumeClass, appInstance.Status.ResolvedOfferings.Volumes[vol]) - if err != nil { - return nil, err - } + volumeRequest = volume.CopyVolumeDefaults(volumeRequest, volumeBinding, appInstance.Status.Defaults.Volumes[vol]) pvc := corev1.PersistentVolumeClaim{ ObjectMeta: metav1.ObjectMeta{ @@ -199,7 +197,16 @@ func toPVCs(req router.Request, appInstance *v1.AppInstance) (result []kclient.O pvc.Spec.VolumeName = pvName if volumeRequest.Size == "" { - pvc.Spec.Resources.Requests[corev1.ResourceStorage] = *v1.DefaultSize + // If the volumeRequest does not have a size set, then we need to determine what default to use. If status.Defaults.Volumes has this + // volume set, then we use that. Otherwise, we use v1 package level default size. + defaultSize := *v1.DefaultSize + if defaultVolume, hasDefaultSet := appInstance.Status.Defaults.Volumes[vol]; hasDefaultSet { + defaultSize, err = resource.ParseQuantity(string(defaultVolume.Size)) + if err != nil { + return nil, fmt.Errorf("failed to parse default volume size %q for volume %q: %w", defaultVolume.Size, vol, err) + } + } + pvc.Spec.Resources.Requests[corev1.ResourceStorage] = defaultSize } else { pvc.Spec.Resources.Requests[corev1.ResourceStorage] = *v1.MustParseResourceQuantity(volumeRequest.Size) } diff --git a/pkg/controller/appstatus/check.go b/pkg/controller/appstatus/check.go index 05a6c0498..fb7f9ffc7 100644 --- a/pkg/controller/appstatus/check.go +++ b/pkg/controller/appstatus/check.go @@ -9,7 +9,7 @@ func CheckStatus(h router.Handler) router.Handler { return router.HandlerFunc(func(req router.Request, resp router.Response) error { appInstance := req.Object.(*v1.AppInstance) conditionsToCheck := []string{ - v1.AppInstanceConditionResolvedOfferings, + v1.AppInstanceConditionDefaults, v1.AppInstanceConditionScheduling, v1.AppInstanceConditionQuota, } diff --git a/pkg/controller/appstatus/check_test.go b/pkg/controller/appstatus/check_test.go index 9bd6033dd..1741b1dd5 100644 --- a/pkg/controller/appstatus/check_test.go +++ b/pkg/controller/appstatus/check_test.go @@ -27,7 +27,7 @@ func TestCheckStatus(t *testing.T) { } assert.False(t, called, "router handler call unexpected") - condition.Setter(appInstance, resp, v1.AppInstanceConditionResolvedOfferings).Success() + condition.Setter(appInstance, resp, v1.AppInstanceConditionDefaults).Success() condition.Setter(appInstance, resp, v1.AppInstanceConditionScheduling).Success() condition.Setter(appInstance, resp, v1.AppInstanceConditionQuota).Success() diff --git a/pkg/controller/resolvedofferings/resolvedofferings.go b/pkg/controller/defaults/defaults.go similarity index 63% rename from pkg/controller/resolvedofferings/resolvedofferings.go rename to pkg/controller/defaults/defaults.go index 388abe427..0e97e3fc8 100644 --- a/pkg/controller/resolvedofferings/resolvedofferings.go +++ b/pkg/controller/defaults/defaults.go @@ -1,4 +1,4 @@ -package resolvedofferings +package defaults import ( "github.com/acorn-io/baaah/pkg/router" @@ -7,16 +7,16 @@ import ( "github.com/acorn-io/runtime/pkg/config" ) -// Calculate is a handler that sets the resolved offerings for an AppInstance to its status if +// Calculate is a handler that sets the defaults for an AppInstance to its status if // and only if its generation is different from its observedGeneration. // -// This is necessary because querying for resolved offerings will result in all running +// This is necessary because querying for defaults will result in all running // AppInstances using that default to redeploy when a default changes. By -// calculating the resolved offerings only when the generation changes, we can ensure that -// updated resolved offerings are only applied when an AppInstance is updated directly. +// calculating the defaults only when the generation changes, we can ensure that +// updated defaults are only applied when an AppInstance is updated directly. func Calculate(req router.Request, resp router.Response) (err error) { appInstance := req.Object.(*internalv1.AppInstance) - status := condition.Setter(appInstance, resp, internalv1.AppInstanceConditionResolvedOfferings) + status := condition.Setter(appInstance, resp, internalv1.AppInstanceConditionDefaults) defer func() { if err == nil { @@ -30,9 +30,9 @@ func Calculate(req router.Request, resp router.Response) (err error) { } }() - // resolveVolumeClasses should run everytime as the function itself will not overwrite any existing - // information. Effectively, this means that volume class info only gets set if it have not been set before. - if err = resolveVolumeClasses(req.Ctx, req.Client, appInstance); err != nil { + // addVolumeClassDefaults should run everytime as the function itself will not overwrite any existing + // defaults. Effectively, this means that volume defaults only get set if they have not been set before. + if err = addVolumeClassDefaults(req.Ctx, req.Client, appInstance); err != nil { return err } @@ -55,7 +55,7 @@ func calculate(req router.Request, appInstance *internalv1.AppInstance) error { return err } - if err = resolveComputeClasses(req, cfg, appInstance); err != nil { + if err = addDefaultMemory(req, cfg, appInstance); err != nil { return err } diff --git a/pkg/controller/defaults/memory.go b/pkg/controller/defaults/memory.go new file mode 100644 index 000000000..e97c5a76e --- /dev/null +++ b/pkg/controller/defaults/memory.go @@ -0,0 +1,84 @@ +package defaults + +import ( + "github.com/acorn-io/baaah/pkg/router" + apiv1 "github.com/acorn-io/runtime/pkg/apis/api.acorn.io/v1" + v1 "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1" + adminv1 "github.com/acorn-io/runtime/pkg/apis/internal.admin.acorn.io/v1" + "github.com/acorn-io/runtime/pkg/computeclasses" + apierrors "k8s.io/apimachinery/pkg/api/errors" +) + +// defaultMemory calculates the default that should be used and considers the defaults from the Config, ComputeClass, and +// runtime ComputeClass +func addDefaultMemory(req router.Request, cfg *apiv1.Config, appInstance *v1.AppInstance) error { + if appInstance.Status.Defaults.Memory == nil { + appInstance.Status.Defaults.Memory = v1.MemoryMap{} + } + + var ( + defaultCC string + err error + ) + if value, ok := appInstance.Spec.ComputeClasses[""]; ok { + defaultCC = value + } else { + defaultCC, err = adminv1.GetDefaultComputeClass(req.Ctx, req.Client, appInstance.Namespace) + if err != nil { + return err + } + } + + appInstance.Status.Defaults.Memory[""] = cfg.WorkloadMemoryDefault + cc, err := computeclasses.GetAsProjectComputeClassInstance(req.Ctx, req.Client, appInstance.Status.Namespace, defaultCC) + if err != nil { + if !apierrors.IsNotFound(err) { + return err + } + } + + if cc != nil { + parsedMemory, err := computeclasses.ParseComputeClassMemory(cc.Memory) + if err != nil { + return err + } + def := parsedMemory.Def.Value() + appInstance.Status.Defaults.Memory[""] = &def + } + + if err := addWorkloadMemoryDefault(req, appInstance, cfg.WorkloadMemoryDefault, appInstance.Status.AppSpec.Containers); err != nil { + return err + } + + if err := addWorkloadMemoryDefault(req, appInstance, cfg.WorkloadMemoryDefault, appInstance.Status.AppSpec.Jobs); err != nil { + return err + } + + return nil +} + +func addWorkloadMemoryDefault(req router.Request, appInstance *v1.AppInstance, configDefault *int64, containers map[string]v1.Container) error { + for name, container := range containers { + memory := configDefault + computeClass, err := computeclasses.GetClassForWorkload(req.Ctx, req.Client, appInstance.Spec.ComputeClasses, container, name, appInstance.Namespace) + if err != nil { + return err + } + + if computeClass != nil { + parsedMemory, err := computeclasses.ParseComputeClassMemory(computeClass.Memory) + if err != nil { + return err + } + def := parsedMemory.Def.Value() + memory = &def + } + appInstance.Status.Defaults.Memory[name] = memory + + for sidecarName := range container.Sidecars { + appInstance.Status.Defaults.Memory[sidecarName] = memory + } + } + + return nil +} diff --git a/pkg/controller/defaults/memory_test.go b/pkg/controller/defaults/memory_test.go new file mode 100644 index 000000000..5df464f24 --- /dev/null +++ b/pkg/controller/defaults/memory_test.go @@ -0,0 +1,74 @@ +package defaults + +import ( + "testing" + + "github.com/acorn-io/baaah/pkg/router" + "github.com/acorn-io/baaah/pkg/router/tester" + "github.com/acorn-io/runtime/pkg/scheme" + "github.com/stretchr/testify/assert" +) + +func TestContainerMemory(t *testing.T) { + tester.DefaultTest(t, scheme.Scheme, "testdata/memory/container", Calculate) +} + +func TestSidecarMemory(t *testing.T) { + tester.DefaultTest(t, scheme.Scheme, "testdata/memory/sidecar", Calculate) +} + +func TestJobMemory(t *testing.T) { + tester.DefaultTest(t, scheme.Scheme, "testdata/memory/job", Calculate) +} + +func TestOverwriteAcornfileMemory(t *testing.T) { + tester.DefaultTest(t, scheme.Scheme, "testdata/memory/overwrite-acornfile-memory", Calculate) +} + +func TestWithAcornfileMemory(t *testing.T) { + tester.DefaultTest(t, scheme.Scheme, "testdata/memory/with-acornfile-memory", Calculate) +} + +func TestTwoContainers(t *testing.T) { + tester.DefaultTest(t, scheme.Scheme, "testdata/memory/two-containers", Calculate) +} + +func TestAllSet(t *testing.T) { + tester.DefaultTest(t, scheme.Scheme, "testdata/memory/all-set", Calculate) +} + +func TestAllSetOverwrite(t *testing.T) { + tester.DefaultTest(t, scheme.Scheme, "testdata/memory/all-set-overwrite", Calculate) +} + +func TestMemorySameGeneration(t *testing.T) { + tester.DefaultTest(t, scheme.Scheme, "testdata/memory/same-generation", Calculate) +} + +func TestTwoCCCDefaultsShouldError(t *testing.T) { + harness, input, err := tester.FromDir(scheme.Scheme, "testdata/memory/two-ccc-defaults-should-error") + if err != nil { + t.Fatal(err) + } + + resp, err := harness.Invoke(t, input, router.HandlerFunc(Calculate)) + if err != nil { + t.Fatal(err) + } + + assert.True(t, resp.NoPrune, "NoPrune should be true when error occurs") +} + +func TestTwoPCCDefaultsShouldError(t *testing.T) { + harness, input, err := tester.FromDir(scheme.Scheme, "testdata/memory/two-pcc-defaults-should-error") + if err != nil { + t.Fatal(err) + } + + resp, err := harness.Invoke(t, input, router.HandlerFunc(Calculate)) + if err != nil { + t.Fatal(err) + } + + assert.True(t, resp.NoPrune, "NoPrune should be true when error occurs") +} diff --git a/pkg/controller/resolvedofferings/region.go b/pkg/controller/defaults/region.go similarity index 91% rename from pkg/controller/resolvedofferings/region.go rename to pkg/controller/defaults/region.go index 9b21e4e5f..5ae355ae9 100644 --- a/pkg/controller/resolvedofferings/region.go +++ b/pkg/controller/defaults/region.go @@ -1,4 +1,4 @@ -package resolvedofferings +package defaults import ( "context" @@ -23,8 +23,6 @@ func AddDefaultRegion(ctx context.Context, c client.Client, obj RegionGetterSett } obj.SetDefaultRegion(project.Status.DefaultRegion) - } else { - obj.SetDefaultRegion(obj.GetRegion()) } return nil diff --git a/pkg/controller/resolvedofferings/region_test.go b/pkg/controller/defaults/region_test.go similarity index 95% rename from pkg/controller/resolvedofferings/region_test.go rename to pkg/controller/defaults/region_test.go index d32551751..2069f77ec 100644 --- a/pkg/controller/resolvedofferings/region_test.go +++ b/pkg/controller/defaults/region_test.go @@ -1,4 +1,4 @@ -package resolvedofferings +package defaults import ( "testing" diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/all-set-overwrite/existing.yaml b/pkg/controller/defaults/testdata/memory/all-set-overwrite/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/all-set-overwrite/existing.yaml rename to pkg/controller/defaults/testdata/memory/all-set-overwrite/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/all-set/expected.golden b/pkg/controller/defaults/testdata/memory/all-set-overwrite/expected.golden similarity index 86% rename from pkg/controller/resolvedofferings/testdata/computeclass/all-set/expected.golden rename to pkg/controller/defaults/testdata/memory/all-set-overwrite/expected.golden index 69f31c986..094fafdc3 100644 --- a/pkg/controller/resolvedofferings/testdata/computeclass/all-set/expected.golden +++ b/pkg/controller/defaults/testdata/memory/all-set-overwrite/expected.golden @@ -9,6 +9,7 @@ spec: image: test memory: "": 1048576 + oneimage: 2097152 status: appImage: buildContext: {} @@ -43,18 +44,15 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 + region: local namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 0 - oneimage: - memory: 0 - region: local staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/all-set-overwrite/input.yaml b/pkg/controller/defaults/testdata/memory/all-set-overwrite/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/all-set-overwrite/input.yaml rename to pkg/controller/defaults/testdata/memory/all-set-overwrite/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/all-set/existing.yaml b/pkg/controller/defaults/testdata/memory/all-set/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/all-set/existing.yaml rename to pkg/controller/defaults/testdata/memory/all-set/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/all-set/expected.golden b/pkg/controller/defaults/testdata/memory/all-set/expected.golden new file mode 100644 index 000000000..67d1a40a5 --- /dev/null +++ b/pkg/controller/defaults/testdata/memory/all-set/expected.golden @@ -0,0 +1,61 @@ +`apiVersion: internal.acorn.io/v1 +kind: AppInstance +metadata: + creationTimestamp: null + name: app-name + namespace: app-namespace + uid: 1234567890abcdef +spec: + image: test + memory: + "": 1048576 +status: + appImage: + buildContext: {} + id: test + imageData: {} + vcs: {} + appSpec: + containers: + oneimage: + build: + context: . + dockerfile: Dockerfile + image: image-name + metrics: {} + ports: + - port: 80 + protocol: http + targetPort: 81 + probes: null + sidecars: + left: + image: foo + metrics: {} + ports: + - port: 90 + protocol: tcp + targetPort: 91 + probes: null + appStatus: {} + columns: {} + conditions: + reason: Success + status: "True" + success: true + type: defaults + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 + region: local + namespace: app-created-namespace + observedGeneration: 1 + staged: + appImage: + buildContext: {} + imageData: {} + vcs: {} + summary: {} +` diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/all-set/input.yaml b/pkg/controller/defaults/testdata/memory/all-set/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/all-set/input.yaml rename to pkg/controller/defaults/testdata/memory/all-set/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/container/existing.yaml b/pkg/controller/defaults/testdata/memory/container/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/container/existing.yaml rename to pkg/controller/defaults/testdata/memory/container/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/job/expected.golden b/pkg/controller/defaults/testdata/memory/container/expected.golden similarity index 86% rename from pkg/controller/resolvedofferings/testdata/computeclass/job/expected.golden rename to pkg/controller/defaults/testdata/memory/container/expected.golden index 36968e541..d2b5b4bd7 100644 --- a/pkg/controller/resolvedofferings/testdata/computeclass/job/expected.golden +++ b/pkg/controller/defaults/testdata/memory/container/expected.golden @@ -16,7 +16,7 @@ status: imageData: {} vcs: {} appSpec: - jobs: + containers: oneimage: build: context: . @@ -43,18 +43,15 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 + region: local namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 - region: local staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/container/input.yaml b/pkg/controller/defaults/testdata/memory/container/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/container/input.yaml rename to pkg/controller/defaults/testdata/memory/container/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/job/existing.yaml b/pkg/controller/defaults/testdata/memory/job/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/job/existing.yaml rename to pkg/controller/defaults/testdata/memory/job/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/container/expected.golden b/pkg/controller/defaults/testdata/memory/job/expected.golden similarity index 84% rename from pkg/controller/resolvedofferings/testdata/computeclass/container/expected.golden rename to pkg/controller/defaults/testdata/memory/job/expected.golden index f1d13b9b3..6d4a068f2 100644 --- a/pkg/controller/resolvedofferings/testdata/computeclass/container/expected.golden +++ b/pkg/controller/defaults/testdata/memory/job/expected.golden @@ -16,7 +16,7 @@ status: imageData: {} vcs: {} appSpec: - containers: + jobs: oneimage: build: context: . @@ -43,18 +43,15 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 + region: local namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 - region: local staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/job/input.yaml b/pkg/controller/defaults/testdata/memory/job/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/job/input.yaml rename to pkg/controller/defaults/testdata/memory/job/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/overwrite-acornfile-memory/existing.yaml b/pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/overwrite-acornfile-memory/existing.yaml rename to pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/overwrite-acornfile-memory/expected.golden b/pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/expected.golden similarity index 86% rename from pkg/controller/resolvedofferings/testdata/computeclass/overwrite-acornfile-memory/expected.golden rename to pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/expected.golden index da00b488b..7006c74d2 100644 --- a/pkg/controller/resolvedofferings/testdata/computeclass/overwrite-acornfile-memory/expected.golden +++ b/pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/expected.golden @@ -44,18 +44,15 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 + region: local namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 - region: local staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/overwrite-acornfile-memory/input.yaml b/pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/overwrite-acornfile-memory/input.yaml rename to pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/same-generation/expected.golden b/pkg/controller/defaults/testdata/memory/same-generation/expected.golden similarity index 86% rename from pkg/controller/resolvedofferings/testdata/computeclass/same-generation/expected.golden rename to pkg/controller/defaults/testdata/memory/same-generation/expected.golden index b74d4d229..7ea75f112 100644 --- a/pkg/controller/resolvedofferings/testdata/computeclass/same-generation/expected.golden +++ b/pkg/controller/defaults/testdata/memory/same-generation/expected.golden @@ -43,16 +43,13 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 0 - oneimage: - memory: 0 staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/same-generation/input.yaml b/pkg/controller/defaults/testdata/memory/same-generation/input.yaml similarity index 83% rename from pkg/controller/resolvedofferings/testdata/computeclass/same-generation/input.yaml rename to pkg/controller/defaults/testdata/memory/same-generation/input.yaml index b6661c147..ebc2f5f36 100644 --- a/pkg/controller/resolvedofferings/testdata/computeclass/same-generation/input.yaml +++ b/pkg/controller/defaults/testdata/memory/same-generation/input.yaml @@ -9,14 +9,11 @@ spec: memory: left: 1048576 # 1Mi status: - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 0 - oneimage: - memory: 0 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/sidecar/existing.yaml b/pkg/controller/defaults/testdata/memory/sidecar/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/sidecar/existing.yaml rename to pkg/controller/defaults/testdata/memory/sidecar/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/sidecar/expected.golden b/pkg/controller/defaults/testdata/memory/sidecar/expected.golden similarity index 86% rename from pkg/controller/resolvedofferings/testdata/computeclass/sidecar/expected.golden rename to pkg/controller/defaults/testdata/memory/sidecar/expected.golden index 7ad60b3a3..78ef621ea 100644 --- a/pkg/controller/resolvedofferings/testdata/computeclass/sidecar/expected.golden +++ b/pkg/controller/defaults/testdata/memory/sidecar/expected.golden @@ -43,18 +43,15 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 + region: local namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 0 - oneimage: - memory: 0 - region: local staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/sidecar/input.yaml b/pkg/controller/defaults/testdata/memory/sidecar/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/sidecar/input.yaml rename to pkg/controller/defaults/testdata/memory/sidecar/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/two-ccc-defaults-should-error/existing.yaml b/pkg/controller/defaults/testdata/memory/two-ccc-defaults-should-error/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/two-ccc-defaults-should-error/existing.yaml rename to pkg/controller/defaults/testdata/memory/two-ccc-defaults-should-error/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/two-pcc-defaults-should-error/expected.yaml b/pkg/controller/defaults/testdata/memory/two-ccc-defaults-should-error/expected.yaml similarity index 94% rename from pkg/controller/resolvedofferings/testdata/computeclass/two-pcc-defaults-should-error/expected.yaml rename to pkg/controller/defaults/testdata/memory/two-ccc-defaults-should-error/expected.yaml index 438071625..9699fbeac 100644 --- a/pkg/controller/resolvedofferings/testdata/computeclass/two-pcc-defaults-should-error/expected.yaml +++ b/pkg/controller/defaults/testdata/memory/two-ccc-defaults-should-error/expected.yaml @@ -9,6 +9,8 @@ spec: memory: oneimage: 1048576 # 1Mi status: + defaults: + region: local observedGeneration: 1 namespace: app-created-namespace appImage: @@ -36,6 +38,4 @@ status: message: 'cannot establish defaults because two default computeclasses exist: sample-compute-class and sample-compute-class-other' reason: Error status: "False" - type: resolved-offerings - resolvedOfferings: - region: local + type: defaults diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/two-ccc-defaults-should-error/input.yaml b/pkg/controller/defaults/testdata/memory/two-ccc-defaults-should-error/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/two-ccc-defaults-should-error/input.yaml rename to pkg/controller/defaults/testdata/memory/two-ccc-defaults-should-error/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/two-containers/existing.yaml b/pkg/controller/defaults/testdata/memory/two-containers/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/two-containers/existing.yaml rename to pkg/controller/defaults/testdata/memory/two-containers/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/two-containers/expected.golden b/pkg/controller/defaults/testdata/memory/two-containers/expected.golden similarity index 86% rename from pkg/controller/resolvedofferings/testdata/computeclass/two-containers/expected.golden rename to pkg/controller/defaults/testdata/memory/two-containers/expected.golden index a7a868a01..34a0213d4 100644 --- a/pkg/controller/resolvedofferings/testdata/computeclass/two-containers/expected.golden +++ b/pkg/controller/defaults/testdata/memory/two-containers/expected.golden @@ -45,18 +45,15 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults + defaults: + memory: + "": 0 + oneimage: 0 + twoimage: 0 + region: local namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - oneimage: - memory: 1048576 - twoimage: - memory: 0 - region: local staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/two-containers/input.yaml b/pkg/controller/defaults/testdata/memory/two-containers/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/two-containers/input.yaml rename to pkg/controller/defaults/testdata/memory/two-containers/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/two-pcc-defaults-should-error/existing.yaml b/pkg/controller/defaults/testdata/memory/two-pcc-defaults-should-error/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/two-pcc-defaults-should-error/existing.yaml rename to pkg/controller/defaults/testdata/memory/two-pcc-defaults-should-error/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/two-ccc-defaults-should-error/expected.yaml b/pkg/controller/defaults/testdata/memory/two-pcc-defaults-should-error/expected.yaml similarity index 94% rename from pkg/controller/resolvedofferings/testdata/computeclass/two-ccc-defaults-should-error/expected.yaml rename to pkg/controller/defaults/testdata/memory/two-pcc-defaults-should-error/expected.yaml index 438071625..9699fbeac 100644 --- a/pkg/controller/resolvedofferings/testdata/computeclass/two-ccc-defaults-should-error/expected.yaml +++ b/pkg/controller/defaults/testdata/memory/two-pcc-defaults-should-error/expected.yaml @@ -9,6 +9,8 @@ spec: memory: oneimage: 1048576 # 1Mi status: + defaults: + region: local observedGeneration: 1 namespace: app-created-namespace appImage: @@ -36,6 +38,4 @@ status: message: 'cannot establish defaults because two default computeclasses exist: sample-compute-class and sample-compute-class-other' reason: Error status: "False" - type: resolved-offerings - resolvedOfferings: - region: local + type: defaults diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/two-pcc-defaults-should-error/input.yaml b/pkg/controller/defaults/testdata/memory/two-pcc-defaults-should-error/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/two-pcc-defaults-should-error/input.yaml rename to pkg/controller/defaults/testdata/memory/two-pcc-defaults-should-error/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/with-acornfile-memory/existing.yaml b/pkg/controller/defaults/testdata/memory/with-acornfile-memory/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/with-acornfile-memory/existing.yaml rename to pkg/controller/defaults/testdata/memory/with-acornfile-memory/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/with-acornfile-memory/expected.golden b/pkg/controller/defaults/testdata/memory/with-acornfile-memory/expected.golden similarity index 85% rename from pkg/controller/resolvedofferings/testdata/computeclass/with-acornfile-memory/expected.golden rename to pkg/controller/defaults/testdata/memory/with-acornfile-memory/expected.golden index 049ef97f0..e23679fdb 100644 --- a/pkg/controller/resolvedofferings/testdata/computeclass/with-acornfile-memory/expected.golden +++ b/pkg/controller/defaults/testdata/memory/with-acornfile-memory/expected.golden @@ -42,18 +42,15 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 + region: local namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 - region: local staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/with-acornfile-memory/input.yaml b/pkg/controller/defaults/testdata/memory/with-acornfile-memory/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/computeclass/with-acornfile-memory/input.yaml rename to pkg/controller/defaults/testdata/memory/with-acornfile-memory/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/region/default/existing.yaml b/pkg/controller/defaults/testdata/region/default/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/region/default/existing.yaml rename to pkg/controller/defaults/testdata/region/default/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/region/project-default-status/expected.golden b/pkg/controller/defaults/testdata/region/default/expected.golden similarity index 82% rename from pkg/controller/resolvedofferings/testdata/region/project-default-status/expected.golden rename to pkg/controller/defaults/testdata/region/default/expected.golden index fb101d73b..ff24b6397 100644 --- a/pkg/controller/resolvedofferings/testdata/region/project-default-status/expected.golden +++ b/pkg/controller/defaults/testdata/region/default/expected.golden @@ -25,16 +25,14 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults + defaults: + memory: + "": 0 + container-name: 0 + region: local namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - container-name: - memory: 0 - region: local staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/region/default/input.yaml b/pkg/controller/defaults/testdata/region/default/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/region/default/input.yaml rename to pkg/controller/defaults/testdata/region/default/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/region/project-default-status/existing.yaml b/pkg/controller/defaults/testdata/region/project-default-status/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/region/project-default-status/existing.yaml rename to pkg/controller/defaults/testdata/region/project-default-status/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/region/default/expected.golden b/pkg/controller/defaults/testdata/region/project-default-status/expected.golden similarity index 82% rename from pkg/controller/resolvedofferings/testdata/region/default/expected.golden rename to pkg/controller/defaults/testdata/region/project-default-status/expected.golden index fb101d73b..ff24b6397 100644 --- a/pkg/controller/resolvedofferings/testdata/region/default/expected.golden +++ b/pkg/controller/defaults/testdata/region/project-default-status/expected.golden @@ -25,16 +25,14 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults + defaults: + memory: + "": 0 + container-name: 0 + region: local namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - container-name: - memory: 0 - region: local staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/region/project-default-status/input.yaml b/pkg/controller/defaults/testdata/region/project-default-status/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/region/project-default-status/input.yaml rename to pkg/controller/defaults/testdata/region/project-default-status/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/region/region-on-spec/existing.yaml b/pkg/controller/defaults/testdata/region/region-on-spec/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/region/region-on-spec/existing.yaml rename to pkg/controller/defaults/testdata/region/region-on-spec/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/region/region-on-spec/expected.golden b/pkg/controller/defaults/testdata/region/region-on-spec/expected.golden similarity index 80% rename from pkg/controller/resolvedofferings/testdata/region/region-on-spec/expected.golden rename to pkg/controller/defaults/testdata/region/region-on-spec/expected.golden index d243ccf4c..fe4b17aaf 100644 --- a/pkg/controller/resolvedofferings/testdata/region/region-on-spec/expected.golden +++ b/pkg/controller/defaults/testdata/region/region-on-spec/expected.golden @@ -26,16 +26,13 @@ status: reason: Success status: "True" success: true - type: resolved-offerings + type: defaults + defaults: + memory: + "": 0 + container-name: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - container-name: - memory: 0 - region: my-region staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/region/region-on-spec/input.yaml b/pkg/controller/defaults/testdata/region/region-on-spec/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/region/region-on-spec/input.yaml rename to pkg/controller/defaults/testdata/region/region-on-spec/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/cluster-and-project-class-same-name/existing.yaml b/pkg/controller/defaults/testdata/volumeclass/cluster-and-project-class-same-name/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/cluster-and-project-class-same-name/existing.yaml rename to pkg/controller/defaults/testdata/volumeclass/cluster-and-project-class-same-name/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/cluster-and-project-class-same-name/expected.golden b/pkg/controller/defaults/testdata/volumeclass/cluster-and-project-class-same-name/expected.golden similarity index 84% rename from pkg/controller/resolvedofferings/testdata/volumeclass/cluster-and-project-class-same-name/expected.golden rename to pkg/controller/defaults/testdata/volumeclass/cluster-and-project-class-same-name/expected.golden index d648d60cc..17231acd8 100644 --- a/pkg/controller/resolvedofferings/testdata/volumeclass/cluster-and-project-class-same-name/expected.golden +++ b/pkg/controller/defaults/testdata/volumeclass/cluster-and-project-class-same-name/expected.golden @@ -32,22 +32,19 @@ status: reason: Success status: "True" success: true - type: resolved-offerings - namespace: app-created-namespace - observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - container-name: - memory: 0 + type: defaults + defaults: + memory: + "": 0 + container-name: 0 region: local volumes: foo: accessModes: - readWriteMany - class: custom-class size: 6Gi + namespace: app-created-namespace + observedGeneration: 1 staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/cluster-and-project-class-same-name/input.yaml b/pkg/controller/defaults/testdata/volumeclass/cluster-and-project-class-same-name/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/cluster-and-project-class-same-name/input.yaml rename to pkg/controller/defaults/testdata/volumeclass/cluster-and-project-class-same-name/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-defaults-same-gen/existing.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-same-gen/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-defaults-same-gen/existing.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-same-gen/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-defaults-same-gen/expected.golden b/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-same-gen/expected.golden similarity index 85% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-defaults-same-gen/expected.golden rename to pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-same-gen/expected.golden index 146d84796..0d0f1f3a2 100644 --- a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-defaults-same-gen/expected.golden +++ b/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-same-gen/expected.golden @@ -31,15 +31,15 @@ status: columns: {} conditions: - error: true - message: 'cannot resolve volume classes because two defaults volume classes exist: + message: 'cannot establish defaults because two defaults volume classes exist: test-volume-class and test-volume-class-1' observedGeneration: 1 reason: Error status: "False" - type: resolved-offerings + type: defaults + defaults: {} namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-defaults-same-gen/input.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-same-gen/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-defaults-same-gen/input.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-same-gen/input.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/existing.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/existing.yaml new file mode 100644 index 000000000..d5b958611 --- /dev/null +++ b/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/existing.yaml @@ -0,0 +1,24 @@ +--- +kind: ProjectVolumeClassInstance +apiVersion: internal.admin.acorn.io/v1 +metadata: + name: test-volume-class + namespace: app-namespace +description: Just a simple test volume class +default: true +storageClassName: test-storage-class +size: + min: 1Gi + max: 10Gi + default: 2Gi +allowedAccessModes: ["readWriteOnce"] +--- +kind: ProjectInstance +apiVersion: internal.acorn.io/v1 +metadata: + name: app-namespace +spec: {} +status: + defaultRegion: local + supportedRegions: + - local diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/expected.golden b/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/expected.golden new file mode 100644 index 000000000..775c3f3f6 --- /dev/null +++ b/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/expected.golden @@ -0,0 +1,54 @@ +`apiVersion: internal.acorn.io/v1 +kind: AppInstance +metadata: + creationTimestamp: null + generation: 2 + name: app-name + namespace: app-namespace + uid: 1234567890abcdef +spec: + image: test +status: + appImage: + buildContext: {} + id: test + imageData: {} + vcs: {} + appSpec: + containers: + container-name: + dirs: + /var/tmp: + secret: {} + volume: foo + image: image-name + metrics: {} + probes: null + volumes: + foo: {} + appStatus: {} + columns: {} + conditions: + observedGeneration: 2 + reason: Success + status: "True" + success: true + type: defaults + defaults: + memory: + "": 0 + container-name: 0 + region: local + volumes: + foo: + class: test-volume-class + size: 4Gi + namespace: app-created-namespace + observedGeneration: 1 + staged: + appImage: + buildContext: {} + imageData: {} + vcs: {} + summary: {} +` diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/input.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/input.yaml new file mode 100644 index 000000000..69c2aab84 --- /dev/null +++ b/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/input.yaml @@ -0,0 +1,26 @@ +kind: AppInstance +apiVersion: internal.acorn.io/v1 +metadata: + generation: 2 + name: app-name + namespace: app-namespace + uid: 1234567890abcdef +spec: + image: test +status: + observedGeneration: 1 + namespace: app-created-namespace + appImage: + id: test + appSpec: + containers: + container-name: + image: "image-name" + dirs: + "/var/tmp": + volume: foo + defaults: + volumes: + foo: + class: test-volume-class + size: 4Gi diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-cluster-default/existing.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-cluster-default/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-cluster-default/existing.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-fill-cluster-default/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-cluster-default/expected.golden b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-cluster-default/expected.golden similarity index 86% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-cluster-default/expected.golden rename to pkg/controller/defaults/testdata/volumeclass/volume-class-fill-cluster-default/expected.golden index bd3f0886c..ced454b76 100644 --- a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-cluster-default/expected.golden +++ b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-cluster-default/expected.golden @@ -31,15 +31,11 @@ status: reason: Success status: "True" success: true - type: resolved-offerings - namespace: app-created-namespace - observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - container-name: - memory: 0 + type: defaults + defaults: + memory: + "": 0 + container-name: 0 region: local volumes: foo: @@ -47,6 +43,8 @@ status: - readWriteOnce class: test-volume-class size: 3Gi + namespace: app-created-namespace + observedGeneration: 1 staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-cluster-default/input.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-cluster-default/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-cluster-default/input.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-fill-cluster-default/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults-with-bind/existing.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults-with-bind/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults-with-bind/existing.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults-with-bind/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults-with-bind/expected.golden b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults-with-bind/expected.golden similarity index 84% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults-with-bind/expected.golden rename to pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults-with-bind/expected.golden index 5913f03e2..f604b7258 100644 --- a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults-with-bind/expected.golden +++ b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults-with-bind/expected.golden @@ -35,22 +35,19 @@ status: reason: Success status: "True" success: true - type: resolved-offerings - namespace: app-created-namespace - observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - container-name: - memory: 0 + type: defaults + defaults: + memory: + "": 0 + container-name: 0 region: local volumes: foo: accessModes: - readWriteOnce - class: test-volume-class size: 5Gi + namespace: app-created-namespace + observedGeneration: 1 staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults-with-bind/input.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults-with-bind/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults-with-bind/input.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults-with-bind/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults/existing.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults/existing.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults/expected.golden b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults/expected.golden similarity index 83% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults/expected.golden rename to pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults/expected.golden index c39ad7ff9..45fd223b6 100644 --- a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults/expected.golden +++ b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults/expected.golden @@ -32,22 +32,19 @@ status: reason: Success status: "True" success: true - type: resolved-offerings - namespace: app-created-namespace - observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - container-name: - memory: 0 + type: defaults + defaults: + memory: + "": 0 + container-name: 0 region: local volumes: foo: accessModes: - readWriteOnce - class: test-volume-class size: 2Gi + namespace: app-created-namespace + observedGeneration: 1 staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults/input.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults/input.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-project-default/existing.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-project-default/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-project-default/existing.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-fill-project-default/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-project-default/expected.golden b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-project-default/expected.golden similarity index 87% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-project-default/expected.golden rename to pkg/controller/defaults/testdata/volumeclass/volume-class-fill-project-default/expected.golden index 99652c695..9a87fb84b 100644 --- a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-project-default/expected.golden +++ b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-project-default/expected.golden @@ -31,15 +31,11 @@ status: reason: Success status: "True" success: true - type: resolved-offerings - namespace: app-created-namespace - observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - container-name: - memory: 0 + type: defaults + defaults: + memory: + "": 0 + container-name: 0 region: local volumes: foo: @@ -48,6 +44,8 @@ status: - readOnlyMany class: test-project-volume-class size: 2Gi + namespace: app-created-namespace + observedGeneration: 1 staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-project-default/input.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-project-default/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-project-default/input.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-fill-project-default/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-size/existing.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-size/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-size/existing.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-fill-size/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-size/expected.golden b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-size/expected.golden similarity index 80% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-size/expected.golden rename to pkg/controller/defaults/testdata/volumeclass/volume-class-fill-size/expected.golden index ef51350f8..9062fe05c 100644 --- a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-size/expected.golden +++ b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-size/expected.golden @@ -34,22 +34,17 @@ status: reason: Success status: "True" success: true - type: resolved-offerings - namespace: app-created-namespace - observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - container-name: - memory: 0 + type: defaults + defaults: + memory: + "": 0 + container-name: 0 region: local volumes: foo: - accessModes: - - readWriteOnce - class: test-volume-class size: 2Gi + namespace: app-created-namespace + observedGeneration: 1 staged: appImage: buildContext: {} diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-size/input.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-size/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-size/input.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-fill-size/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-cluster-defaults/existing.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-two-cluster-defaults/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-cluster-defaults/existing.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-two-cluster-defaults/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-project-defaults/expected.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-two-cluster-defaults/expected.yaml similarity index 74% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-project-defaults/expected.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-two-cluster-defaults/expected.yaml index c62bd0c6c..d8b5915a0 100644 --- a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-project-defaults/expected.yaml +++ b/pkg/controller/defaults/testdata/volumeclass/volume-class-two-cluster-defaults/expected.yaml @@ -22,7 +22,7 @@ status: foo: {} conditions: - error: true - message: 'cannot resolve volume classes because two defaults volume classes exist: test-volume-class and test-volume-class-1' + message: 'cannot establish defaults because two defaults volume classes exist: test-volume-class and test-volume-class-1' reason: Error status: "False" - type: resolved-offerings + type: defaults diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-cluster-defaults/input.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-two-cluster-defaults/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-cluster-defaults/input.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-two-cluster-defaults/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-project-defaults/existing.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-two-project-defaults/existing.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-project-defaults/existing.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-two-project-defaults/existing.yaml diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-cluster-defaults/expected.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-two-project-defaults/expected.yaml similarity index 74% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-cluster-defaults/expected.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-two-project-defaults/expected.yaml index c62bd0c6c..d8b5915a0 100644 --- a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-cluster-defaults/expected.yaml +++ b/pkg/controller/defaults/testdata/volumeclass/volume-class-two-project-defaults/expected.yaml @@ -22,7 +22,7 @@ status: foo: {} conditions: - error: true - message: 'cannot resolve volume classes because two defaults volume classes exist: test-volume-class and test-volume-class-1' + message: 'cannot establish defaults because two defaults volume classes exist: test-volume-class and test-volume-class-1' reason: Error status: "False" - type: resolved-offerings + type: defaults diff --git a/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-project-defaults/input.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-two-project-defaults/input.yaml similarity index 100% rename from pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-project-defaults/input.yaml rename to pkg/controller/defaults/testdata/volumeclass/volume-class-two-project-defaults/input.yaml diff --git a/pkg/controller/defaults/volumeclass.go b/pkg/controller/defaults/volumeclass.go new file mode 100644 index 000000000..b841d81b1 --- /dev/null +++ b/pkg/controller/defaults/volumeclass.go @@ -0,0 +1,95 @@ +package defaults + +import ( + "context" + "fmt" + + "github.com/acorn-io/baaah/pkg/typed" + v1 "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1" + "github.com/acorn-io/runtime/pkg/config" + "github.com/acorn-io/runtime/pkg/volume" + kclient "sigs.k8s.io/controller-runtime/pkg/client" +) + +func addVolumeClassDefaults(ctx context.Context, c kclient.Client, app *v1.AppInstance) error { + if len(app.Status.AppSpec.Volumes) == 0 { + return nil + } + + volumeClasses, defaultVolumeClass, err := volume.GetVolumeClassInstances(ctx, c, app.Namespace) + if err != nil { + return err + } + + for _, entry := range typed.Sorted(volumeClasses) { + vc := entry.Value + if vc.Default && vc.Name != defaultVolumeClass.Name { + return fmt.Errorf("cannot establish defaults because two defaults volume classes exist: %s and %s", defaultVolumeClass.Name, vc.Name) + } + } + + if app.Status.Defaults.Volumes == nil { + app.Status.Defaults.Volumes = make(map[string]v1.VolumeDefault) + } + + volumeBindings := volume.SliceToMap(app.Spec.Volumes, func(vb v1.VolumeBinding) string { + return vb.Target + }) + + for name, vol := range app.Status.AppSpec.Volumes { + volDefaults := app.Status.Defaults.Volumes[name] + vol = volume.CopyVolumeDefaults(vol, volumeBindings[name], volDefaults) + + // This is a bit of a hack as we're migrating away from the VolumeSize field. Essentially, + // we want to ensure that app.Status.Volumes[name] always has a size set. If the VolumeSize + // field has been set in the past, we want to mirgrate that over to be set on app.Status.Volumes[name]. + // There is another edge case where the Size field was set by a VolumeClass's default size. In this + // case we want to leave the Size field alone. + if app.Status.Defaults.VolumeSize != nil && volDefaults.Size == "" { + volDefaults.Size = v1.Quantity(app.Status.Defaults.VolumeSize.String()) + } + + // If the Volume already has defaults, skip these steps. We don't want to overwrite + // default class or access modes for volumes as it can lead to unexpected behavior when + // volume classes are updated. + if _, alreadySet := app.Status.Defaults.Volumes[name]; !alreadySet { + if vol.Class == "" && defaultVolumeClass != nil { + volDefaults.Class = defaultVolumeClass.Name + vol.Class = volDefaults.Class + } + if len(vol.AccessModes) == 0 { + volDefaults.AccessModes = volumeClasses[vol.Class].AllowedAccessModes + } + if vol.Size == "" { + volDefaults.Size = volumeClasses[vol.Class].Size.Default + if volDefaults.Size == "" { + defaultSize, err := getDefaultVolumeSize(ctx, c) + if err != nil { + return err + } + volDefaults.Size = defaultSize + } + } + } + + app.Status.Defaults.Volumes[name] = volDefaults + } + + return nil +} + +func getDefaultVolumeSize(ctx context.Context, c kclient.Client) (v1.Quantity, error) { + cfg, err := config.Get(ctx, c) + if err != nil { + return "", err + } + + // If the default volume size is set in the config, use that. Otherwise use the + // package level default in v1. + defaultVolumeSize := v1.DefaultSizeQuantity + if cfg.VolumeSizeDefault != "" { + defaultVolumeSize = v1.Quantity(cfg.VolumeSizeDefault) + } + + return defaultVolumeSize, nil +} diff --git a/pkg/controller/resolvedofferings/volumeclass_test.go b/pkg/controller/defaults/volumeclass_test.go similarity index 92% rename from pkg/controller/resolvedofferings/volumeclass_test.go rename to pkg/controller/defaults/volumeclass_test.go index 1392ea034..b0a97b143 100644 --- a/pkg/controller/resolvedofferings/volumeclass_test.go +++ b/pkg/controller/defaults/volumeclass_test.go @@ -1,4 +1,4 @@ -package resolvedofferings +package defaults import ( "testing" @@ -13,6 +13,10 @@ func TestCalculateSameGeneration(t *testing.T) { tester.DefaultTest(t, scheme.Scheme, "testdata/volumeclass/volume-class-defaults-same-gen", Calculate) } +func TestVolumeClassDefaultsSet(t *testing.T) { + tester.DefaultTest(t, scheme.Scheme, "testdata/volumeclass/volume-class-defaults-set", Calculate) +} + func TestFillVolumeClassDefaults(t *testing.T) { tester.DefaultTest(t, scheme.Scheme, "testdata/volumeclass/volume-class-fill-defaults", Calculate) } diff --git a/pkg/controller/quota/quota.go b/pkg/controller/quota/quota.go index ff4b39303..11834ed8a 100644 --- a/pkg/controller/quota/quota.go +++ b/pkg/controller/quota/quota.go @@ -179,7 +179,7 @@ func addStorage(req router.Request, appInstance *v1.AppInstance, quotaRequest *a case "0": continue case "": - sizeQuantity = resolvedVolumeSize(appInstance, name) + sizeQuantity = defaultVolumeSize(appInstance, name) default: parsedQuantity, err := resource.ParseQuantity(string(size)) if err != nil { @@ -202,17 +202,17 @@ func addStorage(req router.Request, appInstance *v1.AppInstance, quotaRequest *a return nil } -// resolvedVolumeSize determines the size of the specified volume. If the volume has a resolved size set -// on the status.ResolvedOfferings.Volumes, it uses that. Otherwise, it uses the default size in the v1 package. -func resolvedVolumeSize(appInstance *v1.AppInstance, name string) resource.Quantity { +// defaultVolumeSize determines the default size of the specified volume. If the volume has a default size set +// on the status.Defaults.Volumes, it uses that. Otherwise, it uses the default size set on the status.Defaults.VolumeSize. +func defaultVolumeSize(appInstance *v1.AppInstance, name string) resource.Quantity { // Use the v1.DefaultSize if the appInstance doesn't have a default size set on the status. result := *v1.DefaultSize // Safe to dereference because it is statically set in the v1 package. - // If the volume has a default size set on status.ResolvedOfferings.Volumes, use that. - if resolvedVolume, set := appInstance.Status.ResolvedOfferings.Volumes[name]; set { + // If the volume has a default size set on status.Defaults.Volumes, use that. + if defaultVolume, set := appInstance.Status.Defaults.Volumes[name]; set { // We do not expect this to ever fail because VolumeClasses have their sizes validated. However, // if it does fail, we'll just use the default size instead. - if parsedQuantity, err := resource.ParseQuantity(string(resolvedVolume.Size)); err == nil { + if parsedQuantity, err := resource.ParseQuantity(string(defaultVolume.Size)); err == nil { result = parsedQuantity } } diff --git a/pkg/controller/quota/testdata/status-default-volume-size/input.yaml b/pkg/controller/quota/testdata/status-default-volume-size/input.yaml index 719a19ad2..6b83f6d5b 100644 --- a/pkg/controller/quota/testdata/status-default-volume-size/input.yaml +++ b/pkg/controller/quota/testdata/status-default-volume-size/input.yaml @@ -39,9 +39,7 @@ status: volume-name: accessModes: - readWriteOnce - resolvedOfferings: + defaults: volumes: volume-name: size: 1Gi - accessModes: - - readWriteOnce diff --git a/pkg/controller/resolvedofferings/computeclass.go b/pkg/controller/resolvedofferings/computeclass.go deleted file mode 100644 index 9c7e1d48a..000000000 --- a/pkg/controller/resolvedofferings/computeclass.go +++ /dev/null @@ -1,123 +0,0 @@ -package resolvedofferings - -import ( - "github.com/acorn-io/baaah/pkg/router" - apiv1 "github.com/acorn-io/runtime/pkg/apis/api.acorn.io/v1" - v1 "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1" - adminv1 "github.com/acorn-io/runtime/pkg/apis/internal.admin.acorn.io/v1" - "github.com/acorn-io/runtime/pkg/computeclasses" - apierrors "k8s.io/apimachinery/pkg/api/errors" -) - -// resolveComputeClasses resolves the compute class information for each container in the AppInstance -func resolveComputeClasses(req router.Request, cfg *apiv1.Config, appInstance *v1.AppInstance) error { - if appInstance.Status.ResolvedOfferings.Containers == nil { - appInstance.Status.ResolvedOfferings.Containers = map[string]v1.ContainerResolvedOffering{} - } - - var ( - defaultCC string - err error - ) - if value, ok := appInstance.Spec.ComputeClasses[""]; ok { - defaultCC = value - } else { - defaultCC, err = adminv1.GetDefaultComputeClass(req.Ctx, req.Client, appInstance.Namespace) - if err != nil { - return err - } - } - - // Set the default for all containers, noted by the empty string - appInstance.Status.ResolvedOfferings.Containers[""] = v1.ContainerResolvedOffering{ - Memory: cfg.WorkloadMemoryDefault, - Class: defaultCC, - } - cc, err := computeclasses.GetAsProjectComputeClassInstance(req.Ctx, req.Client, appInstance.Status.Namespace, defaultCC) - if err != nil && !apierrors.IsNotFound(err) { - return err - } - - if cc != nil { - parsedMemory, err := computeclasses.ParseComputeClassMemory(cc.Memory) - if err != nil { - return err - } - def := parsedMemory.Def.Value() - appInstance.Status.ResolvedOfferings.Containers[""] = v1.ContainerResolvedOffering{ - Memory: &def, - CPUScaler: &cc.CPUScaler, - Class: appInstance.Status.ResolvedOfferings.Containers[""].Class, - } - } - - // Set the compute class info for each container and job individually - if err := resolveComputeClass(req, appInstance, cfg.WorkloadMemoryDefault, cc, defaultCC, appInstance.Status.AppSpec.Containers); err != nil { - return err - } - - if err := resolveComputeClass(req, appInstance, cfg.WorkloadMemoryDefault, cc, defaultCC, appInstance.Status.AppSpec.Jobs); err != nil { - return err - } - - return nil -} - -func resolveComputeClass(req router.Request, appInstance *v1.AppInstance, configDefault *int64, defaultCC *adminv1.ProjectComputeClassInstance, defaultCCName string, containers map[string]v1.Container) error { - for name, container := range containers { - var cpuScaler *float64 - ccName := "" - - // First, get the compute class for the workload - cc, err := computeclasses.GetClassForWorkload(req.Ctx, req.Client, appInstance.Spec.ComputeClasses, container, name, appInstance.Namespace) - if err != nil { - return err - } - if cc == nil { - cc = defaultCC - } - if cc != nil { - ccName = cc.Name - cpuScaler = &cc.CPUScaler - } else { - ccName = defaultCCName - } - - // Next, determine the memory request. This is the order of priority: - // 1. runtime-level overrides from the user (in app.Spec) - // 2. defaults in the acorn image - // 3. defaults from compute class - // 4. global default - - memory := configDefault // set to global default first, then check the higher priority values - - if containerMemoryOverride := appInstance.Spec.Memory[name]; containerMemoryOverride != nil { // runtime-level overrides from the user - memory = containerMemoryOverride - } else if container.Memory != nil { // defaults in the acorn image - memory = container.Memory - } else if cc != nil { // defaults from compute class - parsedMemory, err := computeclasses.ParseComputeClassMemory(cc.Memory) - if err != nil { - return err - } - def := parsedMemory.Def.Value() - memory = &def - } - - appInstance.Status.ResolvedOfferings.Containers[name] = v1.ContainerResolvedOffering{ - Class: ccName, - Memory: memory, - CPUScaler: cpuScaler, - } - - for sidecarName := range container.Sidecars { - appInstance.Status.ResolvedOfferings.Containers[sidecarName] = v1.ContainerResolvedOffering{ - Class: ccName, - Memory: memory, - CPUScaler: cpuScaler, - } - } - } - - return nil -} diff --git a/pkg/controller/resolvedofferings/computeclass_test.go b/pkg/controller/resolvedofferings/computeclass_test.go deleted file mode 100644 index 76cdfbed9..000000000 --- a/pkg/controller/resolvedofferings/computeclass_test.go +++ /dev/null @@ -1,86 +0,0 @@ -package resolvedofferings - -import ( - "testing" - - "github.com/acorn-io/baaah/pkg/router" - "github.com/acorn-io/baaah/pkg/router/tester" - "github.com/acorn-io/runtime/pkg/scheme" - "github.com/stretchr/testify/assert" -) - -func TestContainerMemory(t *testing.T) { - tester.DefaultTest(t, scheme.Scheme, "testdata/computeclass/container", Calculate) -} - -func TestSidecarMemory(t *testing.T) { - tester.DefaultTest(t, scheme.Scheme, "testdata/computeclass/sidecar", Calculate) -} - -func TestJobMemory(t *testing.T) { - tester.DefaultTest(t, scheme.Scheme, "testdata/computeclass/job", Calculate) -} - -func TestOverwriteAcornfileMemory(t *testing.T) { - tester.DefaultTest(t, scheme.Scheme, "testdata/computeclass/overwrite-acornfile-memory", Calculate) -} - -func TestWithAcornfileMemory(t *testing.T) { - tester.DefaultTest(t, scheme.Scheme, "testdata/computeclass/with-acornfile-memory", Calculate) -} - -func TestTwoContainers(t *testing.T) { - tester.DefaultTest(t, scheme.Scheme, "testdata/computeclass/two-containers", Calculate) -} - -func TestAllSet(t *testing.T) { - tester.DefaultTest(t, scheme.Scheme, "testdata/computeclass/all-set", Calculate) -} - -func TestAllSetOverwrite(t *testing.T) { - tester.DefaultTest(t, scheme.Scheme, "testdata/computeclass/all-set-overwrite", Calculate) -} - -func TestMemorySameGeneration(t *testing.T) { - tester.DefaultTest(t, scheme.Scheme, "testdata/computeclass/same-generation", Calculate) -} - -func TestTwoCCCDefaultsShouldError(t *testing.T) { - harness, input, err := tester.FromDir(scheme.Scheme, "testdata/computeclass/two-ccc-defaults-should-error") - if err != nil { - t.Fatal(err) - } - - resp, err := harness.Invoke(t, input, router.HandlerFunc(Calculate)) - if err != nil { - t.Fatal(err) - } - - assert.True(t, resp.NoPrune, "NoPrune should be true when error occurs") -} - -func TestTwoPCCDefaultsShouldError(t *testing.T) { - harness, input, err := tester.FromDir(scheme.Scheme, "testdata/computeclass/two-pcc-defaults-should-error") - if err != nil { - t.Fatal(err) - } - - resp, err := harness.Invoke(t, input, router.HandlerFunc(Calculate)) - if err != nil { - t.Fatal(err) - } - - assert.True(t, resp.NoPrune, "NoPrune should be true when error occurs") -} - -func TestComputeClassDefault(t *testing.T) { - tester.DefaultTest(t, scheme.Scheme, "testdata/computeclass/compute-class-default", Calculate) -} - -func TestAcornfileOverrideComputeClass(t *testing.T) { - tester.DefaultTest(t, scheme.Scheme, "testdata/computeclass/acornfile-override-compute-class", Calculate) -} - -func TestUserOverrideComputeClass(t *testing.T) { - tester.DefaultTest(t, scheme.Scheme, "testdata/computeclass/user-override-compute-class", Calculate) -} diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/existing.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/existing.yaml deleted file mode 100644 index 1f862ac4e..000000000 --- a/pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/existing.yaml +++ /dev/null @@ -1,31 +0,0 @@ -kind: ProjectInstance -apiVersion: internal.acorn.io/v1 -metadata: - name: app-namespace -spec: {} -status: - defaultRegion: local - supportedRegions: - - local ---- -kind: ProjectComputeClassInstance -apiVersion: internal.admin.acorn.io/v1 -metadata: - name: sample-compute-class - namespace: app-namespace -description: Simple description for a simple ComputeClass -cpuScaler: 0.25 -default: true -memory: - min: 1Mi # 1Mi - max: 2Mi # 2Mi - default: 1Mi # 1Mi -affinity: - nodeAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - nodeSelectorTerms: - - matchExpressions: - - key: foo - operator: In - values: - - bar \ No newline at end of file diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/expected.golden b/pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/expected.golden deleted file mode 100644 index ffcd45b41..000000000 --- a/pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/expected.golden +++ /dev/null @@ -1,68 +0,0 @@ -`apiVersion: internal.acorn.io/v1 -kind: AppInstance -metadata: - creationTimestamp: null - name: app-name - namespace: app-namespace - uid: 1234567890abcdef -spec: - image: test -status: - appImage: - buildContext: {} - id: test - imageData: {} - vcs: {} - appSpec: - containers: - oneimage: - build: - context: . - dockerfile: Dockerfile - image: image-name - memory: 2097152 - metrics: {} - ports: - - port: 80 - protocol: http - targetPort: 81 - probes: null - sidecars: - left: - image: foo - metrics: {} - ports: - - port: 90 - protocol: tcp - targetPort: 91 - probes: null - appStatus: {} - columns: {} - conditions: - reason: Success - status: "True" - success: true - type: resolved-offerings - namespace: app-created-namespace - observedGeneration: 1 - resolvedOfferings: - containers: - "": - class: sample-compute-class - memory: 0 - left: - class: sample-compute-class - cpuScaler: 0.25 - memory: 2097152 - oneimage: - class: sample-compute-class - cpuScaler: 0.25 - memory: 2097152 - region: local - staged: - appImage: - buildContext: {} - imageData: {} - vcs: {} - summary: {} -` diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/input.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/input.yaml deleted file mode 100644 index 140ee5c17..000000000 --- a/pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/input.yaml +++ /dev/null @@ -1,32 +0,0 @@ -kind: AppInstance -apiVersion: internal.acorn.io/v1 -metadata: - name: app-name - namespace: app-namespace - uid: 1234567890abcdef -spec: - image: test -status: - observedGeneration: 1 - namespace: app-created-namespace - appImage: - id: test - appSpec: - containers: - oneimage: - sidecars: - left: - image: "foo" - ports: - - port: 90 - targetPort: 91 - protocol: tcp - ports: - - port: 80 - targetPort: 81 - protocol: http - image: "image-name" - build: - dockerfile: "Dockerfile" - context: "." - memory: 2097152 # 2Mi diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/all-set-overwrite/expected.golden b/pkg/controller/resolvedofferings/testdata/computeclass/all-set-overwrite/expected.golden deleted file mode 100644 index 4044306a7..000000000 --- a/pkg/controller/resolvedofferings/testdata/computeclass/all-set-overwrite/expected.golden +++ /dev/null @@ -1,65 +0,0 @@ -`apiVersion: internal.acorn.io/v1 -kind: AppInstance -metadata: - creationTimestamp: null - name: app-name - namespace: app-namespace - uid: 1234567890abcdef -spec: - image: test - memory: - "": 1048576 - oneimage: 2097152 -status: - appImage: - buildContext: {} - id: test - imageData: {} - vcs: {} - appSpec: - containers: - oneimage: - build: - context: . - dockerfile: Dockerfile - image: image-name - metrics: {} - ports: - - port: 80 - protocol: http - targetPort: 81 - probes: null - sidecars: - left: - image: foo - metrics: {} - ports: - - port: 90 - protocol: tcp - targetPort: 91 - probes: null - appStatus: {} - columns: {} - conditions: - reason: Success - status: "True" - success: true - type: resolved-offerings - namespace: app-created-namespace - observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 2097152 - oneimage: - memory: 2097152 - region: local - staged: - appImage: - buildContext: {} - imageData: {} - vcs: {} - summary: {} -` diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/existing.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/existing.yaml deleted file mode 100644 index 1f862ac4e..000000000 --- a/pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/existing.yaml +++ /dev/null @@ -1,31 +0,0 @@ -kind: ProjectInstance -apiVersion: internal.acorn.io/v1 -metadata: - name: app-namespace -spec: {} -status: - defaultRegion: local - supportedRegions: - - local ---- -kind: ProjectComputeClassInstance -apiVersion: internal.admin.acorn.io/v1 -metadata: - name: sample-compute-class - namespace: app-namespace -description: Simple description for a simple ComputeClass -cpuScaler: 0.25 -default: true -memory: - min: 1Mi # 1Mi - max: 2Mi # 2Mi - default: 1Mi # 1Mi -affinity: - nodeAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - nodeSelectorTerms: - - matchExpressions: - - key: foo - operator: In - values: - - bar \ No newline at end of file diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/expected.golden b/pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/expected.golden deleted file mode 100644 index 6f0e38aa8..000000000 --- a/pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/expected.golden +++ /dev/null @@ -1,67 +0,0 @@ -`apiVersion: internal.acorn.io/v1 -kind: AppInstance -metadata: - creationTimestamp: null - name: app-name - namespace: app-namespace - uid: 1234567890abcdef -spec: - image: test -status: - appImage: - buildContext: {} - id: test - imageData: {} - vcs: {} - appSpec: - containers: - oneimage: - build: - context: . - dockerfile: Dockerfile - image: image-name - metrics: {} - ports: - - port: 80 - protocol: http - targetPort: 81 - probes: null - sidecars: - left: - image: foo - metrics: {} - ports: - - port: 90 - protocol: tcp - targetPort: 91 - probes: null - appStatus: {} - columns: {} - conditions: - reason: Success - status: "True" - success: true - type: resolved-offerings - namespace: app-created-namespace - observedGeneration: 1 - resolvedOfferings: - containers: - "": - class: sample-compute-class - memory: 0 - left: - class: sample-compute-class - cpuScaler: 0.25 - memory: 1048576 - oneimage: - class: sample-compute-class - cpuScaler: 0.25 - memory: 1048576 - region: local - staged: - appImage: - buildContext: {} - imageData: {} - vcs: {} - summary: {} -` diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/input.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/input.yaml deleted file mode 100644 index 701e1c7c8..000000000 --- a/pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/input.yaml +++ /dev/null @@ -1,31 +0,0 @@ -kind: AppInstance -apiVersion: internal.acorn.io/v1 -metadata: - name: app-name - namespace: app-namespace - uid: 1234567890abcdef -spec: - image: test -status: - observedGeneration: 1 - namespace: app-created-namespace - appImage: - id: test - appSpec: - containers: - oneimage: - sidecars: - left: - image: "foo" - ports: - - port: 90 - targetPort: 91 - protocol: tcp - ports: - - port: 80 - targetPort: 81 - protocol: http - image: "image-name" - build: - dockerfile: "Dockerfile" - context: "." diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/existing.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/existing.yaml deleted file mode 100644 index ebad9b6a8..000000000 --- a/pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/existing.yaml +++ /dev/null @@ -1,31 +0,0 @@ -kind: ProjectInstance -apiVersion: internal.acorn.io/v1 -metadata: - name: app-namespace -spec: {} -status: - defaultRegion: local - supportedRegions: - - local ---- -kind: ProjectComputeClassInstance -apiVersion: internal.admin.acorn.io/v1 -metadata: - name: sample-compute-class - namespace: app-namespace -description: Simple description for a simple ComputeClass -cpuScaler: 0.25 -default: true -memory: - min: 1Mi # 1Mi - max: 3Mi # 2Mi - default: 1Mi # 1Mi -affinity: - nodeAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - nodeSelectorTerms: - - matchExpressions: - - key: foo - operator: In - values: - - bar \ No newline at end of file diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/expected.golden b/pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/expected.golden deleted file mode 100644 index 3089c0eeb..000000000 --- a/pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/expected.golden +++ /dev/null @@ -1,70 +0,0 @@ -`apiVersion: internal.acorn.io/v1 -kind: AppInstance -metadata: - creationTimestamp: null - name: app-name - namespace: app-namespace - uid: 1234567890abcdef -spec: - image: test - memory: - oneimage: 3145728 -status: - appImage: - buildContext: {} - id: test - imageData: {} - vcs: {} - appSpec: - containers: - oneimage: - build: - context: . - dockerfile: Dockerfile - image: image-name - memory: 2097152 - metrics: {} - ports: - - port: 80 - protocol: http - targetPort: 81 - probes: null - sidecars: - left: - image: foo - metrics: {} - ports: - - port: 90 - protocol: tcp - targetPort: 91 - probes: null - appStatus: {} - columns: {} - conditions: - reason: Success - status: "True" - success: true - type: resolved-offerings - namespace: app-created-namespace - observedGeneration: 1 - resolvedOfferings: - containers: - "": - class: sample-compute-class - memory: 0 - left: - class: sample-compute-class - cpuScaler: 0.25 - memory: 3145728 - oneimage: - class: sample-compute-class - cpuScaler: 0.25 - memory: 3145728 - region: local - staged: - appImage: - buildContext: {} - imageData: {} - vcs: {} - summary: {} -` diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/input.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/input.yaml deleted file mode 100644 index 4871266e5..000000000 --- a/pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/input.yaml +++ /dev/null @@ -1,34 +0,0 @@ -kind: AppInstance -apiVersion: internal.acorn.io/v1 -metadata: - name: app-name - namespace: app-namespace - uid: 1234567890abcdef -spec: - image: test - memory: - oneimage: 3145728 # 3Mi -status: - observedGeneration: 1 - namespace: app-created-namespace - appImage: - id: test - appSpec: - containers: - oneimage: - sidecars: - left: - image: "foo" - ports: - - port: 90 - targetPort: 91 - protocol: tcp - ports: - - port: 80 - targetPort: 81 - protocol: http - image: "image-name" - build: - dockerfile: "Dockerfile" - context: "." - memory: 2097152 # 2Mi diff --git a/pkg/controller/resolvedofferings/volumeclass.go b/pkg/controller/resolvedofferings/volumeclass.go deleted file mode 100644 index 4e4fe9cc5..000000000 --- a/pkg/controller/resolvedofferings/volumeclass.go +++ /dev/null @@ -1,99 +0,0 @@ -package resolvedofferings - -import ( - "context" - "fmt" - - "github.com/acorn-io/baaah/pkg/typed" - internalv1 "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1" - "github.com/acorn-io/runtime/pkg/labels" - "github.com/acorn-io/runtime/pkg/volume" - corev1 "k8s.io/api/core/v1" - klabels "k8s.io/apimachinery/pkg/labels" - kclient "sigs.k8s.io/controller-runtime/pkg/client" -) - -func resolveVolumeClasses(ctx context.Context, c kclient.Client, app *internalv1.AppInstance) error { - if len(app.Status.AppSpec.Volumes) == 0 { - return nil - } - - volumeClasses, defaultVolumeClass, err := volume.GetVolumeClassInstances(ctx, c, app.Namespace) - if err != nil { - return err - } - - for _, entry := range typed.Sorted(volumeClasses) { - vc := entry.Value - if vc.Default && vc.Name != defaultVolumeClass.Name { - return fmt.Errorf("cannot resolve volume classes because two defaults volume classes exist: %s and %s", defaultVolumeClass.Name, vc.Name) - } - } - - if app.Status.ResolvedOfferings.Volumes == nil { - app.Status.ResolvedOfferings.Volumes = make(map[string]internalv1.VolumeResolvedOffering) - } - - volumeBindings := volume.SliceToMap(app.Spec.Volumes, func(vb internalv1.VolumeBinding) string { - return vb.Target - }) - - for name, vol := range app.Status.AppSpec.Volumes { - vol, err = volume.ResolveVolumeRequest(ctx, c, vol, volumeBindings[name], volumeClasses, defaultVolumeClass, app.Status.ResolvedOfferings.Volumes[name]) - if err != nil { - return err - } - resolvedVolume := internalv1.VolumeResolvedOffering{ - AccessModes: vol.AccessModes, - Class: vol.Class, - Size: vol.Size, - } - - // If an existing volume is bound to this volume request, then find it and use its values as the resolved offerings - if volumeBindings[name].Volume != "" { - // Try to find the volume by public name first - var boundVolumeList corev1.PersistentVolumeList - if err := c.List(ctx, &boundVolumeList, &kclient.ListOptions{ - LabelSelector: klabels.SelectorFromSet(map[string]string{ - labels.AcornPublicName: volumeBindings[name].Volume, - labels.AcornAppNamespace: app.Namespace, - labels.AcornManaged: "true", - }), - }); err != nil { - return fmt.Errorf("error while looking for bound volume %s in namespace %s: %w", volumeBindings[name].Volume, app.Namespace, err) - } else if len(boundVolumeList.Items) == 0 { - // See if the user provided a PV name instead - var boundPV corev1.PersistentVolume - if err := c.Get(ctx, kclient.ObjectKey{Name: volumeBindings[name].Volume}, &boundPV); err != nil { - return fmt.Errorf("error while looking for bound volume %s in namespace %s: %w", volumeBindings[name].Volume, app.Namespace, err) - } else if boundPV.ObjectMeta.Labels[labels.AcornAppNamespace] != app.Namespace { - return fmt.Errorf("could not find volume %s in project %s", volumeBindings[name].Volume, app.Namespace) - } - - boundVolumeList.Items = []corev1.PersistentVolume{boundPV} - } - - // If we found the volume, then use its values as the resolved offerings - if len(boundVolumeList.Items) == 1 { - for _, a := range boundVolumeList.Items[0].Spec.AccessModes { - resolvedVolume.AccessModes = append(resolvedVolume.AccessModes, internalv1.AccessMode(a)) - } - resolvedVolume.Class = boundVolumeList.Items[0].ObjectMeta.Labels[labels.AcornVolumeClass] - resolvedVolume.Size = internalv1.Quantity(boundVolumeList.Items[0].Spec.Capacity.Storage().String()) - } - } - - // This is a bit of a hack as we're migrating away from the VolumeSize field. Essentially, - // we want to ensure that app.Status.Volumes[name] always has a size set. If the VolumeSize - // field has been set in the past, we want to migrate that over to be set on app.Status.Volumes[name]. - // There is another edge case where the Size field was set by a VolumeClass's default size. In this - // case we want to leave the Size field alone. - if app.Status.ResolvedOfferings.VolumeSize != nil && resolvedVolume.Size == "" { - resolvedVolume.Size = internalv1.Quantity(app.Status.ResolvedOfferings.VolumeSize.String()) - } - - app.Status.ResolvedOfferings.Volumes[name] = resolvedVolume - } - - return nil -} diff --git a/pkg/controller/routes.go b/pkg/controller/routes.go index 43a5b671e..fbbf9850d 100644 --- a/pkg/controller/routes.go +++ b/pkg/controller/routes.go @@ -12,6 +12,7 @@ import ( "github.com/acorn-io/runtime/pkg/controller/appstatus" "github.com/acorn-io/runtime/pkg/controller/builder" "github.com/acorn-io/runtime/pkg/controller/config" + "github.com/acorn-io/runtime/pkg/controller/defaults" "github.com/acorn-io/runtime/pkg/controller/devsession" "github.com/acorn-io/runtime/pkg/controller/eventinstance" "github.com/acorn-io/runtime/pkg/controller/gc" @@ -23,7 +24,6 @@ import ( "github.com/acorn-io/runtime/pkg/controller/permissions" "github.com/acorn-io/runtime/pkg/controller/pvc" "github.com/acorn-io/runtime/pkg/controller/quota" - "github.com/acorn-io/runtime/pkg/controller/resolvedofferings" "github.com/acorn-io/runtime/pkg/controller/scheduling" "github.com/acorn-io/runtime/pkg/controller/secrets" "github.com/acorn-io/runtime/pkg/controller/service" @@ -76,7 +76,7 @@ func routes(router *router.Router, cfg *rest.Config, registryTransport http.Roun // DeploySpec will create the namespace, so ensure it runs before anything that requires a namespace appHasNamespace := appRouter.Middleware(appdefinition.RequireNamespace, appdefinition.IgnoreTerminatingNamespace, appdefinition.FilterLabelsAndAnnotationsConfig) - appHasNamespace.HandlerFunc(resolvedofferings.Calculate) + appHasNamespace.HandlerFunc(defaults.Calculate) appHasNamespace.HandlerFunc(scheduling.Calculate) appHasNamespace.HandlerFunc(quota.EnsureQuotaRequest) appHasNamespace.HandlerFunc(quota.WaitForAllocation) @@ -106,10 +106,10 @@ func routes(router *router.Router, cfg *rest.Config, registryTransport http.Roun router.Type(&v1.ImageInstance{}).HandlerFunc(images.MigrateRemoteImages) - router.Type(&v1.BuilderInstance{}).HandlerFunc(resolvedofferings.SetDefaultRegion) + router.Type(&v1.BuilderInstance{}).HandlerFunc(defaults.SetDefaultRegion) router.Type(&v1.BuilderInstance{}).HandlerFunc(builder.DeployBuilder) - router.Type(&v1.AcornImageBuildInstance{}).HandlerFunc(resolvedofferings.SetDefaultRegion) + router.Type(&v1.AcornImageBuildInstance{}).HandlerFunc(defaults.SetDefaultRegion) router.Type(&v1.AcornImageBuildInstance{}).HandlerFunc(acornimagebuildinstance.MarkRecorded) router.Type(&v1.ServiceInstance{}).HandlerFunc(gc.GCOrphans) diff --git a/pkg/controller/scheduling/scheduling.go b/pkg/controller/scheduling/scheduling.go index 3c6686421..cded2eabf 100644 --- a/pkg/controller/scheduling/scheduling.go +++ b/pkg/controller/scheduling/scheduling.go @@ -157,10 +157,10 @@ func ResourceRequirements(req router.Request, app *v1.AppInstance, containerName requirements := &corev1.ResourceRequirements{Limits: corev1.ResourceList{}, Requests: corev1.ResourceList{}} var memDefault *int64 - if val := app.Status.ResolvedOfferings.Containers[containerName]; val.Memory != nil { - memDefault = val.Memory - } else if val := app.Status.ResolvedOfferings.Containers[""]; val.Memory != nil { - memDefault = val.Memory + if val, ok := app.Status.Defaults.Memory[containerName]; ok && val != nil { + memDefault = val + } else if val, ok := app.Status.Defaults.Memory[""]; ok && val != nil { + memDefault = val } memMax := cfg.WorkloadMemoryMaximum diff --git a/pkg/controller/scheduling/testdata/computeclass/all-set-overwrite-computeclass/expected.golden b/pkg/controller/scheduling/testdata/computeclass/all-set-overwrite-computeclass/expected.golden index 7f5d067aa..0a2cb4afb 100644 --- a/pkg/controller/scheduling/testdata/computeclass/all-set-overwrite-computeclass/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/all-set-overwrite-computeclass/expected.golden @@ -45,16 +45,13 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 2097152 + oneimage: 2097152 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 2097152 - oneimage: - memory: 2097152 scheduling: left: requirements: diff --git a/pkg/controller/scheduling/testdata/computeclass/all-set-overwrite-computeclass/input.yaml b/pkg/controller/scheduling/testdata/computeclass/all-set-overwrite-computeclass/input.yaml index e08dc0901..11cf4cbc3 100644 --- a/pkg/controller/scheduling/testdata/computeclass/all-set-overwrite-computeclass/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/all-set-overwrite-computeclass/input.yaml @@ -11,14 +11,11 @@ spec: oneimage: sample-compute-class-01 # 2Mi status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 2097152 # 2Mi - oneimage: - memory: 2097152 # 2Mi + defaults: + memory: + "": 0 + left: 2097152 # 2Mi + oneimage: 2097152 # 2Mi namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/scheduling/testdata/computeclass/all-set/expected.golden b/pkg/controller/scheduling/testdata/computeclass/all-set/expected.golden index 512047a02..92115fed7 100644 --- a/pkg/controller/scheduling/testdata/computeclass/all-set/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/all-set/expected.golden @@ -44,16 +44,13 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 1048576 + oneimage: 1048576 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: diff --git a/pkg/controller/scheduling/testdata/computeclass/all-set/input.yaml b/pkg/controller/scheduling/testdata/computeclass/all-set/input.yaml index 42954b1c1..7beaac334 100644 --- a/pkg/controller/scheduling/testdata/computeclass/all-set/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/all-set/input.yaml @@ -10,14 +10,11 @@ spec: "": sample-compute-class status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 # 1Mi - oneimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 + left: 1048576 # 1Mi + oneimage: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/scheduling/testdata/computeclass/container/expected.golden b/pkg/controller/scheduling/testdata/computeclass/container/expected.golden index c478281ab..88d74ed06 100644 --- a/pkg/controller/scheduling/testdata/computeclass/container/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/container/expected.golden @@ -44,16 +44,13 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 1048576 + oneimage: 1048576 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: diff --git a/pkg/controller/scheduling/testdata/computeclass/container/input.yaml b/pkg/controller/scheduling/testdata/computeclass/container/input.yaml index 89f9d50b1..87f825ae1 100644 --- a/pkg/controller/scheduling/testdata/computeclass/container/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/container/input.yaml @@ -10,17 +10,15 @@ spec: oneimage: sample-compute-class status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 # 1Mi - oneimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 + left: 1048576 # 1Mi + oneimage: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test + defaults: appSpec: containers: oneimage: diff --git a/pkg/controller/scheduling/testdata/computeclass/different-computeclass/expected.golden b/pkg/controller/scheduling/testdata/computeclass/different-computeclass/expected.golden index 3a073b235..690a372d8 100644 --- a/pkg/controller/scheduling/testdata/computeclass/different-computeclass/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/different-computeclass/expected.golden @@ -47,16 +47,13 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + oneimage: 2097152 + twoimage: 1048576 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - oneimage: - memory: 2097152 - twoimage: - memory: 1048576 scheduling: oneimage: affinity: diff --git a/pkg/controller/scheduling/testdata/computeclass/different-computeclass/input.yaml b/pkg/controller/scheduling/testdata/computeclass/different-computeclass/input.yaml index 64ec43c44..32b565c62 100644 --- a/pkg/controller/scheduling/testdata/computeclass/different-computeclass/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/different-computeclass/input.yaml @@ -11,14 +11,11 @@ spec: oneimage: sample-compute-class status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - oneimage: - memory: 2097152 # 2Mi - twoimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 + oneimage: 2097152 # 2Mi + twoimage: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/scheduling/testdata/computeclass/different-digest-generation/expected.golden b/pkg/controller/scheduling/testdata/computeclass/different-digest-generation/expected.golden index 1d2190001..b9a567d32 100644 --- a/pkg/controller/scheduling/testdata/computeclass/different-digest-generation/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/different-digest-generation/expected.golden @@ -45,16 +45,13 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 1048576 + oneimage: 1048576 namespace: app-created-namespace observedImageDigest: foo - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: diff --git a/pkg/controller/scheduling/testdata/computeclass/different-digest-generation/input.yaml b/pkg/controller/scheduling/testdata/computeclass/different-digest-generation/input.yaml index a1bdf7e45..dcc73eb10 100644 --- a/pkg/controller/scheduling/testdata/computeclass/different-digest-generation/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/different-digest-generation/input.yaml @@ -10,14 +10,11 @@ spec: oneimage: sample-compute-class status: observedImageDigest: foo - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 # 1Mi - oneimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 + left: 1048576 # 1Mi + oneimage: 1048576 # 1Mi namespace: app-created-namespace appImage: name: test diff --git a/pkg/controller/scheduling/testdata/computeclass/invalid-priority-class-should-error/expected.golden b/pkg/controller/scheduling/testdata/computeclass/invalid-priority-class-should-error/expected.golden index 046198097..0a1b8f50f 100644 --- a/pkg/controller/scheduling/testdata/computeclass/invalid-priority-class-should-error/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/invalid-priority-class-should-error/expected.golden @@ -44,16 +44,13 @@ status: reason: Error status: "False" type: scheduling + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 0 - oneimage: - memory: 0 scheduling: left: requirements: {} diff --git a/pkg/controller/scheduling/testdata/computeclass/invalid-priority-class-should-error/input.yaml b/pkg/controller/scheduling/testdata/computeclass/invalid-priority-class-should-error/input.yaml index 2247d8b9d..e4af313da 100644 --- a/pkg/controller/scheduling/testdata/computeclass/invalid-priority-class-should-error/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/invalid-priority-class-should-error/input.yaml @@ -7,14 +7,11 @@ metadata: spec: image: test status: - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 0 - oneimage: - memory: 0 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 observedGeneration: 1 namespace: app-created-namespace appImage: diff --git a/pkg/controller/scheduling/testdata/computeclass/job/expected.golden b/pkg/controller/scheduling/testdata/computeclass/job/expected.golden index fb72e0e8a..4fbf7b27b 100644 --- a/pkg/controller/scheduling/testdata/computeclass/job/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/job/expected.golden @@ -44,16 +44,13 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 1048576 + oneimage: 1048576 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: diff --git a/pkg/controller/scheduling/testdata/computeclass/job/input.yaml b/pkg/controller/scheduling/testdata/computeclass/job/input.yaml index a6ff9cccd..60dd79c1e 100644 --- a/pkg/controller/scheduling/testdata/computeclass/job/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/job/input.yaml @@ -10,14 +10,11 @@ spec: oneimage: sample-compute-class status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 # 1Mi - oneimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 + left: 1048576 # 1Mi + oneimage: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/scheduling/testdata/computeclass/overwrite-acornfile-computeclass/expected.golden b/pkg/controller/scheduling/testdata/computeclass/overwrite-acornfile-computeclass/expected.golden index 5811e6d4d..04436e2ec 100644 --- a/pkg/controller/scheduling/testdata/computeclass/overwrite-acornfile-computeclass/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/overwrite-acornfile-computeclass/expected.golden @@ -45,16 +45,13 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 1048576 + oneimage: 1048576 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: diff --git a/pkg/controller/scheduling/testdata/computeclass/overwrite-acornfile-computeclass/input.yaml b/pkg/controller/scheduling/testdata/computeclass/overwrite-acornfile-computeclass/input.yaml index bd6c9ec6d..d2c6e18f1 100644 --- a/pkg/controller/scheduling/testdata/computeclass/overwrite-acornfile-computeclass/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/overwrite-acornfile-computeclass/input.yaml @@ -10,14 +10,11 @@ spec: oneimage: sample-compute-class status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 # 1Mi - left: - memory: 1048576 # 1Mi - oneimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 # 1Mi + left: 1048576 # 1Mi + oneimage: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/scheduling/testdata/computeclass/priority-class/expected.golden b/pkg/controller/scheduling/testdata/computeclass/priority-class/expected.golden index 53aa9b8e9..637e03d17 100644 --- a/pkg/controller/scheduling/testdata/computeclass/priority-class/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/priority-class/expected.golden @@ -42,16 +42,13 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 0 - oneimage: - memory: 0 scheduling: left: requirements: {} diff --git a/pkg/controller/scheduling/testdata/computeclass/priority-class/input.yaml b/pkg/controller/scheduling/testdata/computeclass/priority-class/input.yaml index 2247d8b9d..e4af313da 100644 --- a/pkg/controller/scheduling/testdata/computeclass/priority-class/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/priority-class/input.yaml @@ -7,14 +7,11 @@ metadata: spec: image: test status: - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 0 - oneimage: - memory: 0 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 observedGeneration: 1 namespace: app-created-namespace appImage: diff --git a/pkg/controller/scheduling/testdata/computeclass/same-digest-generation/expected.golden b/pkg/controller/scheduling/testdata/computeclass/same-digest-generation/expected.golden index 11953e733..01362fc8f 100644 --- a/pkg/controller/scheduling/testdata/computeclass/same-digest-generation/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/same-digest-generation/expected.golden @@ -45,16 +45,13 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 1048576 + oneimage: 1048576 namespace: app-created-namespace observedImageDigest: foo - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: diff --git a/pkg/controller/scheduling/testdata/computeclass/same-digest-generation/input.yaml b/pkg/controller/scheduling/testdata/computeclass/same-digest-generation/input.yaml index c7b3809b5..de527cc4d 100644 --- a/pkg/controller/scheduling/testdata/computeclass/same-digest-generation/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/same-digest-generation/input.yaml @@ -10,14 +10,11 @@ spec: oneimage: sample-compute-class status: observedImageDigest: foo - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 # 1Mi - oneimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 + left: 1048576 # 1Mi + oneimage: 1048576 # 1Mi # In this test, scheduling has already been set and should not get recalculated # since the generation is the same. scheduling: diff --git a/pkg/controller/scheduling/testdata/computeclass/same-generation/expected.golden b/pkg/controller/scheduling/testdata/computeclass/same-generation/expected.golden index 35b457a5a..099032e78 100644 --- a/pkg/controller/scheduling/testdata/computeclass/same-generation/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/same-generation/expected.golden @@ -44,15 +44,12 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 1048576 + oneimage: 1048576 namespace: app-created-namespace - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: diff --git a/pkg/controller/scheduling/testdata/computeclass/same-generation/input.yaml b/pkg/controller/scheduling/testdata/computeclass/same-generation/input.yaml index e83805311..6b807c769 100644 --- a/pkg/controller/scheduling/testdata/computeclass/same-generation/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/same-generation/input.yaml @@ -9,14 +9,11 @@ spec: computeClass: oneimage: sample-compute-class status: - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 # 1Mi - oneimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 + left: 1048576 # 1Mi + oneimage: 1048576 # 1Mi # In this test, scheduling has already been set and should not get recalculated # since the generation is the same. scheduling: @@ -46,6 +43,7 @@ status: namespace: app-created-namespace appImage: id: test + defaults: appSpec: containers: oneimage: diff --git a/pkg/controller/scheduling/testdata/computeclass/sidecar/expected.yaml b/pkg/controller/scheduling/testdata/computeclass/sidecar/expected.yaml index fa991d2e2..8529f849a 100644 --- a/pkg/controller/scheduling/testdata/computeclass/sidecar/expected.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/sidecar/expected.yaml @@ -9,10 +9,9 @@ spec: computeClass: left: sample-compute-class status: - resolvedOfferings: - containers: - left: - memory: 1048576 # 1Mi + defaults: + memory: + left: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/scheduling/testdata/computeclass/sidecar/input.yaml b/pkg/controller/scheduling/testdata/computeclass/sidecar/input.yaml index cb33defaf..c770ce0dc 100644 --- a/pkg/controller/scheduling/testdata/computeclass/sidecar/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/sidecar/input.yaml @@ -9,10 +9,9 @@ spec: computeClass: left: sample-compute-class status: - resolvedOfferings: - containers: - left: - memory: 1048576 # 1Mi + defaults: + memory: + left: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/scheduling/testdata/computeclass/two-ccc-defaults-should-error/expected.yaml b/pkg/controller/scheduling/testdata/computeclass/two-ccc-defaults-should-error/expected.yaml index a3873c96a..54416cac0 100644 --- a/pkg/controller/scheduling/testdata/computeclass/two-ccc-defaults-should-error/expected.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/two-ccc-defaults-should-error/expected.yaml @@ -10,14 +10,11 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 # 1Mi - oneimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 + left: 1048576 # 1Mi + oneimage: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/scheduling/testdata/computeclass/two-ccc-defaults-should-error/input.yaml b/pkg/controller/scheduling/testdata/computeclass/two-ccc-defaults-should-error/input.yaml index b79fed85b..15b4b2241 100644 --- a/pkg/controller/scheduling/testdata/computeclass/two-ccc-defaults-should-error/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/two-ccc-defaults-should-error/input.yaml @@ -9,14 +9,11 @@ spec: memory: oneimage: 1048576 # 1Mi status: - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 # 1Mi - oneimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 + left: 1048576 # 1Mi + oneimage: 1048576 # 1Mi observedGeneration: 1 namespace: app-created-namespace appImage: diff --git a/pkg/controller/scheduling/testdata/computeclass/two-containers/expected.golden b/pkg/controller/scheduling/testdata/computeclass/two-containers/expected.golden index 64c589d6f..648117340 100644 --- a/pkg/controller/scheduling/testdata/computeclass/two-containers/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/two-containers/expected.golden @@ -46,16 +46,13 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + oneimage: 1048576 + twoimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - oneimage: - memory: 1048576 - twoimage: - memory: 0 scheduling: oneimage: affinity: diff --git a/pkg/controller/scheduling/testdata/computeclass/two-containers/input.yaml b/pkg/controller/scheduling/testdata/computeclass/two-containers/input.yaml index 7d8a6c184..da4ee1770 100644 --- a/pkg/controller/scheduling/testdata/computeclass/two-containers/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/two-containers/input.yaml @@ -10,14 +10,11 @@ spec: oneimage: sample-compute-class status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - oneimage: - memory: 1048576 # 1Mi - twoimage: - memory: 0 + defaults: + memory: + "": 0 + oneimage: 1048576 # 1Mi + twoimage: 0 namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/scheduling/testdata/computeclass/two-pcc-defaults-should-error/expected.yaml b/pkg/controller/scheduling/testdata/computeclass/two-pcc-defaults-should-error/expected.yaml index 4fd991694..a603062f3 100644 --- a/pkg/controller/scheduling/testdata/computeclass/two-pcc-defaults-should-error/expected.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/two-pcc-defaults-should-error/expected.yaml @@ -9,14 +9,11 @@ spec: memory: oneimage: 1048576 # 1Mi status: - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 # 1Mi - oneimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 + left: 1048576 # 1Mi + oneimage: 1048576 # 1Mi observedGeneration: 1 namespace: app-created-namespace appImage: diff --git a/pkg/controller/scheduling/testdata/computeclass/two-pcc-defaults-should-error/input.yaml b/pkg/controller/scheduling/testdata/computeclass/two-pcc-defaults-should-error/input.yaml index b79fed85b..15b4b2241 100644 --- a/pkg/controller/scheduling/testdata/computeclass/two-pcc-defaults-should-error/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/two-pcc-defaults-should-error/input.yaml @@ -9,14 +9,11 @@ spec: memory: oneimage: 1048576 # 1Mi status: - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 # 1Mi - oneimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 + left: 1048576 # 1Mi + oneimage: 1048576 # 1Mi observedGeneration: 1 namespace: app-created-namespace appImage: diff --git a/pkg/controller/scheduling/testdata/computeclass/with-acornfile-computeclass/expected.golden b/pkg/controller/scheduling/testdata/computeclass/with-acornfile-computeclass/expected.golden index 92c5593c7..ffbcfb00f 100644 --- a/pkg/controller/scheduling/testdata/computeclass/with-acornfile-computeclass/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/with-acornfile-computeclass/expected.golden @@ -43,16 +43,13 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 1048576 + oneimage: 1048576 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: diff --git a/pkg/controller/scheduling/testdata/computeclass/with-acornfile-computeclass/input.yaml b/pkg/controller/scheduling/testdata/computeclass/with-acornfile-computeclass/input.yaml index c2d7eaf3c..f9b0016b2 100644 --- a/pkg/controller/scheduling/testdata/computeclass/with-acornfile-computeclass/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/with-acornfile-computeclass/input.yaml @@ -8,14 +8,11 @@ spec: image: test status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 # 1Mi - left: - memory: 1048576 # 1Mi - oneimage: - memory: 1048576 # 1Mi + defaults: + memory: + "": 0 # 1Mi + left: 1048576 # 1Mi + oneimage: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/scheduling/testdata/memory/all-set-overwrite/expected.golden b/pkg/controller/scheduling/testdata/memory/all-set-overwrite/expected.golden index a7aacea7a..215d2dc70 100644 --- a/pkg/controller/scheduling/testdata/memory/all-set-overwrite/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/all-set-overwrite/expected.golden @@ -45,16 +45,13 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 1048576 - left: - memory: 2097152 - oneimage: - memory: 2097152 scheduling: left: requirements: diff --git a/pkg/controller/scheduling/testdata/memory/all-set-overwrite/input.yaml b/pkg/controller/scheduling/testdata/memory/all-set-overwrite/input.yaml index 0b2f416a8..186126455 100644 --- a/pkg/controller/scheduling/testdata/memory/all-set-overwrite/input.yaml +++ b/pkg/controller/scheduling/testdata/memory/all-set-overwrite/input.yaml @@ -11,14 +11,11 @@ spec: oneimage: 2097152 # 2Mi status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 1048576 - left: - memory: 2097152 - oneimage: - memory: 2097152 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/scheduling/testdata/memory/all-set/expected.golden b/pkg/controller/scheduling/testdata/memory/all-set/expected.golden index 4ad6dac9c..d2ebab294 100644 --- a/pkg/controller/scheduling/testdata/memory/all-set/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/all-set/expected.golden @@ -44,16 +44,13 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 1048576 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: diff --git a/pkg/controller/scheduling/testdata/memory/all-set/input.yaml b/pkg/controller/scheduling/testdata/memory/all-set/input.yaml index 175a2f2e9..147bac977 100644 --- a/pkg/controller/scheduling/testdata/memory/all-set/input.yaml +++ b/pkg/controller/scheduling/testdata/memory/all-set/input.yaml @@ -10,14 +10,11 @@ spec: "": 1048576 # 1Mi status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 1048576 - left: - memory: 1048576 - oneimage: - memory: 1048576 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/scheduling/testdata/memory/container/expected.golden b/pkg/controller/scheduling/testdata/memory/container/expected.golden index d04d03c82..d31531e73 100644 --- a/pkg/controller/scheduling/testdata/memory/container/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/container/expected.golden @@ -44,23 +44,16 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: - requirements: - limits: - memory: 1Mi - requests: - memory: 1Mi + requirements: {} oneimage: requirements: limits: diff --git a/pkg/controller/scheduling/testdata/memory/container/input.yaml b/pkg/controller/scheduling/testdata/memory/container/input.yaml index dd46be237..96e9aa9c2 100644 --- a/pkg/controller/scheduling/testdata/memory/container/input.yaml +++ b/pkg/controller/scheduling/testdata/memory/container/input.yaml @@ -10,14 +10,11 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/scheduling/testdata/memory/job/expected.golden b/pkg/controller/scheduling/testdata/memory/job/expected.golden index 3f38bd32c..81eba6dca 100644 --- a/pkg/controller/scheduling/testdata/memory/job/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/job/expected.golden @@ -44,23 +44,16 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: - requirements: - limits: - memory: 1Mi - requests: - memory: 1Mi + requirements: {} oneimage: requirements: limits: diff --git a/pkg/controller/scheduling/testdata/memory/job/input.yaml b/pkg/controller/scheduling/testdata/memory/job/input.yaml index b59bdfc2a..ad4e1af34 100644 --- a/pkg/controller/scheduling/testdata/memory/job/input.yaml +++ b/pkg/controller/scheduling/testdata/memory/job/input.yaml @@ -10,14 +10,11 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/scheduling/testdata/memory/overwrite-acornfile-memory/expected.golden b/pkg/controller/scheduling/testdata/memory/overwrite-acornfile-memory/expected.golden index 66aaecfa0..816279731 100644 --- a/pkg/controller/scheduling/testdata/memory/overwrite-acornfile-memory/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/overwrite-acornfile-memory/expected.golden @@ -45,23 +45,16 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: - requirements: - limits: - memory: 1Mi - requests: - memory: 1Mi + requirements: {} oneimage: requirements: limits: diff --git a/pkg/controller/scheduling/testdata/memory/overwrite-acornfile-memory/input.yaml b/pkg/controller/scheduling/testdata/memory/overwrite-acornfile-memory/input.yaml index 35c60cccb..3515d3bf2 100644 --- a/pkg/controller/scheduling/testdata/memory/overwrite-acornfile-memory/input.yaml +++ b/pkg/controller/scheduling/testdata/memory/overwrite-acornfile-memory/input.yaml @@ -10,14 +10,11 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/scheduling/testdata/memory/same-generation/expected.golden b/pkg/controller/scheduling/testdata/memory/same-generation/expected.golden index 557833c01..c244d03de 100644 --- a/pkg/controller/scheduling/testdata/memory/same-generation/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/same-generation/expected.golden @@ -44,15 +44,12 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: requirements: {} diff --git a/pkg/controller/scheduling/testdata/memory/same-generation/input.yaml b/pkg/controller/scheduling/testdata/memory/same-generation/input.yaml index 6502d95cf..2324366d0 100644 --- a/pkg/controller/scheduling/testdata/memory/same-generation/input.yaml +++ b/pkg/controller/scheduling/testdata/memory/same-generation/input.yaml @@ -9,14 +9,11 @@ spec: memory: oneimage: 1048576 # 1Mi status: - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 # In this test, scheduling has already been set and should not get recalculated # since the generation is the same. scheduling: diff --git a/pkg/controller/scheduling/testdata/memory/sidecar/expected.golden b/pkg/controller/scheduling/testdata/memory/sidecar/expected.golden index c0cdf455e..19cbe99a0 100644 --- a/pkg/controller/scheduling/testdata/memory/sidecar/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/sidecar/expected.golden @@ -44,9 +44,9 @@ status: status: "True" success: true type: scheduling + defaults: {} namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: {} scheduling: left: requirements: diff --git a/pkg/controller/scheduling/testdata/memory/two-containers/expected.golden b/pkg/controller/scheduling/testdata/memory/two-containers/expected.golden index fc22f0a5d..653ca3172 100644 --- a/pkg/controller/scheduling/testdata/memory/two-containers/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/two-containers/expected.golden @@ -46,16 +46,13 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: oneimage: requirements: diff --git a/pkg/controller/scheduling/testdata/memory/two-containers/input.yaml b/pkg/controller/scheduling/testdata/memory/two-containers/input.yaml index 5d82fd3b3..57f19010c 100644 --- a/pkg/controller/scheduling/testdata/memory/two-containers/input.yaml +++ b/pkg/controller/scheduling/testdata/memory/two-containers/input.yaml @@ -10,14 +10,11 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/scheduling/testdata/memory/with-acornfile-memory/expected.golden b/pkg/controller/scheduling/testdata/memory/with-acornfile-memory/expected.golden index 267467dd2..8a78515e4 100644 --- a/pkg/controller/scheduling/testdata/memory/with-acornfile-memory/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/with-acornfile-memory/expected.golden @@ -43,23 +43,16 @@ status: status: "True" success: true type: scheduling + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 scheduling: left: - requirements: - limits: - memory: 1Mi - requests: - memory: 1Mi + requirements: {} oneimage: requirements: limits: diff --git a/pkg/controller/scheduling/testdata/memory/with-acornfile-memory/input.yaml b/pkg/controller/scheduling/testdata/memory/with-acornfile-memory/input.yaml index 5745280f7..403426169 100644 --- a/pkg/controller/scheduling/testdata/memory/with-acornfile-memory/input.yaml +++ b/pkg/controller/scheduling/testdata/memory/with-acornfile-memory/input.yaml @@ -8,14 +8,11 @@ spec: image: test status: observedGeneration: 1 - resolvedOfferings: - containers: - "": - memory: 0 - left: - memory: 1048576 - oneimage: - memory: 1048576 + defaults: + memory: + "": 0 + left: 0 + oneimage: 0 namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/scheduling/testdata/tolerations/container/expected.golden b/pkg/controller/scheduling/testdata/tolerations/container/expected.golden index 9d769b0a1..e04e1a4b4 100644 --- a/pkg/controller/scheduling/testdata/tolerations/container/expected.golden +++ b/pkg/controller/scheduling/testdata/tolerations/container/expected.golden @@ -42,9 +42,9 @@ status: status: "True" success: true type: scheduling + defaults: {} namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: {} scheduling: left: requirements: {} diff --git a/pkg/controller/scheduling/testdata/tolerations/container/input.yaml b/pkg/controller/scheduling/testdata/tolerations/container/input.yaml index 701e1c7c8..1d97481e4 100644 --- a/pkg/controller/scheduling/testdata/tolerations/container/input.yaml +++ b/pkg/controller/scheduling/testdata/tolerations/container/input.yaml @@ -11,6 +11,7 @@ status: namespace: app-created-namespace appImage: id: test + defaults: appSpec: containers: oneimage: diff --git a/pkg/controller/scheduling/testdata/tolerations/job/expected.golden b/pkg/controller/scheduling/testdata/tolerations/job/expected.golden index c825f1eb6..fedff8320 100644 --- a/pkg/controller/scheduling/testdata/tolerations/job/expected.golden +++ b/pkg/controller/scheduling/testdata/tolerations/job/expected.golden @@ -42,9 +42,9 @@ status: status: "True" success: true type: scheduling + defaults: {} namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: {} scheduling: left: requirements: {} diff --git a/pkg/controller/scheduling/testdata/tolerations/job/input.yaml b/pkg/controller/scheduling/testdata/tolerations/job/input.yaml index b115f940d..bd80e65ca 100644 --- a/pkg/controller/scheduling/testdata/tolerations/job/input.yaml +++ b/pkg/controller/scheduling/testdata/tolerations/job/input.yaml @@ -11,6 +11,7 @@ status: namespace: app-created-namespace appImage: id: test + defaults: appSpec: jobs: oneimage: diff --git a/pkg/labels/labels.go b/pkg/labels/labels.go index 1643f237a..cbcb114fd 100644 --- a/pkg/labels/labels.go +++ b/pkg/labels/labels.go @@ -61,7 +61,6 @@ const ( ProjectEnforcedQuotaAnnotation = Prefix + "enforced-quota" AcornPermissions = Prefix + "permissions" AcornConfigHashAnnotation = Prefix + "config-hash" - AcornContainerResolvedOfferings = Prefix + "container-resolved-offerings" IdentityPrefix = "identity." + Prefix AcornIdentityAccountServerURL = IdentityPrefix + "account-server-url" diff --git a/pkg/openapi/generated/openapi_generated.go b/pkg/openapi/generated/openapi_generated.go index 554f24d35..985f6ed93 100644 --- a/pkg/openapi/generated/openapi_generated.go +++ b/pkg/openapi/generated/openapi_generated.go @@ -137,8 +137,8 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.Container": schema_pkg_apis_internalacornio_v1_Container(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.ContainerData": schema_pkg_apis_internalacornio_v1_ContainerData(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.ContainerImageBuilderSpec": schema_pkg_apis_internalacornio_v1_ContainerImageBuilderSpec(ref), - "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.ContainerResolvedOffering": schema_pkg_apis_internalacornio_v1_ContainerResolvedOffering(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.ContainerStatus": schema_pkg_apis_internalacornio_v1_ContainerStatus(ref), + "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.Defaults": schema_pkg_apis_internalacornio_v1_Defaults(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.Dependency": schema_pkg_apis_internalacornio_v1_Dependency(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.DependencyNotFound": schema_pkg_apis_internalacornio_v1_DependencyNotFound(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.DependencyStatus": schema_pkg_apis_internalacornio_v1_DependencyStatus(ref), @@ -192,7 +192,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.ProjectInstanceSpec": schema_pkg_apis_internalacornio_v1_ProjectInstanceSpec(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.ProjectInstanceStatus": schema_pkg_apis_internalacornio_v1_ProjectInstanceStatus(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.ReplicasSummary": schema_pkg_apis_internalacornio_v1_ReplicasSummary(ref), - "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.ResolvedOfferings": schema_pkg_apis_internalacornio_v1_ResolvedOfferings(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.Route": schema_pkg_apis_internalacornio_v1_Route(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.Router": schema_pkg_apis_internalacornio_v1_Router(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.RouterStatus": schema_pkg_apis_internalacornio_v1_RouterStatus(ref), @@ -217,9 +216,9 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.UserContext": schema_pkg_apis_internalacornio_v1_UserContext(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.VCS": schema_pkg_apis_internalacornio_v1_VCS(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.VolumeBinding": schema_pkg_apis_internalacornio_v1_VolumeBinding(ref), + "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.VolumeDefault": schema_pkg_apis_internalacornio_v1_VolumeDefault(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.VolumeMount": schema_pkg_apis_internalacornio_v1_VolumeMount(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.VolumeRequest": schema_pkg_apis_internalacornio_v1_VolumeRequest(ref), - "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.VolumeResolvedOffering": schema_pkg_apis_internalacornio_v1_VolumeResolvedOffering(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.VolumeSecretMount": schema_pkg_apis_internalacornio_v1_VolumeSecretMount(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.VolumeStatus": schema_pkg_apis_internalacornio_v1_VolumeStatus(ref), "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.acornAliases": schema_pkg_apis_internalacornio_v1_acornAliases(ref), @@ -7016,10 +7015,10 @@ func schema_pkg_apis_internalacornio_v1_AppInstanceStatus(ref common.ReferenceCa }, }, }, - "resolvedOfferings": { + "defaults": { SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.ResolvedOfferings"), + Ref: ref("github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.Defaults"), }, }, "summary": { @@ -7059,7 +7058,7 @@ func schema_pkg_apis_internalacornio_v1_AppInstanceStatus(ref common.ReferenceCa }, }, Dependencies: []string{ - "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.AppColumns", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.AppImage", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.AppSpec", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.AppStatus", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.AppStatusStaged", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.CommonSummary", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.Condition", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.DevSessionInstanceSpec", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.Permissions", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.ResolvedOfferings", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.Scheduling"}, + "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.AppColumns", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.AppImage", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.AppSpec", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.AppStatus", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.AppStatusStaged", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.CommonSummary", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.Condition", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.Defaults", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.DevSessionInstanceSpec", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.Permissions", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.Scheduling"}, } } @@ -8487,36 +8486,6 @@ func schema_pkg_apis_internalacornio_v1_ContainerImageBuilderSpec(ref common.Ref } } -func schema_pkg_apis_internalacornio_v1_ContainerResolvedOffering(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "class": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - "memory": { - SchemaProps: spec.SchemaProps{ - Type: []string{"integer"}, - Format: "int64", - }, - }, - "cpuScaler": { - SchemaProps: spec.SchemaProps{ - Type: []string{"number"}, - Format: "double", - }, - }, - }, - }, - }, - } -} - func schema_pkg_apis_internalacornio_v1_ContainerStatus(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -8666,6 +8635,59 @@ func schema_pkg_apis_internalacornio_v1_ContainerStatus(ref common.ReferenceCall } } +func schema_pkg_apis_internalacornio_v1_Defaults(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "volumeSize": { + SchemaProps: spec.SchemaProps{ + Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), + }, + }, + "volumes": { + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.VolumeDefault"), + }, + }, + }, + }, + }, + "memory": { + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"integer"}, + Format: "int64", + }, + }, + }, + }, + }, + "region": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + Dependencies: []string{ + "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.VolumeDefault", "k8s.io/apimachinery/pkg/api/resource.Quantity"}, + } +} + func schema_pkg_apis_internalacornio_v1_Dependency(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -11004,59 +11026,6 @@ func schema_pkg_apis_internalacornio_v1_ReplicasSummary(ref common.ReferenceCall } } -func schema_pkg_apis_internalacornio_v1_ResolvedOfferings(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "volumes": { - SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, - AdditionalProperties: &spec.SchemaOrBool{ - Allows: true, - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.VolumeResolvedOffering"), - }, - }, - }, - }, - }, - "volumeSize": { - SchemaProps: spec.SchemaProps{ - Ref: ref("k8s.io/apimachinery/pkg/api/resource.Quantity"), - }, - }, - "containers": { - SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, - AdditionalProperties: &spec.SchemaOrBool{ - Allows: true, - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.ContainerResolvedOffering"), - }, - }, - }, - }, - }, - "region": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - }, - }, - }, - Dependencies: []string{ - "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.ContainerResolvedOffering", "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.VolumeResolvedOffering", "k8s.io/apimachinery/pkg/api/resource.Quantity"}, - } -} - func schema_pkg_apis_internalacornio_v1_Route(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -12750,6 +12719,44 @@ func schema_pkg_apis_internalacornio_v1_VolumeBinding(ref common.ReferenceCallba } } +func schema_pkg_apis_internalacornio_v1_VolumeDefault(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "class": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "size": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "accessModes": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + }, + }, + }, + } +} + func schema_pkg_apis_internalacornio_v1_VolumeMount(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -12874,44 +12881,6 @@ func schema_pkg_apis_internalacornio_v1_VolumeRequest(ref common.ReferenceCallba } } -func schema_pkg_apis_internalacornio_v1_VolumeResolvedOffering(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "class": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - "size": { - SchemaProps: spec.SchemaProps{ - Type: []string{"string"}, - Format: "", - }, - }, - "accessModes": { - SchemaProps: spec.SchemaProps{ - Type: []string{"array"}, - Items: &spec.SchemaOrArray{ - Schema: &spec.Schema{ - SchemaProps: spec.SchemaProps{ - Default: "", - Type: []string{"string"}, - Format: "", - }, - }, - }, - }, - }, - }, - }, - }, - } -} - func schema_pkg_apis_internalacornio_v1_VolumeSecretMount(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/pkg/server/registry/apigroups/acorn/apps/validator.go b/pkg/server/registry/apigroups/acorn/apps/validator.go index df3ebb527..8069908d5 100644 --- a/pkg/server/registry/apigroups/acorn/apps/validator.go +++ b/pkg/server/registry/apigroups/acorn/apps/validator.go @@ -17,7 +17,6 @@ import ( "github.com/acorn-io/namegenerator" apiv1 "github.com/acorn-io/runtime/pkg/apis/api.acorn.io/v1" v1 "github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1" - adminv1 "github.com/acorn-io/runtime/pkg/apis/internal.admin.acorn.io/v1" "github.com/acorn-io/runtime/pkg/autoupgrade" "github.com/acorn-io/runtime/pkg/client" "github.com/acorn-io/runtime/pkg/computeclasses" @@ -259,7 +258,7 @@ func (s *Validator) ValidateUpdate(ctx context.Context, obj, old runtime.Object) } } - if newParams.Spec.Region != "" && newParams.Spec.Region != oldParams.Status.ResolvedOfferings.Region { + if newParams.Spec.Region != oldParams.Spec.Region && newParams.Spec.Region != oldParams.Status.Defaults.Region { result = append(result, field.Invalid(field.NewPath("spec", "region"), newParams.Spec.Region, "cannot change region")) return result } @@ -684,13 +683,23 @@ func validateVolumeClasses(ctx context.Context, c kclient.Client, namespace stri return nil } - defaultRegion := project.GetRegion() - - volumeClasses, defaultVolumeClass, err := volume.GetVolumeClassInstances(ctx, c, namespace) - if err != nil { + var ( + defaultRegion = project.GetRegion() + volumeClassList = new(apiv1.VolumeClassList) + defaultVolumeClass *apiv1.VolumeClass + ) + if err := c.List(ctx, volumeClassList, kclient.InNamespace(namespace)); err != nil { return field.Invalid(field.NewPath("spec", "image"), appInstanceSpec.Image, fmt.Sprintf("error checking volume classes: %v", err)) } + volumeClasses := make(map[string]apiv1.VolumeClass, len(volumeClassList.Items)) + for _, volumeClass := range volumeClassList.Items { + if volumeClass.Default { + defaultVolumeClass = volumeClass.DeepCopy() + } + volumeClasses[volumeClass.Name] = volumeClass + } + volumeBindings := make(map[string]v1.VolumeBinding) for i, vol := range appInstanceSpec.Volumes { if volClass, ok := volumeClasses[vol.Class]; vol.Class != "" && (!ok || volClass.Inactive || (volClass.SupportedRegions != nil && !slices.Contains(volClass.SupportedRegions, defaultRegion) && !slices.Contains(volClass.SupportedRegions, appInstanceSpec.Region))) { @@ -699,12 +708,9 @@ func validateVolumeClasses(ctx context.Context, c kclient.Client, namespace stri volumeBindings[vol.Target] = vol } - var volClass adminv1.ProjectVolumeClassInstance + var volClass apiv1.VolumeClass for volName, vol := range appSpec.Volumes { - calculatedVolumeRequest, err := volume.ResolveVolumeRequest(ctx, c, vol, volumeBindings[volName], volumeClasses, defaultVolumeClass, v1.VolumeResolvedOffering{}) - if err != nil { - return field.Invalid(field.NewPath("spec", "volumes", volName), vol, err.Error()) - } + calculatedVolumeRequest := volume.CopyVolumeDefaults(vol, volumeBindings[volName], v1.VolumeDefault{}) if calculatedVolumeRequest.Class != "" { volClass = volumeClasses[calculatedVolumeRequest.Class] } else if defaultVolumeClass != nil { diff --git a/pkg/server/registry/apigroups/acorn/apps/validator_test.go b/pkg/server/registry/apigroups/acorn/apps/validator_test.go index f7f95f4f5..48ea39d6c 100644 --- a/pkg/server/registry/apigroups/acorn/apps/validator_test.go +++ b/pkg/server/registry/apigroups/acorn/apps/validator_test.go @@ -94,7 +94,7 @@ func TestCannotChangeAppRegion(t *testing.T) { name: "Cannot change region from calculated default", oldApp: apiv1.App{ Status: internalv1.AppInstanceStatus{ - ResolvedOfferings: internalv1.ResolvedOfferings{ + Defaults: internalv1.Defaults{ Region: "old-acorn-test-region", }, }, diff --git a/pkg/server/registry/apigroups/acorn/projects/validator_test.go b/pkg/server/registry/apigroups/acorn/projects/validator_test.go index f22052bd3..9e67c7363 100644 --- a/pkg/server/registry/apigroups/acorn/projects/validator_test.go +++ b/pkg/server/registry/apigroups/acorn/projects/validator_test.go @@ -236,11 +236,6 @@ func TestProjectUpdateValidation(t *testing.T) { Spec: v1.AppInstanceSpec{ Region: "my-region", }, - Status: v1.AppInstanceStatus{ - ResolvedOfferings: v1.ResolvedOfferings{ - Region: "my-region", - }, - }, }, }, }, @@ -277,11 +272,6 @@ func TestProjectUpdateValidation(t *testing.T) { Spec: v1.AppInstanceSpec{ Region: "my-region", }, - Status: v1.AppInstanceStatus{ - ResolvedOfferings: v1.ResolvedOfferings{ - Region: "my-region", - }, - }, }, }, }, @@ -323,11 +313,6 @@ func TestProjectUpdateValidation(t *testing.T) { Spec: v1.AppInstanceSpec{ Region: "my-other-region", }, - Status: v1.AppInstanceStatus{ - ResolvedOfferings: v1.ResolvedOfferings{ - Region: "my-other-region", - }, - }, }, }, }, @@ -412,7 +397,7 @@ func TestProjectUpdateValidation(t *testing.T) { Namespace: "my-project", }, Status: v1.AppInstanceStatus{ - ResolvedOfferings: v1.ResolvedOfferings{ + Defaults: v1.Defaults{ Region: "my-other-region", }, }, @@ -461,11 +446,6 @@ func TestProjectUpdateValidation(t *testing.T) { Spec: v1.AppInstanceSpec{ Region: "my-other-region", }, - Status: v1.AppInstanceStatus{ - ResolvedOfferings: v1.ResolvedOfferings{ - Region: "my-other-region", - }, - }, }, }, }, @@ -508,11 +488,6 @@ func TestProjectUpdateValidation(t *testing.T) { Spec: v1.AppInstanceSpec{ Region: "my-other-region", }, - Status: v1.AppInstanceStatus{ - ResolvedOfferings: v1.ResolvedOfferings{ - Region: "my-other-region", - }, - }, }, { ObjectMeta: metav1.ObjectMeta{ @@ -522,11 +497,6 @@ func TestProjectUpdateValidation(t *testing.T) { Spec: v1.AppInstanceSpec{ Region: "my-region", }, - Status: v1.AppInstanceStatus{ - ResolvedOfferings: v1.ResolvedOfferings{ - Region: "my-region", - }, - }, }, }, }, @@ -569,11 +539,6 @@ func TestProjectUpdateValidation(t *testing.T) { Spec: v1.AppInstanceSpec{ Region: "my-other-region", }, - Status: v1.AppInstanceStatus{ - ResolvedOfferings: v1.ResolvedOfferings{ - Region: "my-other-region", - }, - }, }, }, }, @@ -614,11 +579,6 @@ func TestProjectUpdateValidation(t *testing.T) { Spec: v1.AppInstanceSpec{ Region: "my-other-region", }, - Status: v1.AppInstanceStatus{ - ResolvedOfferings: v1.ResolvedOfferings{ - Region: "my-other-region", - }, - }, }, }, }, diff --git a/pkg/volume/volume.go b/pkg/volume/volume.go index 66114171b..96a7b2b31 100644 --- a/pkg/volume/volume.go +++ b/pkg/volume/volume.go @@ -151,58 +151,27 @@ func getVolumeClassNames(volumeClasses map[string]adminv1.ProjectVolumeClassInst return typed.SortedKeys(storageClassName) } -func ResolveVolumeRequest(ctx context.Context, c client.Client, volumeRequest v1.VolumeRequest, - volumeBinding v1.VolumeBinding, volumeClasses map[string]adminv1.ProjectVolumeClassInstance, - defaultVolumeClass *adminv1.ProjectVolumeClassInstance, existingResolvedVolume v1.VolumeResolvedOffering) (v1.VolumeRequest, error) { +func CopyVolumeDefaults(volumeRequest v1.VolumeRequest, volumeBinding v1.VolumeBinding, volumeDefaults v1.VolumeDefault) v1.VolumeRequest { bind := volumeBinding.Volume != "" - trueVolumeClass := defaultVolumeClass.DeepCopy() - if volumeBinding.Class != "" { volumeRequest.Class = volumeBinding.Class - vc := volumeClasses[volumeBinding.Class] - trueVolumeClass = &vc - } else if volumeRequest.Class != "" { - vc := volumeClasses[volumeRequest.Class] - trueVolumeClass = &vc - } else if !bind && defaultVolumeClass != nil { - volumeRequest.Class = defaultVolumeClass.Name + } else if !bind && volumeRequest.Class == "" { + volumeRequest.Class = volumeDefaults.Class } if volumeBinding.Size != "" { volumeRequest.Size = volumeBinding.Size } else if !bind && volumeRequest.Size == "" { - if existingResolvedVolume.Size != "" { - volumeRequest.Size = existingResolvedVolume.Size - } else if trueVolumeClass != nil { - volumeRequest.Size = trueVolumeClass.Size.Default - } else { - defaultSize, err := GetDefaultVolumeSize(ctx, c) - if err != nil { - return v1.VolumeRequest{}, err - } - volumeRequest.Size = defaultSize - } + volumeRequest.Size = volumeDefaults.Size } - if len(volumeBinding.AccessModes) > 0 { + if len(volumeBinding.AccessModes) != 0 { volumeRequest.AccessModes = volumeBinding.AccessModes - } else if !bind && len(volumeRequest.AccessModes) == 0 && trueVolumeClass != nil { - volumeRequest.AccessModes = trueVolumeClass.AllowedAccessModes - } - - // If there is an existing VolumeResolvedOffering, and we are not binding to an already existing volume, - // then make sure that we continue using the same VolumeClass and AccessModes, since those cannot be - // changed on existing volumes - if !bind { - if existingResolvedVolume.Class != "" { - volumeRequest.Class = existingResolvedVolume.Class - } - if len(existingResolvedVolume.AccessModes) > 0 { - volumeRequest.AccessModes = existingResolvedVolume.AccessModes - } + } else if len(volumeRequest.AccessModes) == 0 { + volumeRequest.AccessModes = volumeDefaults.AccessModes } - return volumeRequest, nil + return volumeRequest } func FindDefaultStorageClass(ctx context.Context, c client.Reader) (string, error) { @@ -219,19 +188,3 @@ func FindDefaultStorageClass(ctx context.Context, c client.Reader) (string, erro return "", nil } - -func GetDefaultVolumeSize(ctx context.Context, c client.Client) (v1.Quantity, error) { - cfg, err := config.Get(ctx, c) - if err != nil { - return "", err - } - - // If the default volume size is set in the config, use that. Otherwise use the - // package level default in internalv1. - defaultVolumeSize := v1.DefaultSizeQuantity - if cfg.VolumeSizeDefault != "" { - defaultVolumeSize = v1.Quantity(cfg.VolumeSizeDefault) - } - - return defaultVolumeSize, nil -}