From 4aca73ac589f8716ece18a269f764b7af6aa55df Mon Sep 17 00:00:00 2001 From: Grant Linville Date: Tue, 5 Dec 2023 10:17:58 -0500 Subject: [PATCH] Refactor defaults to resolvedOfferings 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 | 38 +-- .../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 | 13 + .../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 | 17 +- .../input.yaml | 13 +- .../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 | 14 +- pkg/controller/appstatus/check.go | 2 +- pkg/controller/appstatus/check_test.go | 2 +- pkg/controller/defaults/memory.go | 84 ------- pkg/controller/defaults/memory_test.go | 74 ------ .../volume-class-defaults-set/existing.yaml | 24 -- .../volume-class-defaults-set/expected.golden | 54 ----- .../volume-class-defaults-set/input.yaml | 26 -- pkg/controller/quota/quota.go | 14 +- .../status-default-volume-size/input.yaml | 4 +- .../resolvedofferings/computeclass.go | 123 ++++++++++ .../resolvedofferings/computeclass_test.go | 86 +++++++ .../{defaults => resolvedofferings}/region.go | 4 +- .../region_test.go | 2 +- .../resolvedofferings.go} | 20 +- .../existing.yaml | 31 +++ .../expected.golden | 68 ++++++ .../input.yaml | 32 +++ .../all-set-overwrite/existing.yaml | 0 .../all-set-overwrite/expected.golden | 17 +- .../all-set-overwrite/input.yaml | 0 .../computeclass}/all-set/existing.yaml | 0 .../computeclass}/all-set/expected.golden | 17 +- .../testdata/computeclass}/all-set/input.yaml | 0 .../compute-class-default/existing.yaml | 31 +++ .../compute-class-default/expected.golden | 67 ++++++ .../compute-class-default/input.yaml | 31 +++ .../computeclass}/container/existing.yaml | 0 .../computeclass}/container/expected.golden | 17 +- .../computeclass}/container/input.yaml | 0 .../testdata/computeclass}/job/existing.yaml | 0 .../computeclass/job}/expected.golden | 20 +- .../testdata/computeclass}/job/input.yaml | 0 .../overwrite-acornfile-memory/existing.yaml | 0 .../expected.golden | 20 +- .../overwrite-acornfile-memory/input.yaml | 0 .../same-generation/expected.golden | 15 +- .../computeclass}/same-generation/input.yaml | 13 +- .../computeclass}/sidecar/existing.yaml | 0 .../computeclass}/sidecar/expected.golden | 17 +- .../testdata/computeclass}/sidecar/input.yaml | 0 .../existing.yaml | 0 .../expected.yaml | 6 +- .../two-ccc-defaults-should-error/input.yaml | 0 .../two-containers/existing.yaml | 0 .../two-containers/expected.golden | 17 +- .../computeclass}/two-containers/input.yaml | 0 .../existing.yaml | 0 .../expected.yaml | 6 +- .../two-pcc-defaults-should-error/input.yaml | 0 .../user-override-compute-class/existing.yaml | 31 +++ .../expected.golden | 70 ++++++ .../user-override-compute-class/input.yaml | 34 +++ .../with-acornfile-memory/existing.yaml | 0 .../with-acornfile-memory/expected.golden | 17 +- .../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 .../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 | 21 +- .../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 .../volumeclass.go | 44 ++-- .../volumeclass_test.go | 6 +- 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 | 4 +- .../apigroups/acorn/apps/validator_test.go | 2 +- .../acorn/projects/validator_test.go | 42 +++- pkg/volume/volume.go | 26 +- 273 files changed, 1984 insertions(+), 1218 deletions(-) delete mode 100644 pkg/controller/defaults/memory.go delete mode 100644 pkg/controller/defaults/memory_test.go delete mode 100644 pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/existing.yaml delete mode 100644 pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/expected.golden delete mode 100644 pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/input.yaml create mode 100644 pkg/controller/resolvedofferings/computeclass.go create mode 100644 pkg/controller/resolvedofferings/computeclass_test.go rename pkg/controller/{defaults => resolvedofferings}/region.go (91%) rename pkg/controller/{defaults => resolvedofferings}/region_test.go (95%) rename pkg/controller/{defaults/defaults.go => resolvedofferings/resolvedofferings.go} (63%) create mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/existing.yaml create mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/expected.golden create mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/input.yaml rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/all-set-overwrite/existing.yaml (100%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/all-set-overwrite/expected.golden (86%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/all-set-overwrite/input.yaml (100%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/all-set/existing.yaml (100%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/all-set/expected.golden (86%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/all-set/input.yaml (100%) create mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/existing.yaml create mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/expected.golden create mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/input.yaml rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/container/existing.yaml (100%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/container/expected.golden (85%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/container/input.yaml (100%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/job/existing.yaml (100%) rename pkg/controller/{defaults/testdata/memory/overwrite-acornfile-memory => resolvedofferings/testdata/computeclass/job}/expected.golden (86%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/job/input.yaml (100%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/overwrite-acornfile-memory/existing.yaml (100%) rename pkg/controller/{defaults/testdata/memory/job => resolvedofferings/testdata/computeclass/overwrite-acornfile-memory}/expected.golden (82%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/overwrite-acornfile-memory/input.yaml (100%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/same-generation/expected.golden (86%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/same-generation/input.yaml (83%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/sidecar/existing.yaml (100%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/sidecar/expected.golden (86%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/sidecar/input.yaml (100%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/two-ccc-defaults-should-error/existing.yaml (100%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/two-ccc-defaults-should-error/expected.yaml (94%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/two-ccc-defaults-should-error/input.yaml (100%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/two-containers/existing.yaml (100%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/two-containers/expected.golden (86%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/two-containers/input.yaml (100%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/two-pcc-defaults-should-error/existing.yaml (100%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/two-pcc-defaults-should-error/expected.yaml (94%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/two-pcc-defaults-should-error/input.yaml (100%) create mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/existing.yaml create mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/expected.golden create mode 100644 pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/input.yaml rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/with-acornfile-memory/existing.yaml (100%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/with-acornfile-memory/expected.golden (85%) rename pkg/controller/{defaults/testdata/memory => resolvedofferings/testdata/computeclass}/with-acornfile-memory/input.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/region/default/existing.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/region/default/expected.golden (82%) rename pkg/controller/{defaults => resolvedofferings}/testdata/region/default/input.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/region/project-default-status/existing.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/region/project-default-status/expected.golden (82%) rename pkg/controller/{defaults => resolvedofferings}/testdata/region/project-default-status/input.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/region/region-on-spec/existing.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/region/region-on-spec/expected.golden (80%) rename pkg/controller/{defaults => resolvedofferings}/testdata/region/region-on-spec/input.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/cluster-and-project-class-same-name/existing.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/cluster-and-project-class-same-name/expected.golden (84%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/cluster-and-project-class-same-name/input.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-defaults-same-gen/existing.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-defaults-same-gen/expected.golden (85%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-defaults-same-gen/input.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-fill-cluster-default/existing.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-fill-cluster-default/expected.golden (86%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-fill-cluster-default/input.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-fill-defaults-with-bind/existing.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-fill-defaults-with-bind/expected.golden (84%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-fill-defaults-with-bind/input.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-fill-defaults/existing.yaml (100%) rename pkg/controller/{defaults/testdata/volumeclass/volume-class-fill-size => resolvedofferings/testdata/volumeclass/volume-class-fill-defaults}/expected.golden (83%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-fill-defaults/input.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-fill-project-default/existing.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-fill-project-default/expected.golden (87%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-fill-project-default/input.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-fill-size/existing.yaml (100%) rename pkg/controller/{defaults/testdata/volumeclass/volume-class-fill-defaults => resolvedofferings/testdata/volumeclass/volume-class-fill-size}/expected.golden (80%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-fill-size/input.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-two-cluster-defaults/existing.yaml (100%) rename pkg/controller/{defaults/testdata/volumeclass/volume-class-two-project-defaults => resolvedofferings/testdata/volumeclass/volume-class-two-cluster-defaults}/expected.yaml (74%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-two-cluster-defaults/input.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-two-project-defaults/existing.yaml (100%) rename pkg/controller/{defaults/testdata/volumeclass/volume-class-two-cluster-defaults => resolvedofferings/testdata/volumeclass/volume-class-two-project-defaults}/expected.yaml (74%) rename pkg/controller/{defaults => resolvedofferings}/testdata/volumeclass/volume-class-two-project-defaults/input.yaml (100%) rename pkg/controller/{defaults => resolvedofferings}/volumeclass.go (56%) rename pkg/controller/{defaults => resolvedofferings}/volumeclass_test.go (92%) diff --git a/docs/docs/40-admin/03-computeclasses.md b/docs/docs/40-admin/03-computeclasses.md index 1445417d8..58b322c03 100644 --- a/docs/docs/40-admin/03-computeclasses.md +++ b/docs/docs/40-admin/03-computeclasses.md @@ -40,6 +40,7 @@ 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 5dfa25c81..843112c8d 100644 --- a/pkg/apis/api.acorn.io/v1/types.go +++ b/pkg/apis/api.acorn.io/v1/types.go @@ -23,10 +23,7 @@ func (in *App) GetStopped() bool { } func (in *App) GetRegion() string { - if in.Spec.Region != "" { - return in.Spec.Region - } - return in.Status.Defaults.Region + return in.Status.ResolvedOfferings.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 deccdebca..487c88867 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" - AppInstanceConditionDefaults = "defaults" + AppInstanceConditionResolvedOfferings = "resolved-offerings" AppInstanceConditionScheduling = "scheduling" AppInstanceConditionNamespace = "namespace" AppInstanceConditionParsed = "parsed" @@ -52,24 +52,18 @@ type AppInstance struct { } func (in *AppInstance) HasRegion(region string) bool { - return in.Status.Defaults.Region == region || in.Spec.Region == region + return in.Status.ResolvedOfferings.Region == region || in.Spec.Region == region } func (in *AppInstance) GetRegion() string { - if in.Spec.Region != "" { - return in.Spec.Region + if in.Status.ResolvedOfferings.Region != "" { + return in.Status.ResolvedOfferings.Region } - return in.Status.Defaults.Region + return in.Spec.Region } func (in *AppInstance) SetDefaultRegion(region string) { - if in.Spec.Region == "" { - if in.Status.Defaults.Region == "" { - in.Status.Defaults.Region = region - } - } else { - in.Status.Defaults.Region = "" - } + in.Status.ResolvedOfferings.Region = region } func (in *AppInstance) ShortID() string { @@ -209,7 +203,7 @@ type AppInstanceStatus struct { AppStatus AppStatus `json:"appStatus,omitempty"` Scheduling map[string]Scheduling `json:"scheduling,omitempty"` Conditions []Condition `json:"conditions,omitempty"` - Defaults Defaults `json:"defaults,omitempty"` + ResolvedOfferings ResolvedOfferings `json:"resolvedOfferings,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 @@ -229,19 +223,25 @@ type AppStatusStaged struct { ImageAllowed *bool `json:"imageAllowed,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 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 VolumeDefault struct { +type VolumeResolvedOffering 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 4723a1893..018136105 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.Defaults.DeepCopyInto(&out.Defaults) + in.ResolvedOfferings.DeepCopyInto(&out.ResolvedOfferings) in.Summary.DeepCopyInto(&out.Summary) if in.Permissions != nil { in, out := &in.Permissions, &out.Permissions @@ -1344,6 +1344,31 @@ 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 @@ -1374,48 +1399,6 @@ 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) { { @@ -2784,6 +2767,40 @@ 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 @@ -3602,26 +3619,6 @@ 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 @@ -3672,6 +3669,26 @@ 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 0b362c571..b6172d9e2 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": {}, - "defaults": {}, + "resolvedOfferings": {}, "summary": {} } } diff --git a/pkg/cli/testdata/TestAll/acorn_all_-o_yaml.golden b/pkg/cli/testdata/TestAll/acorn_all_-o_yaml.golden index a8f6731ff..93a96a578 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: {} - defaults: {} + resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/deploy.go b/pkg/controller/appdefinition/deploy.go index fa2c20270..101795761 100644 --- a/pkg/controller/appdefinition/deploy.go +++ b/pkg/controller/appdefinition/deploy.go @@ -597,12 +597,25 @@ func containerAnnotation(container v1.Container) string { return string(json) } +func resolvedOfferingsAnnotation(appInstance *v1.AppInstance, container v1.Container) string { + if resolved, exists := appInstance.Status.ResolvedOfferings.Containers[container.Name]; exists { + data, _ := convert.EncodeToMap(resolved) + j, _ := json.Marshal(data) + return string(j) + } + return "" +} + func podAnnotations(appInstance *v1.AppInstance, container v1.Container) map[string]string { annotations := map[string]string{ labels.AcornContainerSpec: containerAnnotation(container), } addPrometheusAnnotations(annotations, container) + if offerings := resolvedOfferingsAnnotation(appInstance, container); 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 9f160e2a5..0d26719a6 100644 --- a/pkg/controller/appdefinition/testdata/TestComputeMem.golden +++ b/pkg/controller/appdefinition/testdata/TestComputeMem.golden @@ -116,7 +116,7 @@ status: appSpec: {} appStatus: {} columns: {} - defaults: {} + resolvedOfferings: {} staged: appImage: buildContext: {} @@ -157,7 +157,7 @@ status: appSpec: {} appStatus: {} columns: {} - defaults: {} + resolvedOfferings: {} 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 a86ce4724..4d13f27b0 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: {} - defaults: {} + resolvedOfferings: {} 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 94f10fed6..583250909 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: {} - defaults: {} + resolvedOfferings: {} 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 b101e1c8c..9a356ca61 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 518c57d7f..aceec1cbf 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 753f7bcfc..08bd1be57 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,6 +55,7 @@ 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 +225,7 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true @@ -233,13 +234,16 @@ 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 4c19157f4..b5ce2e734 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,11 +36,14 @@ status: requests: cpu: 2m memory: 2Mi - defaults: - memory: - "": 0 - left: 2097152 # 2Mi - oneimage: 2097152 # 2Mi + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 2097152 # 2Mi + oneimage: + memory: 2097152 # 2Mi namespace: app-created-namespace appImage: id: test @@ -63,7 +66,7 @@ status: dockerfile: "Dockerfile" context: "." conditions: - - type: defaults + - type: resolved-offerings 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 c8439e019..3ab0d4989 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/all-set/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/all-set/expected.golden @@ -55,6 +55,7 @@ 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 @@ -223,7 +224,7 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true @@ -232,13 +233,16 @@ 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 44a71471a..6bf5330a7 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/all-set/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/all-set/input.yaml @@ -35,11 +35,14 @@ status: cpu: 1m memory: 1Mi namespace: app-created-namespace - defaults: - memory: - "": 0 - left: 1048576 # 1Mi - oneimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 # 1Mi + oneimage: + memory: 1048576 # 1Mi appImage: id: test appSpec: @@ -61,7 +64,7 @@ status: dockerfile: "Dockerfile" context: "." conditions: - - type: defaults + - type: resolved-offerings 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 f22484471..ebbe3bc3e 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/container/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/container/expected.golden @@ -55,6 +55,7 @@ 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 @@ -223,7 +224,7 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true @@ -232,13 +233,16 @@ 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 e6f0f9a4b..6d55f8c75 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/container/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/container/input.yaml @@ -35,11 +35,14 @@ status: cpu: 1m memory: 1Mi namespace: app-created-namespace - defaults: - memory: - "": 0 - left: 1048576 # 1Mi - oneimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 # 1Mi + oneimage: + memory: 1048576 # 1Mi appImage: id: test appSpec: @@ -61,7 +64,7 @@ status: dockerfile: "Dockerfile" context: "." conditions: - - type: defaults + - type: resolved-offerings 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 ab86edaf4..a9cb45cb4 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/different-computeclass/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/different-computeclass/expected.golden @@ -69,6 +69,7 @@ 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 @@ -186,6 +187,7 @@ 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 @@ -372,7 +374,7 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true @@ -381,13 +383,16 @@ 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 988d8cff3..30b47c5e8 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/different-computeclass/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/different-computeclass/input.yaml @@ -44,11 +44,14 @@ status: requests: cpu: 1m memory: 1Mi - defaults: - memory: - "": 0 - oneimage: 2097152 # 2Mi - twoimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 + oneimage: + memory: 2097152 # 2Mi + twoimage: + memory: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test @@ -73,7 +76,7 @@ status: dockerfile: "Dockerfile" context: "." conditions: - - type: defaults + - type: resolved-offerings 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 0787f0a97..d20580dee 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/job/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/job/expected.golden @@ -54,6 +54,7 @@ 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: @@ -222,7 +223,7 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true @@ -231,13 +232,16 @@ 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 8cc04fd1a..d2af853a8 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/job/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/job/input.yaml @@ -35,11 +35,14 @@ status: cpu: 1m memory: 1Mi namespace: app-created-namespace - defaults: - memory: - "": 0 - left: 1048576 # 1Mi - oneimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 # 1Mi + oneimage: + memory: 1048576 # 1Mi appImage: id: test appSpec: @@ -61,7 +64,7 @@ status: dockerfile: "Dockerfile" context: "." conditions: - - type: defaults + - type: resolved-offerings 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 3d86319f1..8e2f55105 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/overwrite-acornfile-computeclass/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/overwrite-acornfile-computeclass/expected.golden @@ -55,6 +55,7 @@ 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 @@ -224,7 +225,7 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true @@ -233,13 +234,16 @@ 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 b8c256e35..92ba08394 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/overwrite-acornfile-computeclass/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/overwrite-acornfile-computeclass/input.yaml @@ -34,11 +34,14 @@ status: requests: cpu: 1m memory: 1Mi - defaults: - memory: - "": 0 # 1Mi - left: 1048576 # 1Mi - oneimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 # 1Mi + left: + memory: 1048576 # 1Mi + oneimage: + memory: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test @@ -62,7 +65,7 @@ status: context: "." class: sample-compute-class-01 conditions: - - type: defaults + - type: resolved-offerings 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 24247810e..2f0fc0b93 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,9 +9,10 @@ spec: computeClass: left: sample-compute-class status: - defaults: - memory: - left: 1048576 # 1Mi + resolvedOfferings: + containers: + left: + memory: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test @@ -34,7 +35,7 @@ status: dockerfile: "Dockerfile" context: "." conditions: - - type: defaults + - type: resolved-offerings 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 b0735abee..484e175aa 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/sidecar/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/sidecar/input.yaml @@ -9,9 +9,10 @@ spec: computeClass: left: sample-compute-class status: - defaults: - memory: - left: 1048576 # 1Mi + resolvedOfferings: + containers: + left: + memory: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test @@ -34,7 +35,7 @@ status: dockerfile: "Dockerfile" context: "." conditions: - - type: defaults + - type: resolved-offerings 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 fbe43e572..1e40639fc 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/two-containers/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/two-containers/expected.golden @@ -69,6 +69,7 @@ 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 @@ -186,6 +187,7 @@ 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 @@ -357,7 +359,7 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true @@ -366,13 +368,16 @@ 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 88d33e222..4a93fcd3c 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/two-containers/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/two-containers/input.yaml @@ -29,11 +29,14 @@ status: memory: 1Mi twoimage: requirements: {} - defaults: - memory: - "": 0 - oneimage: 1048576 # 1Mi - twoimage: 0 + resolvedOfferings: + containers: + "": + memory: 0 + oneimage: + memory: 1048576 # 1Mi + twoimage: + memory: 0 namespace: app-created-namespace appImage: id: test @@ -58,7 +61,7 @@ status: dockerfile: "Dockerfile" context: "." conditions: - - type: defaults + - type: resolved-offerings 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 51ed2acd7..293cb72f1 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/with-acornfile-computeclass/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/with-acornfile-computeclass/expected.golden @@ -55,6 +55,7 @@ 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 @@ -222,7 +223,7 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true @@ -231,13 +232,16 @@ 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 eb2a79f02..519aa0bc5 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/with-acornfile-computeclass/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/with-acornfile-computeclass/input.yaml @@ -32,11 +32,14 @@ status: requests: cpu: 1m memory: 1Mi - defaults: - memory: - "": 0 # 1Mi - left: 1048576 # 1Mi - oneimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 # 1Mi + oneimage: + memory: 1048576 # 1Mi namespace: app-created-namespace appImage: id: test @@ -60,7 +63,7 @@ status: context: "." class: sample-compute-class conditions: - - type: defaults + - type: resolved-offerings 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 2f1522d5f..46ef557e5 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 196da524b..a561abed7 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 a028b5f70..cee64d11c 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 7b9352f44..5d2be1b6b 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 14b2a2576..24f1a0d48 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 0c3e5d5f8..8c88b097e 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 0c9f1513d..f9e9eb7df 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 24b143307..5177ecc25 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 5580aa20a..9b482facb 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 48fcbbf4b..d97fe8d75 100644 --- a/pkg/controller/appdefinition/testdata/deployspec/pre-stop/dev/expected.golden +++ b/pkg/controller/appdefinition/testdata/deployspec/pre-stop/dev/expected.golden @@ -321,7 +321,6 @@ status: status: "True" success: true type: defined - defaults: {} devSession: client: imageSource: {} @@ -329,6 +328,7 @@ 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 ebdd8be9e..4081b2f4a 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 7313fda09..57ccc4d56 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 73f601540..b974fa03c 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 76b530280..664dea179 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 - defaults: + namespace: app-created-namespace + resolvedOfferings: 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 3138c7dfc..5a3d79e32 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: {} - defaults: + resolvedOfferings: 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 fdbd5ffb5..8da340724 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 1d48b868a..e6c4ce2d7 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 afc121717..f47299fa0 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 d43240798..0e9cadc5f 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 ac5d939ed..449887ff5 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: {} - defaults: {} + resolvedOfferings: {} 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 d337c144e..06b946244 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 c32622804..e17cae1d4 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 b20bb6058..109d7ca49 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 0a1b5ff82..3085a9e96 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 5adec7492..160b5a604 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 f9029bea9..db48c9a91 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 69b515efd..2d16b34ba 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 ebdd8be9e..4081b2f4a 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 87c677958..9ce390c5b 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 fa87005d9..b8c08bd10 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 ab44576db..04a5d930d 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 6c530fcc2..289436a4e 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 c8b39e86c..d764fc47a 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 7097cc0f5..e0348e8ea 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 72f9ed126..64639593e 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 7c53a953e..318820f66 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 6adeef91b..6ee944fd7 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 1438c99a6..b050a2435 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 49d97c1ff..f02687a07 100644 --- a/pkg/controller/appdefinition/testdata/memory/all-set-overwrite/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/all-set-overwrite/expected.golden @@ -55,6 +55,7 @@ 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,18 +218,21 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings 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 06b83139c..f3a43f53d 100644 --- a/pkg/controller/appdefinition/testdata/memory/all-set-overwrite/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/all-set-overwrite/input.yaml @@ -8,14 +8,17 @@ spec: image: test memory: "": 1048576 # 1Mi - oneimage: 2097152 # 2Mi + oneimage: 2097152 # 2Mi status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 1048576 + left: + memory: 2097152 + oneimage: + memory: 2097152 scheduling: oneimage: requirements: @@ -55,7 +58,7 @@ status: reason: Success status: "True" success: true - - type: defaults + - type: resolved-offerings 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 3061aede9..2a9a3117c 100644 --- a/pkg/controller/appdefinition/testdata/memory/all-set/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/all-set/expected.golden @@ -55,6 +55,7 @@ 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 @@ -216,18 +217,21 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings 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 04304d372..35b6232cf 100644 --- a/pkg/controller/appdefinition/testdata/memory/all-set/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/all-set/input.yaml @@ -10,11 +10,14 @@ spec: "": 1048576 # 1Mi status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 1048576 + left: + memory: 1048576 + oneimage: + memory: 1048576 scheduling: oneimage: requirements: @@ -54,7 +57,7 @@ status: reason: Success status: "True" success: true - - type: defaults + - type: resolved-offerings 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 c45e9957d..1ddbaf6b4 100644 --- a/pkg/controller/appdefinition/testdata/memory/container/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/container/expected.golden @@ -55,6 +55,7 @@ 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 @@ -212,18 +213,21 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings 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 b460aafb5..98ec2d2f4 100644 --- a/pkg/controller/appdefinition/testdata/memory/container/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/container/input.yaml @@ -10,11 +10,14 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 + oneimage: + memory: 1048576 scheduling: oneimage: requirements: @@ -50,7 +53,7 @@ status: reason: Success status: "True" success: true - - type: defaults + - type: resolved-offerings 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 241fac53b..cc96beb1f 100644 --- a/pkg/controller/appdefinition/testdata/memory/job/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/job/expected.golden @@ -54,6 +54,7 @@ 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: @@ -211,18 +212,21 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings 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 54754e7ae..aca5df3ea 100644 --- a/pkg/controller/appdefinition/testdata/memory/job/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/job/input.yaml @@ -10,11 +10,14 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 + oneimage: + memory: 1048576 scheduling: oneimage: requirements: @@ -50,7 +53,7 @@ status: reason: Success status: "True" success: true - - type: defaults + - type: resolved-offerings 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 f0209f8e7..66859076e 100644 --- a/pkg/controller/appdefinition/testdata/memory/overwrite-acornfile-memory/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/overwrite-acornfile-memory/expected.golden @@ -55,6 +55,7 @@ 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 @@ -213,18 +214,21 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings 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 c24384faa..dc7795ff9 100644 --- a/pkg/controller/appdefinition/testdata/memory/overwrite-acornfile-memory/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/overwrite-acornfile-memory/input.yaml @@ -10,11 +10,14 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 + oneimage: + memory: 1048576 scheduling: oneimage: requirements: @@ -51,7 +54,7 @@ status: reason: Success status: "True" success: true - - type: defaults + - type: resolved-offerings 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 809eda4e5..92ab40fe8 100644 --- a/pkg/controller/appdefinition/testdata/memory/sidecar/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/sidecar/expected.golden @@ -55,6 +55,7 @@ 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 @@ -212,18 +213,21 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings 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 5cd0d67f5..108eef008 100644 --- a/pkg/controller/appdefinition/testdata/memory/sidecar/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/sidecar/input.yaml @@ -10,11 +10,14 @@ spec: left: 1048576 # 1Mi status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 + oneimage: + memory: 1048576 scheduling: left: requirements: @@ -50,7 +53,7 @@ status: reason: Success status: "True" success: true - - type: defaults + - type: resolved-offerings 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 8e77fabaf..6815838d8 100644 --- a/pkg/controller/appdefinition/testdata/memory/two-containers/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/two-containers/expected.golden @@ -69,6 +69,7 @@ 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 @@ -176,6 +177,7 @@ 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 @@ -351,18 +353,21 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings 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 e8bb0a5d0..ebd84d84b 100644 --- a/pkg/controller/appdefinition/testdata/memory/two-containers/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/two-containers/input.yaml @@ -10,11 +10,14 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 + oneimage: + memory: 1048576 scheduling: oneimage: requirements: @@ -52,7 +55,7 @@ status: reason: Success status: "True" success: true - - type: defaults + - type: resolved-offerings 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 81b34f14d..813803baf 100644 --- a/pkg/controller/appdefinition/testdata/memory/with-acornfile-memory/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/with-acornfile-memory/expected.golden @@ -55,6 +55,7 @@ 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 @@ -211,18 +212,21 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings 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 7c9be6ae2..a70ef9c68 100644 --- a/pkg/controller/appdefinition/testdata/memory/with-acornfile-memory/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/with-acornfile-memory/input.yaml @@ -8,11 +8,14 @@ spec: image: test status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 + oneimage: + memory: 1048576 scheduling: oneimage: requirements: @@ -49,7 +52,7 @@ status: reason: Success status: "True" success: true - - type: defaults + - type: resolved-offerings 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 a79beef26..50ac38954 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 - defaults: {} + resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/appdefinition/testdata/parsedevmode/expected.golden b/pkg/controller/appdefinition/testdata/parsedevmode/expected.golden index 96e7c3d53..0b4d6ed00 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 b00628858..a745435e7 100644 --- a/pkg/controller/appdefinition/testdata/permissions/both/expected.golden +++ b/pkg/controller/appdefinition/testdata/permissions/both/expected.golden @@ -615,7 +615,6 @@ status: status: "True" success: true type: defined - defaults: {} namespace: app-created-namespace permissions: - rules: @@ -650,6 +649,7 @@ 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 027ae0a5f..0c75907bc 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 933fda07e..b5978ceec 100644 --- a/pkg/controller/appdefinition/testdata/permissions/container/expected.golden +++ b/pkg/controller/appdefinition/testdata/permissions/container/expected.golden @@ -317,7 +317,6 @@ status: status: "True" success: true type: defined - defaults: {} namespace: app-created-namespace permissions: - rules: @@ -336,6 +335,7 @@ 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 57cd48fe9..1e020adba 100644 --- a/pkg/controller/appdefinition/testdata/permissions/containerwithnamespace/expected.golden +++ b/pkg/controller/appdefinition/testdata/permissions/containerwithnamespace/expected.golden @@ -424,7 +424,6 @@ status: status: "True" success: true type: defined - defaults: {} namespace: app-created-namespace permissions: - rules: @@ -452,6 +451,7 @@ 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 65710f6a8..042418f98 100644 --- a/pkg/controller/appdefinition/testdata/permissions/differentpermissions/expected.golden +++ b/pkg/controller/appdefinition/testdata/permissions/differentpermissions/expected.golden @@ -611,7 +611,6 @@ status: status: "True" success: true type: defined - defaults: {} namespace: app-created-namespace permissions: - rules: @@ -646,6 +645,7 @@ 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 cf2cfa129..857b484f6 100644 --- a/pkg/controller/appdefinition/testdata/permissions/job/expected.golden +++ b/pkg/controller/appdefinition/testdata/permissions/job/expected.golden @@ -320,7 +320,6 @@ status: status: "True" success: true type: defined - defaults: {} namespace: app-created-namespace permissions: - rules: @@ -339,6 +338,7 @@ 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 471abe52a..e32ae618f 100644 --- a/pkg/controller/appdefinition/testdata/permissions/multiplecontainers/expected.golden +++ b/pkg/controller/appdefinition/testdata/permissions/multiplecontainers/expected.golden @@ -611,7 +611,6 @@ status: status: "True" success: true type: defined - defaults: {} namespace: app-created-namespace permissions: - rules: @@ -646,6 +645,7 @@ 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 d4d847100..4abd1ccfa 100644 --- a/pkg/controller/appdefinition/testdata/permissions/multiplejobs/expected.golden +++ b/pkg/controller/appdefinition/testdata/permissions/multiplejobs/expected.golden @@ -616,7 +616,6 @@ status: status: "True" success: true type: defined - defaults: {} namespace: app-created-namespace permissions: - rules: @@ -651,6 +650,7 @@ 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 fda5df155..f15b0ddb9 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 1a4d3cdc7..8ed9c6846 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 6609cd71f..3e2bcf6af 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 24c438c25..d08953833 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 df36efc17..098dc3b87 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 51cd2ebc9..5f8004199 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 45f12af58..4de94d130 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 bc1ff8f49..914553a18 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 6dd4f518c..a5e082f76 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 @@ -140,7 +140,7 @@ metadata: namespace: app-created-namespace spec: accessModes: - - ReadWriteMany + - ReadWriteOnce resources: requests: storage: 6Gi @@ -225,18 +225,19 @@ status: status: "True" success: true type: defined - defaults: + namespace: app-created-namespace + resolvedOfferings: volumes: bar: accessModes: - - readWriteMany - class: test-custom-class-default + - readWriteOnce + class: test-custom-class + size: 6Gi foo: accessModes: - - readWriteMany - class: test-custom-class-default - size: 2Gi - namespace: app-created-namespace + - readWriteOnce + class: test-custom-class + size: 3Gi 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 043bc7802..2e7c81131 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,12 +34,13 @@ status: bar: class: test-custom-class-request size: 6Gi - defaults: + resolvedOfferings: volumes: foo: - class: test-custom-class-default - size: 2Gi - accessModes: [ "readWriteMany" ] + class: test-custom-class + size: 3Gi + accessModes: [ "readWriteOnce" ] bar: - class: test-custom-class-default - accessModes: [ "readWriteMany" ] + class: test-custom-class + size: 6Gi + accessModes: [ "readWriteOnce" ] 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 6626b5c6f..68cfc2066 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 041e7e82a..838047a92 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 1d6ccdd46..3716d8f39 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 - defaults: + namespace: app-created-namespace + resolvedOfferings: 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 b2ea7057b..2e17957a7 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: {} - defaults: + resolvedOfferings: 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 aec68b6f4..d80e46239 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 9c5bcbe58..bb30239c9 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 d8c009787..94d0b8634 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 1d6ccdd46..3716d8f39 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 - defaults: + namespace: app-created-namespace + resolvedOfferings: 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 b2ea7057b..2e17957a7 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: {} - defaults: + resolvedOfferings: 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 0e446cd14..787b2bc30 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 59655bcf4..26121c773 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 aec68b6f4..d80e46239 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 11cbffd17..ff309fc6a 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 782822f5a..80c707995 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 2b8e9d0d6..0ea6e4610 100644 --- a/pkg/controller/appdefinition/volume.go +++ b/pkg/controller/appdefinition/volume.go @@ -19,7 +19,6 @@ 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" @@ -127,7 +126,7 @@ func toPVCs(req router.Request, appInstance *v1.AppInstance) (result []kclient.O continue } - volumeRequest = volume.CopyVolumeDefaults(volumeRequest, volumeBinding, appInstance.Status.Defaults.Volumes[vol]) + volumeRequest = volume.ResolveVolumeRequest(volumeRequest, volumeBinding, appInstance.Status.ResolvedOfferings.Volumes[vol]) pvc := corev1.PersistentVolumeClaim{ ObjectMeta: metav1.ObjectMeta{ @@ -197,16 +196,7 @@ func toPVCs(req router.Request, appInstance *v1.AppInstance) (result []kclient.O pvc.Spec.VolumeName = pvName if volumeRequest.Size == "" { - // 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 + pvc.Spec.Resources.Requests[corev1.ResourceStorage] = *v1.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 fb7f9ffc7..05a6c0498 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.AppInstanceConditionDefaults, + v1.AppInstanceConditionResolvedOfferings, v1.AppInstanceConditionScheduling, v1.AppInstanceConditionQuota, } diff --git a/pkg/controller/appstatus/check_test.go b/pkg/controller/appstatus/check_test.go index 1741b1dd5..9bd6033dd 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.AppInstanceConditionDefaults).Success() + condition.Setter(appInstance, resp, v1.AppInstanceConditionResolvedOfferings).Success() condition.Setter(appInstance, resp, v1.AppInstanceConditionScheduling).Success() condition.Setter(appInstance, resp, v1.AppInstanceConditionQuota).Success() diff --git a/pkg/controller/defaults/memory.go b/pkg/controller/defaults/memory.go deleted file mode 100644 index e97c5a76e..000000000 --- a/pkg/controller/defaults/memory.go +++ /dev/null @@ -1,84 +0,0 @@ -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 deleted file mode 100644 index 5df464f24..000000000 --- a/pkg/controller/defaults/memory_test.go +++ /dev/null @@ -1,74 +0,0 @@ -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/defaults/testdata/volumeclass/volume-class-defaults-set/existing.yaml b/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/existing.yaml deleted file mode 100644 index d5b958611..000000000 --- a/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/existing.yaml +++ /dev/null @@ -1,24 +0,0 @@ ---- -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 deleted file mode 100644 index 775c3f3f6..000000000 --- a/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/expected.golden +++ /dev/null @@ -1,54 +0,0 @@ -`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 deleted file mode 100644 index 69c2aab84..000000000 --- a/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-set/input.yaml +++ /dev/null @@ -1,26 +0,0 @@ -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/quota/quota.go b/pkg/controller/quota/quota.go index 11834ed8a..ff4b39303 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 = defaultVolumeSize(appInstance, name) + sizeQuantity = resolvedVolumeSize(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 } -// 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 { +// 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 { // 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.Defaults.Volumes, use that. - if defaultVolume, set := appInstance.Status.Defaults.Volumes[name]; set { + // If the volume has a default size set on status.ResolvedOfferings.Volumes, use that. + if resolvedVolume, set := appInstance.Status.ResolvedOfferings.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(defaultVolume.Size)); err == nil { + if parsedQuantity, err := resource.ParseQuantity(string(resolvedVolume.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 6b83f6d5b..719a19ad2 100644 --- a/pkg/controller/quota/testdata/status-default-volume-size/input.yaml +++ b/pkg/controller/quota/testdata/status-default-volume-size/input.yaml @@ -39,7 +39,9 @@ status: volume-name: accessModes: - readWriteOnce - defaults: + resolvedOfferings: volumes: volume-name: size: 1Gi + accessModes: + - readWriteOnce diff --git a/pkg/controller/resolvedofferings/computeclass.go b/pkg/controller/resolvedofferings/computeclass.go new file mode 100644 index 000000000..9c7e1d48a --- /dev/null +++ b/pkg/controller/resolvedofferings/computeclass.go @@ -0,0 +1,123 @@ +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 new file mode 100644 index 000000000..76cdfbed9 --- /dev/null +++ b/pkg/controller/resolvedofferings/computeclass_test.go @@ -0,0 +1,86 @@ +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/defaults/region.go b/pkg/controller/resolvedofferings/region.go similarity index 91% rename from pkg/controller/defaults/region.go rename to pkg/controller/resolvedofferings/region.go index 5ae355ae9..9b21e4e5f 100644 --- a/pkg/controller/defaults/region.go +++ b/pkg/controller/resolvedofferings/region.go @@ -1,4 +1,4 @@ -package defaults +package resolvedofferings import ( "context" @@ -23,6 +23,8 @@ 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/defaults/region_test.go b/pkg/controller/resolvedofferings/region_test.go similarity index 95% rename from pkg/controller/defaults/region_test.go rename to pkg/controller/resolvedofferings/region_test.go index 2069f77ec..d32551751 100644 --- a/pkg/controller/defaults/region_test.go +++ b/pkg/controller/resolvedofferings/region_test.go @@ -1,4 +1,4 @@ -package defaults +package resolvedofferings import ( "testing" diff --git a/pkg/controller/defaults/defaults.go b/pkg/controller/resolvedofferings/resolvedofferings.go similarity index 63% rename from pkg/controller/defaults/defaults.go rename to pkg/controller/resolvedofferings/resolvedofferings.go index 0e97e3fc8..388abe427 100644 --- a/pkg/controller/defaults/defaults.go +++ b/pkg/controller/resolvedofferings/resolvedofferings.go @@ -1,4 +1,4 @@ -package defaults +package resolvedofferings 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 defaults for an AppInstance to its status if +// Calculate is a handler that sets the resolved offerings for an AppInstance to its status if // and only if its generation is different from its observedGeneration. // -// This is necessary because querying for defaults will result in all running +// This is necessary because querying for resolved offerings will result in all running // AppInstances using that default to redeploy when a default changes. By -// calculating the defaults only when the generation changes, we can ensure that -// updated defaults are only applied when an AppInstance is updated directly. +// 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. func Calculate(req router.Request, resp router.Response) (err error) { appInstance := req.Object.(*internalv1.AppInstance) - status := condition.Setter(appInstance, resp, internalv1.AppInstanceConditionDefaults) + status := condition.Setter(appInstance, resp, internalv1.AppInstanceConditionResolvedOfferings) defer func() { if err == nil { @@ -30,9 +30,9 @@ func Calculate(req router.Request, resp router.Response) (err error) { } }() - // 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 { + // 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 { return err } @@ -55,7 +55,7 @@ func calculate(req router.Request, appInstance *internalv1.AppInstance) error { return err } - if err = addDefaultMemory(req, cfg, appInstance); err != nil { + if err = resolveComputeClasses(req, cfg, appInstance); err != nil { return err } 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 new file mode 100644 index 000000000..1f862ac4e --- /dev/null +++ b/pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/existing.yaml @@ -0,0 +1,31 @@ +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 new file mode 100644 index 000000000..ffcd45b41 --- /dev/null +++ b/pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/expected.golden @@ -0,0 +1,68 @@ +`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 new file mode 100644 index 000000000..140ee5c17 --- /dev/null +++ b/pkg/controller/resolvedofferings/testdata/computeclass/acornfile-override-compute-class/input.yaml @@ -0,0 +1,32 @@ +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/defaults/testdata/memory/all-set-overwrite/existing.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/all-set-overwrite/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/all-set-overwrite/existing.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/all-set-overwrite/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/all-set-overwrite/expected.golden b/pkg/controller/resolvedofferings/testdata/computeclass/all-set-overwrite/expected.golden similarity index 86% rename from pkg/controller/defaults/testdata/memory/all-set-overwrite/expected.golden rename to pkg/controller/resolvedofferings/testdata/computeclass/all-set-overwrite/expected.golden index 094fafdc3..4044306a7 100644 --- a/pkg/controller/defaults/testdata/memory/all-set-overwrite/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/computeclass/all-set-overwrite/expected.golden @@ -44,15 +44,18 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 - region: local + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 2097152 + oneimage: + memory: 2097152 + region: local staged: appImage: buildContext: {} diff --git a/pkg/controller/defaults/testdata/memory/all-set-overwrite/input.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/all-set-overwrite/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/all-set-overwrite/input.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/all-set-overwrite/input.yaml diff --git a/pkg/controller/defaults/testdata/memory/all-set/existing.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/all-set/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/all-set/existing.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/all-set/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/all-set/expected.golden b/pkg/controller/resolvedofferings/testdata/computeclass/all-set/expected.golden similarity index 86% rename from pkg/controller/defaults/testdata/memory/all-set/expected.golden rename to pkg/controller/resolvedofferings/testdata/computeclass/all-set/expected.golden index 67d1a40a5..69f31c986 100644 --- a/pkg/controller/defaults/testdata/memory/all-set/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/computeclass/all-set/expected.golden @@ -43,15 +43,18 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 - region: local + type: resolved-offerings 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/defaults/testdata/memory/all-set/input.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/all-set/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/all-set/input.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/all-set/input.yaml diff --git a/pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/existing.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/existing.yaml new file mode 100644 index 000000000..1f862ac4e --- /dev/null +++ b/pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/existing.yaml @@ -0,0 +1,31 @@ +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 new file mode 100644 index 000000000..6f0e38aa8 --- /dev/null +++ b/pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/expected.golden @@ -0,0 +1,67 @@ +`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 new file mode 100644 index 000000000..701e1c7c8 --- /dev/null +++ b/pkg/controller/resolvedofferings/testdata/computeclass/compute-class-default/input.yaml @@ -0,0 +1,31 @@ +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/defaults/testdata/memory/container/existing.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/container/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/container/existing.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/container/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/container/expected.golden b/pkg/controller/resolvedofferings/testdata/computeclass/container/expected.golden similarity index 85% rename from pkg/controller/defaults/testdata/memory/container/expected.golden rename to pkg/controller/resolvedofferings/testdata/computeclass/container/expected.golden index d2b5b4bd7..f1d13b9b3 100644 --- a/pkg/controller/defaults/testdata/memory/container/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/computeclass/container/expected.golden @@ -43,15 +43,18 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 - region: local + type: resolved-offerings 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/defaults/testdata/memory/container/input.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/container/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/container/input.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/container/input.yaml diff --git a/pkg/controller/defaults/testdata/memory/job/existing.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/job/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/job/existing.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/job/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/expected.golden b/pkg/controller/resolvedofferings/testdata/computeclass/job/expected.golden similarity index 86% rename from pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/expected.golden rename to pkg/controller/resolvedofferings/testdata/computeclass/job/expected.golden index 7006c74d2..36968e541 100644 --- a/pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/computeclass/job/expected.golden @@ -16,13 +16,12 @@ status: imageData: {} vcs: {} appSpec: - containers: + jobs: oneimage: build: context: . dockerfile: Dockerfile image: image-name - memory: 2097152 metrics: {} ports: - port: 80 @@ -44,15 +43,18 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 - region: local + type: resolved-offerings 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/defaults/testdata/memory/job/input.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/job/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/job/input.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/job/input.yaml diff --git a/pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/existing.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/overwrite-acornfile-memory/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/existing.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/overwrite-acornfile-memory/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/job/expected.golden b/pkg/controller/resolvedofferings/testdata/computeclass/overwrite-acornfile-memory/expected.golden similarity index 82% rename from pkg/controller/defaults/testdata/memory/job/expected.golden rename to pkg/controller/resolvedofferings/testdata/computeclass/overwrite-acornfile-memory/expected.golden index 6d4a068f2..da00b488b 100644 --- a/pkg/controller/defaults/testdata/memory/job/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/computeclass/overwrite-acornfile-memory/expected.golden @@ -16,12 +16,13 @@ status: imageData: {} vcs: {} appSpec: - jobs: + containers: oneimage: build: context: . dockerfile: Dockerfile image: image-name + memory: 2097152 metrics: {} ports: - port: 80 @@ -43,15 +44,18 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 - region: local + type: resolved-offerings 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/defaults/testdata/memory/overwrite-acornfile-memory/input.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/overwrite-acornfile-memory/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/input.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/overwrite-acornfile-memory/input.yaml diff --git a/pkg/controller/defaults/testdata/memory/same-generation/expected.golden b/pkg/controller/resolvedofferings/testdata/computeclass/same-generation/expected.golden similarity index 86% rename from pkg/controller/defaults/testdata/memory/same-generation/expected.golden rename to pkg/controller/resolvedofferings/testdata/computeclass/same-generation/expected.golden index 7ea75f112..b74d4d229 100644 --- a/pkg/controller/defaults/testdata/memory/same-generation/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/computeclass/same-generation/expected.golden @@ -43,13 +43,16 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + type: resolved-offerings namespace: app-created-namespace + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 0 + oneimage: + memory: 0 staged: appImage: buildContext: {} diff --git a/pkg/controller/defaults/testdata/memory/same-generation/input.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/same-generation/input.yaml similarity index 83% rename from pkg/controller/defaults/testdata/memory/same-generation/input.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/same-generation/input.yaml index ebc2f5f36..b6661c147 100644 --- a/pkg/controller/defaults/testdata/memory/same-generation/input.yaml +++ b/pkg/controller/resolvedofferings/testdata/computeclass/same-generation/input.yaml @@ -9,11 +9,14 @@ spec: memory: left: 1048576 # 1Mi status: - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 0 + oneimage: + memory: 0 namespace: app-created-namespace appImage: id: test diff --git a/pkg/controller/defaults/testdata/memory/sidecar/existing.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/sidecar/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/sidecar/existing.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/sidecar/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/sidecar/expected.golden b/pkg/controller/resolvedofferings/testdata/computeclass/sidecar/expected.golden similarity index 86% rename from pkg/controller/defaults/testdata/memory/sidecar/expected.golden rename to pkg/controller/resolvedofferings/testdata/computeclass/sidecar/expected.golden index 78ef621ea..7ad60b3a3 100644 --- a/pkg/controller/defaults/testdata/memory/sidecar/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/computeclass/sidecar/expected.golden @@ -43,15 +43,18 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 - region: local + type: resolved-offerings 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/defaults/testdata/memory/sidecar/input.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/sidecar/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/sidecar/input.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/sidecar/input.yaml diff --git a/pkg/controller/defaults/testdata/memory/two-ccc-defaults-should-error/existing.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/two-ccc-defaults-should-error/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/two-ccc-defaults-should-error/existing.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/two-ccc-defaults-should-error/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/two-ccc-defaults-should-error/expected.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/two-ccc-defaults-should-error/expected.yaml similarity index 94% rename from pkg/controller/defaults/testdata/memory/two-ccc-defaults-should-error/expected.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/two-ccc-defaults-should-error/expected.yaml index 9699fbeac..438071625 100644 --- a/pkg/controller/defaults/testdata/memory/two-ccc-defaults-should-error/expected.yaml +++ b/pkg/controller/resolvedofferings/testdata/computeclass/two-ccc-defaults-should-error/expected.yaml @@ -9,8 +9,6 @@ spec: memory: oneimage: 1048576 # 1Mi status: - defaults: - region: local observedGeneration: 1 namespace: app-created-namespace appImage: @@ -38,4 +36,6 @@ status: message: 'cannot establish defaults because two default computeclasses exist: sample-compute-class and sample-compute-class-other' reason: Error status: "False" - type: defaults + type: resolved-offerings + resolvedOfferings: + region: local diff --git a/pkg/controller/defaults/testdata/memory/two-ccc-defaults-should-error/input.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/two-ccc-defaults-should-error/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/two-ccc-defaults-should-error/input.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/two-ccc-defaults-should-error/input.yaml diff --git a/pkg/controller/defaults/testdata/memory/two-containers/existing.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/two-containers/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/two-containers/existing.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/two-containers/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/two-containers/expected.golden b/pkg/controller/resolvedofferings/testdata/computeclass/two-containers/expected.golden similarity index 86% rename from pkg/controller/defaults/testdata/memory/two-containers/expected.golden rename to pkg/controller/resolvedofferings/testdata/computeclass/two-containers/expected.golden index 34a0213d4..a7a868a01 100644 --- a/pkg/controller/defaults/testdata/memory/two-containers/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/computeclass/two-containers/expected.golden @@ -45,15 +45,18 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - oneimage: 0 - twoimage: 0 - region: local + type: resolved-offerings 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/defaults/testdata/memory/two-containers/input.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/two-containers/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/two-containers/input.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/two-containers/input.yaml diff --git a/pkg/controller/defaults/testdata/memory/two-pcc-defaults-should-error/existing.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/two-pcc-defaults-should-error/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/two-pcc-defaults-should-error/existing.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/two-pcc-defaults-should-error/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/two-pcc-defaults-should-error/expected.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/two-pcc-defaults-should-error/expected.yaml similarity index 94% rename from pkg/controller/defaults/testdata/memory/two-pcc-defaults-should-error/expected.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/two-pcc-defaults-should-error/expected.yaml index 9699fbeac..438071625 100644 --- a/pkg/controller/defaults/testdata/memory/two-pcc-defaults-should-error/expected.yaml +++ b/pkg/controller/resolvedofferings/testdata/computeclass/two-pcc-defaults-should-error/expected.yaml @@ -9,8 +9,6 @@ spec: memory: oneimage: 1048576 # 1Mi status: - defaults: - region: local observedGeneration: 1 namespace: app-created-namespace appImage: @@ -38,4 +36,6 @@ status: message: 'cannot establish defaults because two default computeclasses exist: sample-compute-class and sample-compute-class-other' reason: Error status: "False" - type: defaults + type: resolved-offerings + resolvedOfferings: + region: local diff --git a/pkg/controller/defaults/testdata/memory/two-pcc-defaults-should-error/input.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/two-pcc-defaults-should-error/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/two-pcc-defaults-should-error/input.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/two-pcc-defaults-should-error/input.yaml 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 new file mode 100644 index 000000000..ebad9b6a8 --- /dev/null +++ b/pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/existing.yaml @@ -0,0 +1,31 @@ +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 new file mode 100644 index 000000000..3089c0eeb --- /dev/null +++ b/pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/expected.golden @@ -0,0 +1,70 @@ +`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 new file mode 100644 index 000000000..4871266e5 --- /dev/null +++ b/pkg/controller/resolvedofferings/testdata/computeclass/user-override-compute-class/input.yaml @@ -0,0 +1,34 @@ +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/defaults/testdata/memory/with-acornfile-memory/existing.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/with-acornfile-memory/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/with-acornfile-memory/existing.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/with-acornfile-memory/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/with-acornfile-memory/expected.golden b/pkg/controller/resolvedofferings/testdata/computeclass/with-acornfile-memory/expected.golden similarity index 85% rename from pkg/controller/defaults/testdata/memory/with-acornfile-memory/expected.golden rename to pkg/controller/resolvedofferings/testdata/computeclass/with-acornfile-memory/expected.golden index e23679fdb..049ef97f0 100644 --- a/pkg/controller/defaults/testdata/memory/with-acornfile-memory/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/computeclass/with-acornfile-memory/expected.golden @@ -42,15 +42,18 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 - region: local + type: resolved-offerings 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/defaults/testdata/memory/with-acornfile-memory/input.yaml b/pkg/controller/resolvedofferings/testdata/computeclass/with-acornfile-memory/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/with-acornfile-memory/input.yaml rename to pkg/controller/resolvedofferings/testdata/computeclass/with-acornfile-memory/input.yaml diff --git a/pkg/controller/defaults/testdata/region/default/existing.yaml b/pkg/controller/resolvedofferings/testdata/region/default/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/region/default/existing.yaml rename to pkg/controller/resolvedofferings/testdata/region/default/existing.yaml diff --git a/pkg/controller/defaults/testdata/region/default/expected.golden b/pkg/controller/resolvedofferings/testdata/region/default/expected.golden similarity index 82% rename from pkg/controller/defaults/testdata/region/default/expected.golden rename to pkg/controller/resolvedofferings/testdata/region/default/expected.golden index ff24b6397..fb101d73b 100644 --- a/pkg/controller/defaults/testdata/region/default/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/region/default/expected.golden @@ -25,14 +25,16 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - container-name: 0 - region: local + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 + resolvedOfferings: + containers: + "": + memory: 0 + container-name: + memory: 0 + region: local staged: appImage: buildContext: {} diff --git a/pkg/controller/defaults/testdata/region/default/input.yaml b/pkg/controller/resolvedofferings/testdata/region/default/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/region/default/input.yaml rename to pkg/controller/resolvedofferings/testdata/region/default/input.yaml diff --git a/pkg/controller/defaults/testdata/region/project-default-status/existing.yaml b/pkg/controller/resolvedofferings/testdata/region/project-default-status/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/region/project-default-status/existing.yaml rename to pkg/controller/resolvedofferings/testdata/region/project-default-status/existing.yaml diff --git a/pkg/controller/defaults/testdata/region/project-default-status/expected.golden b/pkg/controller/resolvedofferings/testdata/region/project-default-status/expected.golden similarity index 82% rename from pkg/controller/defaults/testdata/region/project-default-status/expected.golden rename to pkg/controller/resolvedofferings/testdata/region/project-default-status/expected.golden index ff24b6397..fb101d73b 100644 --- a/pkg/controller/defaults/testdata/region/project-default-status/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/region/project-default-status/expected.golden @@ -25,14 +25,16 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - container-name: 0 - region: local + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 + resolvedOfferings: + containers: + "": + memory: 0 + container-name: + memory: 0 + region: local staged: appImage: buildContext: {} diff --git a/pkg/controller/defaults/testdata/region/project-default-status/input.yaml b/pkg/controller/resolvedofferings/testdata/region/project-default-status/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/region/project-default-status/input.yaml rename to pkg/controller/resolvedofferings/testdata/region/project-default-status/input.yaml diff --git a/pkg/controller/defaults/testdata/region/region-on-spec/existing.yaml b/pkg/controller/resolvedofferings/testdata/region/region-on-spec/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/region/region-on-spec/existing.yaml rename to pkg/controller/resolvedofferings/testdata/region/region-on-spec/existing.yaml diff --git a/pkg/controller/defaults/testdata/region/region-on-spec/expected.golden b/pkg/controller/resolvedofferings/testdata/region/region-on-spec/expected.golden similarity index 80% rename from pkg/controller/defaults/testdata/region/region-on-spec/expected.golden rename to pkg/controller/resolvedofferings/testdata/region/region-on-spec/expected.golden index fe4b17aaf..d243ccf4c 100644 --- a/pkg/controller/defaults/testdata/region/region-on-spec/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/region/region-on-spec/expected.golden @@ -26,13 +26,16 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - container-name: 0 + type: resolved-offerings 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/defaults/testdata/region/region-on-spec/input.yaml b/pkg/controller/resolvedofferings/testdata/region/region-on-spec/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/region/region-on-spec/input.yaml rename to pkg/controller/resolvedofferings/testdata/region/region-on-spec/input.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/cluster-and-project-class-same-name/existing.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/cluster-and-project-class-same-name/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/cluster-and-project-class-same-name/existing.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/cluster-and-project-class-same-name/existing.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/cluster-and-project-class-same-name/expected.golden b/pkg/controller/resolvedofferings/testdata/volumeclass/cluster-and-project-class-same-name/expected.golden similarity index 84% rename from pkg/controller/defaults/testdata/volumeclass/cluster-and-project-class-same-name/expected.golden rename to pkg/controller/resolvedofferings/testdata/volumeclass/cluster-and-project-class-same-name/expected.golden index 17231acd8..d648d60cc 100644 --- a/pkg/controller/defaults/testdata/volumeclass/cluster-and-project-class-same-name/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/volumeclass/cluster-and-project-class-same-name/expected.golden @@ -32,19 +32,22 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - container-name: 0 + type: resolved-offerings + namespace: app-created-namespace + observedGeneration: 1 + resolvedOfferings: + containers: + "": + memory: 0 + container-name: + memory: 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/defaults/testdata/volumeclass/cluster-and-project-class-same-name/input.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/cluster-and-project-class-same-name/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/cluster-and-project-class-same-name/input.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/cluster-and-project-class-same-name/input.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-same-gen/existing.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-defaults-same-gen/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-same-gen/existing.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-defaults-same-gen/existing.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-same-gen/expected.golden b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-defaults-same-gen/expected.golden similarity index 85% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-same-gen/expected.golden rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-defaults-same-gen/expected.golden index 0d0f1f3a2..146d84796 100644 --- a/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-same-gen/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-defaults-same-gen/expected.golden @@ -31,15 +31,15 @@ status: columns: {} conditions: - error: true - message: 'cannot establish defaults because two defaults volume classes exist: + message: 'cannot resolve volume classes because two defaults volume classes exist: test-volume-class and test-volume-class-1' observedGeneration: 1 reason: Error status: "False" - type: defaults - defaults: {} + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 + resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-same-gen/input.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-defaults-same-gen/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-defaults-same-gen/input.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-defaults-same-gen/input.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-cluster-default/existing.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-cluster-default/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-fill-cluster-default/existing.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-cluster-default/existing.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-cluster-default/expected.golden b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-cluster-default/expected.golden similarity index 86% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-fill-cluster-default/expected.golden rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-cluster-default/expected.golden index ced454b76..bd3f0886c 100644 --- a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-cluster-default/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-cluster-default/expected.golden @@ -31,11 +31,15 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - container-name: 0 + type: resolved-offerings + namespace: app-created-namespace + observedGeneration: 1 + resolvedOfferings: + containers: + "": + memory: 0 + container-name: + memory: 0 region: local volumes: foo: @@ -43,8 +47,6 @@ status: - readWriteOnce class: test-volume-class size: 3Gi - namespace: app-created-namespace - observedGeneration: 1 staged: appImage: buildContext: {} diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-cluster-default/input.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-cluster-default/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-fill-cluster-default/input.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-cluster-default/input.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults-with-bind/existing.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults-with-bind/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults-with-bind/existing.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults-with-bind/existing.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults-with-bind/expected.golden b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults-with-bind/expected.golden similarity index 84% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults-with-bind/expected.golden rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults-with-bind/expected.golden index f604b7258..5913f03e2 100644 --- a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults-with-bind/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults-with-bind/expected.golden @@ -35,19 +35,22 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - container-name: 0 + type: resolved-offerings + namespace: app-created-namespace + observedGeneration: 1 + resolvedOfferings: + containers: + "": + memory: 0 + container-name: + memory: 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/defaults/testdata/volumeclass/volume-class-fill-defaults-with-bind/input.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults-with-bind/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults-with-bind/input.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults-with-bind/input.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults/existing.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults/existing.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults/existing.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-size/expected.golden b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults/expected.golden similarity index 83% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-fill-size/expected.golden rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults/expected.golden index 9062fe05c..c39ad7ff9 100644 --- a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-size/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults/expected.golden @@ -25,8 +25,6 @@ status: probes: null volumes: foo: - accessModes: - - readWriteOnce class: test-volume-class appStatus: {} columns: {} @@ -34,17 +32,22 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - container-name: 0 + type: resolved-offerings + namespace: app-created-namespace + observedGeneration: 1 + resolvedOfferings: + containers: + "": + memory: 0 + container-name: + memory: 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/defaults/testdata/volumeclass/volume-class-fill-defaults/input.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults/input.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults/input.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-project-default/existing.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-project-default/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-fill-project-default/existing.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-project-default/existing.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-project-default/expected.golden b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-project-default/expected.golden similarity index 87% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-fill-project-default/expected.golden rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-project-default/expected.golden index 9a87fb84b..99652c695 100644 --- a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-project-default/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-project-default/expected.golden @@ -31,11 +31,15 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - container-name: 0 + type: resolved-offerings + namespace: app-created-namespace + observedGeneration: 1 + resolvedOfferings: + containers: + "": + memory: 0 + container-name: + memory: 0 region: local volumes: foo: @@ -44,8 +48,6 @@ status: - readOnlyMany class: test-project-volume-class size: 2Gi - namespace: app-created-namespace - observedGeneration: 1 staged: appImage: buildContext: {} diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-project-default/input.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-project-default/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-fill-project-default/input.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-project-default/input.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-size/existing.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-size/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-fill-size/existing.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-size/existing.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults/expected.golden b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-size/expected.golden similarity index 80% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults/expected.golden rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-size/expected.golden index 45fd223b6..ef51350f8 100644 --- a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-size/expected.golden @@ -25,6 +25,8 @@ status: probes: null volumes: foo: + accessModes: + - readWriteOnce class: test-volume-class appStatus: {} columns: {} @@ -32,19 +34,22 @@ status: reason: Success status: "True" success: true - type: defaults - defaults: - memory: - "": 0 - container-name: 0 + type: resolved-offerings + namespace: app-created-namespace + observedGeneration: 1 + resolvedOfferings: + containers: + "": + memory: 0 + container-name: + memory: 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/defaults/testdata/volumeclass/volume-class-fill-size/input.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-size/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-fill-size/input.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-size/input.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-two-cluster-defaults/existing.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-cluster-defaults/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-two-cluster-defaults/existing.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-cluster-defaults/existing.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-two-project-defaults/expected.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-cluster-defaults/expected.yaml similarity index 74% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-two-project-defaults/expected.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-cluster-defaults/expected.yaml index d8b5915a0..c62bd0c6c 100644 --- a/pkg/controller/defaults/testdata/volumeclass/volume-class-two-project-defaults/expected.yaml +++ b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-cluster-defaults/expected.yaml @@ -22,7 +22,7 @@ status: foo: {} conditions: - error: true - message: 'cannot establish defaults because two defaults volume classes exist: test-volume-class and test-volume-class-1' + message: 'cannot resolve volume classes because two defaults volume classes exist: test-volume-class and test-volume-class-1' reason: Error status: "False" - type: defaults + type: resolved-offerings diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-two-cluster-defaults/input.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-cluster-defaults/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-two-cluster-defaults/input.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-cluster-defaults/input.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-two-project-defaults/existing.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-project-defaults/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-two-project-defaults/existing.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-project-defaults/existing.yaml diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-two-cluster-defaults/expected.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-project-defaults/expected.yaml similarity index 74% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-two-cluster-defaults/expected.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-project-defaults/expected.yaml index d8b5915a0..c62bd0c6c 100644 --- a/pkg/controller/defaults/testdata/volumeclass/volume-class-two-cluster-defaults/expected.yaml +++ b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-project-defaults/expected.yaml @@ -22,7 +22,7 @@ status: foo: {} conditions: - error: true - message: 'cannot establish defaults because two defaults volume classes exist: test-volume-class and test-volume-class-1' + message: 'cannot resolve volume classes because two defaults volume classes exist: test-volume-class and test-volume-class-1' reason: Error status: "False" - type: defaults + type: resolved-offerings diff --git a/pkg/controller/defaults/testdata/volumeclass/volume-class-two-project-defaults/input.yaml b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-project-defaults/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-two-project-defaults/input.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-project-defaults/input.yaml diff --git a/pkg/controller/defaults/volumeclass.go b/pkg/controller/resolvedofferings/volumeclass.go similarity index 56% rename from pkg/controller/defaults/volumeclass.go rename to pkg/controller/resolvedofferings/volumeclass.go index b841d81b1..92db0eaf1 100644 --- a/pkg/controller/defaults/volumeclass.go +++ b/pkg/controller/resolvedofferings/volumeclass.go @@ -1,4 +1,4 @@ -package defaults +package resolvedofferings import ( "context" @@ -11,7 +11,7 @@ import ( kclient "sigs.k8s.io/controller-runtime/pkg/client" ) -func addVolumeClassDefaults(ctx context.Context, c kclient.Client, app *v1.AppInstance) error { +func resolveVolumeClasses(ctx context.Context, c kclient.Client, app *v1.AppInstance) error { if len(app.Status.AppSpec.Volumes) == 0 { return nil } @@ -24,12 +24,12 @@ func addVolumeClassDefaults(ctx context.Context, c kclient.Client, app *v1.AppIn 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) + return fmt.Errorf("cannot resolve volume classes 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) + if app.Status.ResolvedOfferings.Volumes == nil { + app.Status.ResolvedOfferings.Volumes = make(map[string]v1.VolumeResolvedOffering) } volumeBindings := volume.SliceToMap(app.Spec.Volumes, func(vb v1.VolumeBinding) string { @@ -37,42 +37,44 @@ func addVolumeClassDefaults(ctx context.Context, c kclient.Client, app *v1.AppIn }) for name, vol := range app.Status.AppSpec.Volumes { - volDefaults := app.Status.Defaults.Volumes[name] - vol = volume.CopyVolumeDefaults(vol, volumeBindings[name], volDefaults) + resolvedVolume := app.Status.ResolvedOfferings.Volumes[name] + vol = volume.ResolveVolumeRequest(vol, volumeBindings[name], resolvedVolume) // 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]. + // 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.Defaults.VolumeSize != nil && volDefaults.Size == "" { - volDefaults.Size = v1.Quantity(app.Status.Defaults.VolumeSize.String()) + if app.Status.ResolvedOfferings.VolumeSize != nil && resolvedVolume.Size == "" { + resolvedVolume.Size = v1.Quantity(app.Status.ResolvedOfferings.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 _, alreadySet := app.Status.ResolvedOfferings.Volumes[name]; !alreadySet { + resolvedVolume.Class = vol.Class if vol.Class == "" && defaultVolumeClass != nil { - volDefaults.Class = defaultVolumeClass.Name - vol.Class = volDefaults.Class + resolvedVolume.Class = defaultVolumeClass.Name + vol.Class = defaultVolumeClass.Name } + + resolvedVolume.AccessModes = vol.AccessModes if len(vol.AccessModes) == 0 { - volDefaults.AccessModes = volumeClasses[vol.Class].AllowedAccessModes + resolvedVolume.AccessModes = volumeClasses[vol.Class].AllowedAccessModes } + + resolvedVolume.Size = vol.Size if vol.Size == "" { - volDefaults.Size = volumeClasses[vol.Class].Size.Default - if volDefaults.Size == "" { + resolvedVolume.Size = volumeClasses[vol.Class].Size.Default + if resolvedVolume.Size == "" { defaultSize, err := getDefaultVolumeSize(ctx, c) if err != nil { return err } - volDefaults.Size = defaultSize + resolvedVolume.Size = defaultSize } } } - app.Status.Defaults.Volumes[name] = volDefaults + app.Status.ResolvedOfferings.Volumes[name] = resolvedVolume } return nil diff --git a/pkg/controller/defaults/volumeclass_test.go b/pkg/controller/resolvedofferings/volumeclass_test.go similarity index 92% rename from pkg/controller/defaults/volumeclass_test.go rename to pkg/controller/resolvedofferings/volumeclass_test.go index b0a97b143..1392ea034 100644 --- a/pkg/controller/defaults/volumeclass_test.go +++ b/pkg/controller/resolvedofferings/volumeclass_test.go @@ -1,4 +1,4 @@ -package defaults +package resolvedofferings import ( "testing" @@ -13,10 +13,6 @@ 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/routes.go b/pkg/controller/routes.go index fbbf9850d..43a5b671e 100644 --- a/pkg/controller/routes.go +++ b/pkg/controller/routes.go @@ -12,7 +12,6 @@ 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" @@ -24,6 +23,7 @@ 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(defaults.Calculate) + appHasNamespace.HandlerFunc(resolvedofferings.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(defaults.SetDefaultRegion) + router.Type(&v1.BuilderInstance{}).HandlerFunc(resolvedofferings.SetDefaultRegion) router.Type(&v1.BuilderInstance{}).HandlerFunc(builder.DeployBuilder) - router.Type(&v1.AcornImageBuildInstance{}).HandlerFunc(defaults.SetDefaultRegion) + router.Type(&v1.AcornImageBuildInstance{}).HandlerFunc(resolvedofferings.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 cded2eabf..ddab4f530 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, ok := app.Status.Defaults.Memory[containerName]; ok && val != nil { - memDefault = val - } else if val, ok := app.Status.Defaults.Memory[""]; ok && val != nil { - memDefault = val + if val, ok := app.Status.ResolvedOfferings.Containers[containerName]; ok && val.Memory != nil { + memDefault = val.Memory + } else if val, ok := app.Status.ResolvedOfferings.Containers[""]; ok && val.Memory != nil { + memDefault = val.Memory } 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 0a2cb4afb..7f5d067aa 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,13 +45,16 @@ 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 11cf4cbc3..e08dc0901 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,11 +11,14 @@ spec: oneimage: sample-compute-class-01 # 2Mi status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 2097152 # 2Mi - oneimage: 2097152 # 2Mi + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 2097152 # 2Mi + oneimage: + memory: 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 92115fed7..512047a02 100644 --- a/pkg/controller/scheduling/testdata/computeclass/all-set/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/all-set/expected.golden @@ -44,13 +44,16 @@ 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 7beaac334..42954b1c1 100644 --- a/pkg/controller/scheduling/testdata/computeclass/all-set/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/all-set/input.yaml @@ -10,11 +10,14 @@ spec: "": sample-compute-class status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 1048576 # 1Mi - oneimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 # 1Mi + oneimage: + memory: 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 88d74ed06..c478281ab 100644 --- a/pkg/controller/scheduling/testdata/computeclass/container/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/container/expected.golden @@ -44,13 +44,16 @@ 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 87f825ae1..89f9d50b1 100644 --- a/pkg/controller/scheduling/testdata/computeclass/container/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/container/input.yaml @@ -10,15 +10,17 @@ spec: oneimage: sample-compute-class status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 1048576 # 1Mi - oneimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 # 1Mi + oneimage: + memory: 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 690a372d8..3a073b235 100644 --- a/pkg/controller/scheduling/testdata/computeclass/different-computeclass/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/different-computeclass/expected.golden @@ -47,13 +47,16 @@ 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 32b565c62..64ec43c44 100644 --- a/pkg/controller/scheduling/testdata/computeclass/different-computeclass/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/different-computeclass/input.yaml @@ -11,11 +11,14 @@ spec: oneimage: sample-compute-class status: observedGeneration: 1 - defaults: - memory: - "": 0 - oneimage: 2097152 # 2Mi - twoimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 + oneimage: + memory: 2097152 # 2Mi + twoimage: + memory: 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 b9a567d32..1d2190001 100644 --- a/pkg/controller/scheduling/testdata/computeclass/different-digest-generation/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/different-digest-generation/expected.golden @@ -45,13 +45,16 @@ 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 dcc73eb10..a1bdf7e45 100644 --- a/pkg/controller/scheduling/testdata/computeclass/different-digest-generation/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/different-digest-generation/input.yaml @@ -10,11 +10,14 @@ spec: oneimage: sample-compute-class status: observedImageDigest: foo - defaults: - memory: - "": 0 - left: 1048576 # 1Mi - oneimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 # 1Mi + oneimage: + memory: 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 0a1b8f50f..046198097 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,13 +44,16 @@ 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 e4af313da..2247d8b9d 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,11 +7,14 @@ metadata: spec: image: test status: - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 0 + oneimage: + memory: 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 4fbf7b27b..fb72e0e8a 100644 --- a/pkg/controller/scheduling/testdata/computeclass/job/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/job/expected.golden @@ -44,13 +44,16 @@ 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 60dd79c1e..a6ff9cccd 100644 --- a/pkg/controller/scheduling/testdata/computeclass/job/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/job/input.yaml @@ -10,11 +10,14 @@ spec: oneimage: sample-compute-class status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 1048576 # 1Mi - oneimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 # 1Mi + oneimage: + memory: 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 04436e2ec..5811e6d4d 100644 --- a/pkg/controller/scheduling/testdata/computeclass/overwrite-acornfile-computeclass/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/overwrite-acornfile-computeclass/expected.golden @@ -45,13 +45,16 @@ 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 d2c6e18f1..bd6c9ec6d 100644 --- a/pkg/controller/scheduling/testdata/computeclass/overwrite-acornfile-computeclass/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/overwrite-acornfile-computeclass/input.yaml @@ -10,11 +10,14 @@ spec: oneimage: sample-compute-class status: observedGeneration: 1 - defaults: - memory: - "": 0 # 1Mi - left: 1048576 # 1Mi - oneimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 # 1Mi + left: + memory: 1048576 # 1Mi + oneimage: + memory: 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 637e03d17..53aa9b8e9 100644 --- a/pkg/controller/scheduling/testdata/computeclass/priority-class/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/priority-class/expected.golden @@ -42,13 +42,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: 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 e4af313da..2247d8b9d 100644 --- a/pkg/controller/scheduling/testdata/computeclass/priority-class/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/priority-class/input.yaml @@ -7,11 +7,14 @@ metadata: spec: image: test status: - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 0 + oneimage: + memory: 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 01362fc8f..11953e733 100644 --- a/pkg/controller/scheduling/testdata/computeclass/same-digest-generation/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/same-digest-generation/expected.golden @@ -45,13 +45,16 @@ 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 de527cc4d..c7b3809b5 100644 --- a/pkg/controller/scheduling/testdata/computeclass/same-digest-generation/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/same-digest-generation/input.yaml @@ -10,11 +10,14 @@ spec: oneimage: sample-compute-class status: observedImageDigest: foo - defaults: - memory: - "": 0 - left: 1048576 # 1Mi - oneimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 # 1Mi + oneimage: + memory: 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 099032e78..35b457a5a 100644 --- a/pkg/controller/scheduling/testdata/computeclass/same-generation/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/same-generation/expected.golden @@ -44,12 +44,15 @@ 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 6b807c769..e83805311 100644 --- a/pkg/controller/scheduling/testdata/computeclass/same-generation/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/same-generation/input.yaml @@ -9,11 +9,14 @@ spec: computeClass: oneimage: sample-compute-class status: - defaults: - memory: - "": 0 - left: 1048576 # 1Mi - oneimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 # 1Mi + oneimage: + memory: 1048576 # 1Mi # In this test, scheduling has already been set and should not get recalculated # since the generation is the same. scheduling: @@ -43,7 +46,6 @@ 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 8529f849a..fa991d2e2 100644 --- a/pkg/controller/scheduling/testdata/computeclass/sidecar/expected.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/sidecar/expected.yaml @@ -9,9 +9,10 @@ spec: computeClass: left: sample-compute-class status: - defaults: - memory: - left: 1048576 # 1Mi + resolvedOfferings: + containers: + left: + memory: 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 c770ce0dc..cb33defaf 100644 --- a/pkg/controller/scheduling/testdata/computeclass/sidecar/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/sidecar/input.yaml @@ -9,9 +9,10 @@ spec: computeClass: left: sample-compute-class status: - defaults: - memory: - left: 1048576 # 1Mi + resolvedOfferings: + containers: + left: + memory: 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 54416cac0..a3873c96a 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,11 +10,14 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 1048576 # 1Mi - oneimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 # 1Mi + oneimage: + memory: 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 15b4b2241..b79fed85b 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,11 +9,14 @@ spec: memory: oneimage: 1048576 # 1Mi status: - defaults: - memory: - "": 0 - left: 1048576 # 1Mi - oneimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 # 1Mi + oneimage: + memory: 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 648117340..64c589d6f 100644 --- a/pkg/controller/scheduling/testdata/computeclass/two-containers/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/two-containers/expected.golden @@ -46,13 +46,16 @@ 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 da4ee1770..7d8a6c184 100644 --- a/pkg/controller/scheduling/testdata/computeclass/two-containers/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/two-containers/input.yaml @@ -10,11 +10,14 @@ spec: oneimage: sample-compute-class status: observedGeneration: 1 - defaults: - memory: - "": 0 - oneimage: 1048576 # 1Mi - twoimage: 0 + resolvedOfferings: + containers: + "": + memory: 0 + oneimage: + memory: 1048576 # 1Mi + twoimage: + memory: 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 a603062f3..4fd991694 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,11 +9,14 @@ spec: memory: oneimage: 1048576 # 1Mi status: - defaults: - memory: - "": 0 - left: 1048576 # 1Mi - oneimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 # 1Mi + oneimage: + memory: 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 15b4b2241..b79fed85b 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,11 +9,14 @@ spec: memory: oneimage: 1048576 # 1Mi status: - defaults: - memory: - "": 0 - left: 1048576 # 1Mi - oneimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 # 1Mi + oneimage: + memory: 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 ffbcfb00f..92c5593c7 100644 --- a/pkg/controller/scheduling/testdata/computeclass/with-acornfile-computeclass/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/with-acornfile-computeclass/expected.golden @@ -43,13 +43,16 @@ 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 f9b0016b2..c2d7eaf3c 100644 --- a/pkg/controller/scheduling/testdata/computeclass/with-acornfile-computeclass/input.yaml +++ b/pkg/controller/scheduling/testdata/computeclass/with-acornfile-computeclass/input.yaml @@ -8,11 +8,14 @@ spec: image: test status: observedGeneration: 1 - defaults: - memory: - "": 0 # 1Mi - left: 1048576 # 1Mi - oneimage: 1048576 # 1Mi + resolvedOfferings: + containers: + "": + memory: 0 # 1Mi + left: + memory: 1048576 # 1Mi + oneimage: + memory: 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 215d2dc70..a7aacea7a 100644 --- a/pkg/controller/scheduling/testdata/memory/all-set-overwrite/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/all-set-overwrite/expected.golden @@ -45,13 +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: 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 186126455..0b2f416a8 100644 --- a/pkg/controller/scheduling/testdata/memory/all-set-overwrite/input.yaml +++ b/pkg/controller/scheduling/testdata/memory/all-set-overwrite/input.yaml @@ -11,11 +11,14 @@ spec: oneimage: 2097152 # 2Mi status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 1048576 + left: + memory: 2097152 + oneimage: + memory: 2097152 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 d2ebab294..4ad6dac9c 100644 --- a/pkg/controller/scheduling/testdata/memory/all-set/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/all-set/expected.golden @@ -44,13 +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: 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 147bac977..175a2f2e9 100644 --- a/pkg/controller/scheduling/testdata/memory/all-set/input.yaml +++ b/pkg/controller/scheduling/testdata/memory/all-set/input.yaml @@ -10,11 +10,14 @@ spec: "": 1048576 # 1Mi status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 1048576 + left: + memory: 1048576 + oneimage: + memory: 1048576 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 d31531e73..d04d03c82 100644 --- a/pkg/controller/scheduling/testdata/memory/container/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/container/expected.golden @@ -44,16 +44,23 @@ 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: {} + requirements: + limits: + memory: 1Mi + requests: + memory: 1Mi oneimage: requirements: limits: diff --git a/pkg/controller/scheduling/testdata/memory/container/input.yaml b/pkg/controller/scheduling/testdata/memory/container/input.yaml index 96e9aa9c2..dd46be237 100644 --- a/pkg/controller/scheduling/testdata/memory/container/input.yaml +++ b/pkg/controller/scheduling/testdata/memory/container/input.yaml @@ -10,11 +10,14 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 + oneimage: + memory: 1048576 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 81eba6dca..3f38bd32c 100644 --- a/pkg/controller/scheduling/testdata/memory/job/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/job/expected.golden @@ -44,16 +44,23 @@ 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: {} + requirements: + limits: + memory: 1Mi + requests: + memory: 1Mi oneimage: requirements: limits: diff --git a/pkg/controller/scheduling/testdata/memory/job/input.yaml b/pkg/controller/scheduling/testdata/memory/job/input.yaml index ad4e1af34..b59bdfc2a 100644 --- a/pkg/controller/scheduling/testdata/memory/job/input.yaml +++ b/pkg/controller/scheduling/testdata/memory/job/input.yaml @@ -10,11 +10,14 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 + oneimage: + memory: 1048576 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 816279731..66aaecfa0 100644 --- a/pkg/controller/scheduling/testdata/memory/overwrite-acornfile-memory/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/overwrite-acornfile-memory/expected.golden @@ -45,16 +45,23 @@ 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: {} + requirements: + limits: + memory: 1Mi + requests: + memory: 1Mi 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 3515d3bf2..35c60cccb 100644 --- a/pkg/controller/scheduling/testdata/memory/overwrite-acornfile-memory/input.yaml +++ b/pkg/controller/scheduling/testdata/memory/overwrite-acornfile-memory/input.yaml @@ -10,11 +10,14 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 + oneimage: + memory: 1048576 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 c244d03de..557833c01 100644 --- a/pkg/controller/scheduling/testdata/memory/same-generation/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/same-generation/expected.golden @@ -44,12 +44,15 @@ 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 2324366d0..6502d95cf 100644 --- a/pkg/controller/scheduling/testdata/memory/same-generation/input.yaml +++ b/pkg/controller/scheduling/testdata/memory/same-generation/input.yaml @@ -9,11 +9,14 @@ spec: memory: oneimage: 1048576 # 1Mi status: - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 + oneimage: + memory: 1048576 # 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 19cbe99a0..c0cdf455e 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 653ca3172..fc22f0a5d 100644 --- a/pkg/controller/scheduling/testdata/memory/two-containers/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/two-containers/expected.golden @@ -46,13 +46,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: 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 57f19010c..5d82fd3b3 100644 --- a/pkg/controller/scheduling/testdata/memory/two-containers/input.yaml +++ b/pkg/controller/scheduling/testdata/memory/two-containers/input.yaml @@ -10,11 +10,14 @@ spec: oneimage: 1048576 # 1Mi status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 + oneimage: + memory: 1048576 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 8a78515e4..267467dd2 100644 --- a/pkg/controller/scheduling/testdata/memory/with-acornfile-memory/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/with-acornfile-memory/expected.golden @@ -43,16 +43,23 @@ 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: {} + requirements: + limits: + memory: 1Mi + requests: + memory: 1Mi 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 403426169..5745280f7 100644 --- a/pkg/controller/scheduling/testdata/memory/with-acornfile-memory/input.yaml +++ b/pkg/controller/scheduling/testdata/memory/with-acornfile-memory/input.yaml @@ -8,11 +8,14 @@ spec: image: test status: observedGeneration: 1 - defaults: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: + containers: + "": + memory: 0 + left: + memory: 1048576 + oneimage: + memory: 1048576 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 e04e1a4b4..9d769b0a1 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 1d97481e4..701e1c7c8 100644 --- a/pkg/controller/scheduling/testdata/tolerations/container/input.yaml +++ b/pkg/controller/scheduling/testdata/tolerations/container/input.yaml @@ -11,7 +11,6 @@ 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 fedff8320..c825f1eb6 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 bd80e65ca..b115f940d 100644 --- a/pkg/controller/scheduling/testdata/tolerations/job/input.yaml +++ b/pkg/controller/scheduling/testdata/tolerations/job/input.yaml @@ -11,7 +11,6 @@ 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 cbcb114fd..1643f237a 100644 --- a/pkg/labels/labels.go +++ b/pkg/labels/labels.go @@ -61,6 +61,7 @@ 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 985f6ed93..554f24d35 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,6 +192,7 @@ 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), @@ -216,9 +217,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), @@ -7015,10 +7016,10 @@ func schema_pkg_apis_internalacornio_v1_AppInstanceStatus(ref common.ReferenceCa }, }, }, - "defaults": { + "resolvedOfferings": { SchemaProps: spec.SchemaProps{ Default: map[string]interface{}{}, - Ref: ref("github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.Defaults"), + Ref: ref("github.com/acorn-io/runtime/pkg/apis/internal.acorn.io/v1.ResolvedOfferings"), }, }, "summary": { @@ -7058,7 +7059,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.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"}, + "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"}, } } @@ -8486,6 +8487,36 @@ 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{ @@ -8635,59 +8666,6 @@ 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{ @@ -11026,6 +11004,59 @@ 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{ @@ -12719,44 +12750,6 @@ 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{ @@ -12881,6 +12874,44 @@ 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 8069908d5..bb0f6ebd6 100644 --- a/pkg/server/registry/apigroups/acorn/apps/validator.go +++ b/pkg/server/registry/apigroups/acorn/apps/validator.go @@ -258,7 +258,7 @@ func (s *Validator) ValidateUpdate(ctx context.Context, obj, old runtime.Object) } } - if newParams.Spec.Region != oldParams.Spec.Region && newParams.Spec.Region != oldParams.Status.Defaults.Region { + if newParams.Spec.Region != oldParams.Spec.Region && newParams.Spec.Region != oldParams.Status.ResolvedOfferings.Region { result = append(result, field.Invalid(field.NewPath("spec", "region"), newParams.Spec.Region, "cannot change region")) return result } @@ -710,7 +710,7 @@ func validateVolumeClasses(ctx context.Context, c kclient.Client, namespace stri var volClass apiv1.VolumeClass for volName, vol := range appSpec.Volumes { - calculatedVolumeRequest := volume.CopyVolumeDefaults(vol, volumeBindings[volName], v1.VolumeDefault{}) + calculatedVolumeRequest := volume.ResolveVolumeRequest(vol, volumeBindings[volName], v1.VolumeResolvedOffering{}) 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 48ea39d6c..f7f95f4f5 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{ - Defaults: internalv1.Defaults{ + ResolvedOfferings: internalv1.ResolvedOfferings{ 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 9e67c7363..f22052bd3 100644 --- a/pkg/server/registry/apigroups/acorn/projects/validator_test.go +++ b/pkg/server/registry/apigroups/acorn/projects/validator_test.go @@ -236,6 +236,11 @@ func TestProjectUpdateValidation(t *testing.T) { Spec: v1.AppInstanceSpec{ Region: "my-region", }, + Status: v1.AppInstanceStatus{ + ResolvedOfferings: v1.ResolvedOfferings{ + Region: "my-region", + }, + }, }, }, }, @@ -272,6 +277,11 @@ func TestProjectUpdateValidation(t *testing.T) { Spec: v1.AppInstanceSpec{ Region: "my-region", }, + Status: v1.AppInstanceStatus{ + ResolvedOfferings: v1.ResolvedOfferings{ + Region: "my-region", + }, + }, }, }, }, @@ -313,6 +323,11 @@ func TestProjectUpdateValidation(t *testing.T) { Spec: v1.AppInstanceSpec{ Region: "my-other-region", }, + Status: v1.AppInstanceStatus{ + ResolvedOfferings: v1.ResolvedOfferings{ + Region: "my-other-region", + }, + }, }, }, }, @@ -397,7 +412,7 @@ func TestProjectUpdateValidation(t *testing.T) { Namespace: "my-project", }, Status: v1.AppInstanceStatus{ - Defaults: v1.Defaults{ + ResolvedOfferings: v1.ResolvedOfferings{ Region: "my-other-region", }, }, @@ -446,6 +461,11 @@ func TestProjectUpdateValidation(t *testing.T) { Spec: v1.AppInstanceSpec{ Region: "my-other-region", }, + Status: v1.AppInstanceStatus{ + ResolvedOfferings: v1.ResolvedOfferings{ + Region: "my-other-region", + }, + }, }, }, }, @@ -488,6 +508,11 @@ 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{ @@ -497,6 +522,11 @@ func TestProjectUpdateValidation(t *testing.T) { Spec: v1.AppInstanceSpec{ Region: "my-region", }, + Status: v1.AppInstanceStatus{ + ResolvedOfferings: v1.ResolvedOfferings{ + Region: "my-region", + }, + }, }, }, }, @@ -539,6 +569,11 @@ func TestProjectUpdateValidation(t *testing.T) { Spec: v1.AppInstanceSpec{ Region: "my-other-region", }, + Status: v1.AppInstanceStatus{ + ResolvedOfferings: v1.ResolvedOfferings{ + Region: "my-other-region", + }, + }, }, }, }, @@ -579,6 +614,11 @@ 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 96a7b2b31..851114135 100644 --- a/pkg/volume/volume.go +++ b/pkg/volume/volume.go @@ -151,24 +151,30 @@ func getVolumeClassNames(volumeClasses map[string]adminv1.ProjectVolumeClassInst return typed.SortedKeys(storageClassName) } -func CopyVolumeDefaults(volumeRequest v1.VolumeRequest, volumeBinding v1.VolumeBinding, volumeDefaults v1.VolumeDefault) v1.VolumeRequest { +func ResolveVolumeRequest(volumeRequest v1.VolumeRequest, volumeBinding v1.VolumeBinding, resolvedVolume v1.VolumeResolvedOffering) v1.VolumeRequest { + // Order of precedence: + // 1. VolumeResolvedOffering - the previously resolved values for Class, Size, and AccessModes + // 2. VolumeBinding - the values set by the user in the app spec + // 3. VolumeRequest - the defaults as defined in the acorn image + bind := volumeBinding.Volume != "" - if volumeBinding.Class != "" { + + if !bind && resolvedVolume.Class != "" { + volumeRequest.Class = resolvedVolume.Class + } else if volumeBinding.Class != "" { volumeRequest.Class = volumeBinding.Class - } else if !bind && volumeRequest.Class == "" { - volumeRequest.Class = volumeDefaults.Class } - if volumeBinding.Size != "" { + if !bind && resolvedVolume.Size != "" { + volumeRequest.Size = resolvedVolume.Size + } else if volumeBinding.Size != "" { volumeRequest.Size = volumeBinding.Size - } else if !bind && volumeRequest.Size == "" { - volumeRequest.Size = volumeDefaults.Size } - if len(volumeBinding.AccessModes) != 0 { + if len(resolvedVolume.AccessModes) != 0 { + volumeRequest.AccessModes = resolvedVolume.AccessModes + } else if len(volumeBinding.AccessModes) != 0 { volumeRequest.AccessModes = volumeBinding.AccessModes - } else if len(volumeRequest.AccessModes) == 0 { - volumeRequest.AccessModes = volumeDefaults.AccessModes } return volumeRequest