diff --git a/pkg/apis/internal.acorn.io/v1/appinstance.go b/pkg/apis/internal.acorn.io/v1/appinstance.go index ed0ee881c1..3fe4acbdf0 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" diff --git a/pkg/controller/appdefinition/deploy.go b/pkg/controller/appdefinition/deploy.go index b0000f9a40..9e182ef1fc 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/computeclass/all-set-overwrite-computeclass/expected.golden b/pkg/controller/appdefinition/testdata/computeclass/all-set-overwrite-computeclass/expected.golden index c7d5613d25..c4c4a385bf 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 @@ -224,7 +224,7 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true @@ -235,11 +235,7 @@ status: type: defined namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 2097152 - oneimage: 2097152 + resolvedOfferings: {} 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 0ac012be92..0caaff91b0 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 @@ -63,7 +63,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 a10dca4017..762a39ea2c 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/all-set/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/all-set/expected.golden @@ -223,7 +223,7 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true @@ -234,11 +234,7 @@ status: type: defined namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} 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 7ecb1339b3..8eb98cd122 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/all-set/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/all-set/input.yaml @@ -61,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/container/expected.golden b/pkg/controller/appdefinition/testdata/computeclass/container/expected.golden index c3f70cf58e..32d389a78f 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/container/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/container/expected.golden @@ -223,7 +223,7 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true @@ -234,11 +234,7 @@ status: type: defined namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: requirements: diff --git a/pkg/controller/appdefinition/testdata/computeclass/container/input.yaml b/pkg/controller/appdefinition/testdata/computeclass/container/input.yaml index 7e0a8561d1..213329b89d 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/container/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/container/input.yaml @@ -61,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/different-computeclass/expected.golden b/pkg/controller/appdefinition/testdata/computeclass/different-computeclass/expected.golden index 0f03c58b49..178bbd7db1 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/different-computeclass/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/different-computeclass/expected.golden @@ -372,7 +372,7 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true @@ -383,11 +383,7 @@ status: type: defined namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - oneimage: 2097152 - twoimage: 1048576 + resolvedOfferings: {} 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 272f6b5491..7d8b35529e 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/different-computeclass/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/different-computeclass/input.yaml @@ -73,7 +73,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 6b4f256173..3dc98bd39d 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/job/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/job/expected.golden @@ -222,7 +222,7 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true @@ -233,11 +233,7 @@ status: type: defined namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: requirements: diff --git a/pkg/controller/appdefinition/testdata/computeclass/job/input.yaml b/pkg/controller/appdefinition/testdata/computeclass/job/input.yaml index b88afe6a79..08160093da 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/job/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/job/input.yaml @@ -61,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/overwrite-acornfile-computeclass/expected.golden b/pkg/controller/appdefinition/testdata/computeclass/overwrite-acornfile-computeclass/expected.golden index cde19de5fd..de3e556e93 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/overwrite-acornfile-computeclass/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/overwrite-acornfile-computeclass/expected.golden @@ -224,7 +224,7 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true @@ -235,11 +235,7 @@ status: type: defined namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} 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 73f7599f04..5c259decee 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/overwrite-acornfile-computeclass/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/overwrite-acornfile-computeclass/input.yaml @@ -62,7 +62,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 a35c87b08b..bedd10ae55 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 @@ -34,7 +34,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 3cfdc75a8b..d286435776 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/sidecar/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/sidecar/input.yaml @@ -34,7 +34,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 11f30c640b..aec91b3ba4 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/two-containers/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/two-containers/expected.golden @@ -357,7 +357,7 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true @@ -368,11 +368,7 @@ status: type: defined namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - oneimage: 1048576 - twoimage: 0 + resolvedOfferings: {} 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 8aa4154ec7..99c13533af 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/two-containers/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/two-containers/input.yaml @@ -58,7 +58,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 b5e1288253..039ed619f6 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/with-acornfile-computeclass/expected.golden +++ b/pkg/controller/appdefinition/testdata/computeclass/with-acornfile-computeclass/expected.golden @@ -222,7 +222,7 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true @@ -233,11 +233,7 @@ status: type: defined namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} 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 464308b1ea..ed271cce7b 100644 --- a/pkg/controller/appdefinition/testdata/computeclass/with-acornfile-computeclass/input.yaml +++ b/pkg/controller/appdefinition/testdata/computeclass/with-acornfile-computeclass/input.yaml @@ -60,7 +60,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/memory/all-set-overwrite/expected.golden b/pkg/controller/appdefinition/testdata/memory/all-set-overwrite/expected.golden index 51d9ed261e..e9aca02085 100644 --- a/pkg/controller/appdefinition/testdata/memory/all-set-overwrite/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/all-set-overwrite/expected.golden @@ -217,18 +217,14 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true type: defined namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 1048576 - left: 2097152 - oneimage: 2097152 + resolvedOfferings: {} 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 0262e670d9..fbeb981fd6 100644 --- a/pkg/controller/appdefinition/testdata/memory/all-set-overwrite/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/all-set-overwrite/input.yaml @@ -55,7 +55,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 cb602f5f46..a04271e435 100644 --- a/pkg/controller/appdefinition/testdata/memory/all-set/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/all-set/expected.golden @@ -216,18 +216,14 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true type: defined namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 1048576 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} 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 52a858aba2..28163d658a 100644 --- a/pkg/controller/appdefinition/testdata/memory/all-set/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/all-set/input.yaml @@ -54,7 +54,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 fe845eb1a0..2a197cd9f5 100644 --- a/pkg/controller/appdefinition/testdata/memory/container/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/container/expected.golden @@ -212,18 +212,14 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true type: defined namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: requirements: {} diff --git a/pkg/controller/appdefinition/testdata/memory/container/input.yaml b/pkg/controller/appdefinition/testdata/memory/container/input.yaml index 6b3270dd3b..7792b6cb74 100644 --- a/pkg/controller/appdefinition/testdata/memory/container/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/container/input.yaml @@ -50,7 +50,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 3793d18027..88681dfa92 100644 --- a/pkg/controller/appdefinition/testdata/memory/job/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/job/expected.golden @@ -211,18 +211,14 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true type: defined namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: requirements: {} diff --git a/pkg/controller/appdefinition/testdata/memory/job/input.yaml b/pkg/controller/appdefinition/testdata/memory/job/input.yaml index 84255b15c8..4dd9623636 100644 --- a/pkg/controller/appdefinition/testdata/memory/job/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/job/input.yaml @@ -50,7 +50,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 aded073249..8998b6dffd 100644 --- a/pkg/controller/appdefinition/testdata/memory/overwrite-acornfile-memory/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/overwrite-acornfile-memory/expected.golden @@ -213,18 +213,14 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true type: defined namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} 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 0b5bb974b6..78e419e79a 100644 --- a/pkg/controller/appdefinition/testdata/memory/overwrite-acornfile-memory/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/overwrite-acornfile-memory/input.yaml @@ -51,7 +51,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 877ce5fb91..42c184b225 100644 --- a/pkg/controller/appdefinition/testdata/memory/sidecar/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/sidecar/expected.golden @@ -212,18 +212,14 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true type: defined namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: requirements: diff --git a/pkg/controller/appdefinition/testdata/memory/sidecar/input.yaml b/pkg/controller/appdefinition/testdata/memory/sidecar/input.yaml index 59fcb36ff5..0d6cd57434 100644 --- a/pkg/controller/appdefinition/testdata/memory/sidecar/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/sidecar/input.yaml @@ -50,7 +50,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 2895e66011..6d423d17fa 100644 --- a/pkg/controller/appdefinition/testdata/memory/two-containers/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/two-containers/expected.golden @@ -351,18 +351,14 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true type: defined namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} 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 716c379b62..0aa7e208c3 100644 --- a/pkg/controller/appdefinition/testdata/memory/two-containers/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/two-containers/input.yaml @@ -52,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/memory/with-acornfile-memory/expected.golden b/pkg/controller/appdefinition/testdata/memory/with-acornfile-memory/expected.golden index 752e2cac79..570a47436e 100644 --- a/pkg/controller/appdefinition/testdata/memory/with-acornfile-memory/expected.golden +++ b/pkg/controller/appdefinition/testdata/memory/with-acornfile-memory/expected.golden @@ -211,18 +211,14 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings reason: Success status: "True" success: true type: defined namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} 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 7d239cdcef..2105b23835 100644 --- a/pkg/controller/appdefinition/testdata/memory/with-acornfile-memory/input.yaml +++ b/pkg/controller/appdefinition/testdata/memory/with-acornfile-memory/input.yaml @@ -49,7 +49,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/appstatus/check.go b/pkg/controller/appstatus/check.go index fb7f9ffc72..05a6c0498e 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 1741b1dd55..9bd6033ddf 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/resolvedofferings/computeclass.go similarity index 82% rename from pkg/controller/defaults/memory.go rename to pkg/controller/resolvedofferings/computeclass.go index d75eccefc0..72552a085e 100644 --- a/pkg/controller/defaults/memory.go +++ b/pkg/controller/resolvedofferings/computeclass.go @@ -1,4 +1,4 @@ -package defaults +package resolvedofferings import ( "github.com/acorn-io/baaah/pkg/router" @@ -9,9 +9,8 @@ import ( 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 { +// 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{} } @@ -29,6 +28,7 @@ func addDefaultMemory(req router.Request, cfg *apiv1.Config, appInstance *v1.App } } + // Set the default for all containers, noted by the empty string appInstance.Status.ResolvedOfferings.Containers[""] = v1.ContainerResolvedOffering{ Memory: cfg.WorkloadMemoryDefault, Class: defaultCC, @@ -50,6 +50,7 @@ func addDefaultMemory(req router.Request, cfg *apiv1.Config, appInstance *v1.App } } + // Set the compute class info for each container and job individually if err := resolveWorkloadMemory(req, appInstance, cfg.WorkloadMemoryDefault, cc, defaultCC, appInstance.Status.AppSpec.Containers); err != nil { return err } @@ -81,7 +82,13 @@ func resolveWorkloadMemory(req router.Request, appInstance *v1.AppInstance, conf ccName = defaultCCName } - memory := configDefault + // 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 diff --git a/pkg/controller/defaults/memory_test.go b/pkg/controller/resolvedofferings/computeclass_test.go similarity index 98% rename from pkg/controller/defaults/memory_test.go rename to pkg/controller/resolvedofferings/computeclass_test.go index 5df464f24c..c395a7deb0 100644 --- a/pkg/controller/defaults/memory_test.go +++ b/pkg/controller/resolvedofferings/computeclass_test.go @@ -1,4 +1,4 @@ -package defaults +package resolvedofferings import ( "testing" diff --git a/pkg/controller/defaults/region.go b/pkg/controller/resolvedofferings/region.go similarity index 96% rename from pkg/controller/defaults/region.go rename to pkg/controller/resolvedofferings/region.go index 5ae355ae99..94fc98c290 100644 --- a/pkg/controller/defaults/region.go +++ b/pkg/controller/resolvedofferings/region.go @@ -1,4 +1,4 @@ -package defaults +package resolvedofferings import ( "context" 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 2069f77ec4..d32551751a 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 0e97e3fc8b..388abe427b 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/defaults/testdata/memory/all-set-overwrite/existing.yaml b/pkg/controller/resolvedofferings/testdata/memory/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/memory/all-set-overwrite/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/all-set-overwrite/expected.golden b/pkg/controller/resolvedofferings/testdata/memory/all-set-overwrite/expected.golden similarity index 87% rename from pkg/controller/defaults/testdata/memory/all-set-overwrite/expected.golden rename to pkg/controller/resolvedofferings/testdata/memory/all-set-overwrite/expected.golden index 6bdce51198..4044306a72 100644 --- a/pkg/controller/defaults/testdata/memory/all-set-overwrite/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/memory/all-set-overwrite/expected.golden @@ -44,14 +44,17 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: - memory: - "": 0 - left: 2097152 - oneimage: 2097152 + containers: + "": + memory: 0 + left: + memory: 2097152 + oneimage: + memory: 2097152 region: local staged: appImage: diff --git a/pkg/controller/defaults/testdata/memory/all-set-overwrite/input.yaml b/pkg/controller/resolvedofferings/testdata/memory/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/memory/all-set-overwrite/input.yaml diff --git a/pkg/controller/defaults/testdata/memory/all-set/existing.yaml b/pkg/controller/resolvedofferings/testdata/memory/all-set/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/all-set/existing.yaml rename to pkg/controller/resolvedofferings/testdata/memory/all-set/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/all-set/expected.golden b/pkg/controller/resolvedofferings/testdata/memory/all-set/expected.golden similarity index 88% rename from pkg/controller/defaults/testdata/memory/all-set/expected.golden rename to pkg/controller/resolvedofferings/testdata/memory/all-set/expected.golden index 8e98a9844d..69f31c9867 100644 --- a/pkg/controller/defaults/testdata/memory/all-set/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/memory/all-set/expected.golden @@ -43,14 +43,17 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: - memory: - "": 0 - left: 0 - oneimage: 0 + containers: + "": + memory: 0 + left: + memory: 0 + oneimage: + memory: 0 region: local staged: appImage: diff --git a/pkg/controller/defaults/testdata/memory/all-set/input.yaml b/pkg/controller/resolvedofferings/testdata/memory/all-set/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/all-set/input.yaml rename to pkg/controller/resolvedofferings/testdata/memory/all-set/input.yaml diff --git a/pkg/controller/defaults/testdata/memory/container/existing.yaml b/pkg/controller/resolvedofferings/testdata/memory/container/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/container/existing.yaml rename to pkg/controller/resolvedofferings/testdata/memory/container/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/container/expected.golden b/pkg/controller/resolvedofferings/testdata/memory/container/expected.golden similarity index 87% rename from pkg/controller/defaults/testdata/memory/container/expected.golden rename to pkg/controller/resolvedofferings/testdata/memory/container/expected.golden index d21dcf2783..f1d13b9b3f 100644 --- a/pkg/controller/defaults/testdata/memory/container/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/memory/container/expected.golden @@ -43,14 +43,17 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + containers: + "": + memory: 0 + left: + memory: 1048576 + oneimage: + memory: 1048576 region: local staged: appImage: diff --git a/pkg/controller/defaults/testdata/memory/container/input.yaml b/pkg/controller/resolvedofferings/testdata/memory/container/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/container/input.yaml rename to pkg/controller/resolvedofferings/testdata/memory/container/input.yaml diff --git a/pkg/controller/defaults/testdata/memory/job/existing.yaml b/pkg/controller/resolvedofferings/testdata/memory/job/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/job/existing.yaml rename to pkg/controller/resolvedofferings/testdata/memory/job/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/expected.golden b/pkg/controller/resolvedofferings/testdata/memory/job/expected.golden similarity index 88% rename from pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/expected.golden rename to pkg/controller/resolvedofferings/testdata/memory/job/expected.golden index 42561f6f84..36968e541b 100644 --- a/pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/memory/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,14 +43,17 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + containers: + "": + memory: 0 + left: + memory: 1048576 + oneimage: + memory: 1048576 region: local staged: appImage: diff --git a/pkg/controller/defaults/testdata/memory/job/input.yaml b/pkg/controller/resolvedofferings/testdata/memory/job/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/job/input.yaml rename to pkg/controller/resolvedofferings/testdata/memory/job/input.yaml diff --git a/pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/existing.yaml b/pkg/controller/resolvedofferings/testdata/memory/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/memory/overwrite-acornfile-memory/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/job/expected.golden b/pkg/controller/resolvedofferings/testdata/memory/overwrite-acornfile-memory/expected.golden similarity index 84% rename from pkg/controller/defaults/testdata/memory/job/expected.golden rename to pkg/controller/resolvedofferings/testdata/memory/overwrite-acornfile-memory/expected.golden index 7e79e03f94..da00b488b4 100644 --- a/pkg/controller/defaults/testdata/memory/job/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/memory/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,14 +44,17 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + containers: + "": + memory: 0 + left: + memory: 1048576 + oneimage: + memory: 1048576 region: local staged: appImage: diff --git a/pkg/controller/defaults/testdata/memory/overwrite-acornfile-memory/input.yaml b/pkg/controller/resolvedofferings/testdata/memory/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/memory/overwrite-acornfile-memory/input.yaml diff --git a/pkg/controller/defaults/testdata/memory/same-generation/expected.golden b/pkg/controller/resolvedofferings/testdata/memory/same-generation/expected.golden similarity index 91% rename from pkg/controller/defaults/testdata/memory/same-generation/expected.golden rename to pkg/controller/resolvedofferings/testdata/memory/same-generation/expected.golden index 9395361b51..d35f71263b 100644 --- a/pkg/controller/defaults/testdata/memory/same-generation/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/memory/same-generation/expected.golden @@ -43,13 +43,9 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace - resolvedOfferings: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: {} staged: appImage: buildContext: {} diff --git a/pkg/controller/defaults/testdata/memory/same-generation/input.yaml b/pkg/controller/resolvedofferings/testdata/memory/same-generation/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/same-generation/input.yaml rename to pkg/controller/resolvedofferings/testdata/memory/same-generation/input.yaml diff --git a/pkg/controller/defaults/testdata/memory/sidecar/existing.yaml b/pkg/controller/resolvedofferings/testdata/memory/sidecar/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/sidecar/existing.yaml rename to pkg/controller/resolvedofferings/testdata/memory/sidecar/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/sidecar/expected.golden b/pkg/controller/resolvedofferings/testdata/memory/sidecar/expected.golden similarity index 88% rename from pkg/controller/defaults/testdata/memory/sidecar/expected.golden rename to pkg/controller/resolvedofferings/testdata/memory/sidecar/expected.golden index 1a899ad811..7ad60b3a3c 100644 --- a/pkg/controller/defaults/testdata/memory/sidecar/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/memory/sidecar/expected.golden @@ -43,14 +43,17 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: - memory: - "": 0 - left: 0 - oneimage: 0 + containers: + "": + memory: 0 + left: + memory: 0 + oneimage: + memory: 0 region: local staged: appImage: diff --git a/pkg/controller/defaults/testdata/memory/sidecar/input.yaml b/pkg/controller/resolvedofferings/testdata/memory/sidecar/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/sidecar/input.yaml rename to pkg/controller/resolvedofferings/testdata/memory/sidecar/input.yaml diff --git a/pkg/controller/defaults/testdata/memory/two-ccc-defaults-should-error/existing.yaml b/pkg/controller/resolvedofferings/testdata/memory/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/memory/two-ccc-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/memory/two-ccc-defaults-should-error/expected.yaml similarity index 96% rename from pkg/controller/defaults/testdata/memory/two-pcc-defaults-should-error/expected.yaml rename to pkg/controller/resolvedofferings/testdata/memory/two-ccc-defaults-should-error/expected.yaml index 66d1c6a699..4380716251 100644 --- a/pkg/controller/defaults/testdata/memory/two-pcc-defaults-should-error/expected.yaml +++ b/pkg/controller/resolvedofferings/testdata/memory/two-ccc-defaults-should-error/expected.yaml @@ -36,6 +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/memory/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/memory/two-ccc-defaults-should-error/input.yaml diff --git a/pkg/controller/defaults/testdata/memory/two-containers/existing.yaml b/pkg/controller/resolvedofferings/testdata/memory/two-containers/existing.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/two-containers/existing.yaml rename to pkg/controller/resolvedofferings/testdata/memory/two-containers/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/two-containers/expected.golden b/pkg/controller/resolvedofferings/testdata/memory/two-containers/expected.golden similarity index 88% rename from pkg/controller/defaults/testdata/memory/two-containers/expected.golden rename to pkg/controller/resolvedofferings/testdata/memory/two-containers/expected.golden index 9edc8ebece..a7a868a011 100644 --- a/pkg/controller/defaults/testdata/memory/two-containers/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/memory/two-containers/expected.golden @@ -45,14 +45,17 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: - memory: - "": 0 - oneimage: 1048576 - twoimage: 0 + containers: + "": + memory: 0 + oneimage: + memory: 1048576 + twoimage: + memory: 0 region: local staged: appImage: diff --git a/pkg/controller/defaults/testdata/memory/two-containers/input.yaml b/pkg/controller/resolvedofferings/testdata/memory/two-containers/input.yaml similarity index 100% rename from pkg/controller/defaults/testdata/memory/two-containers/input.yaml rename to pkg/controller/resolvedofferings/testdata/memory/two-containers/input.yaml diff --git a/pkg/controller/defaults/testdata/memory/two-pcc-defaults-should-error/existing.yaml b/pkg/controller/resolvedofferings/testdata/memory/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/memory/two-pcc-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/memory/two-pcc-defaults-should-error/expected.yaml similarity index 96% rename from pkg/controller/defaults/testdata/memory/two-ccc-defaults-should-error/expected.yaml rename to pkg/controller/resolvedofferings/testdata/memory/two-pcc-defaults-should-error/expected.yaml index 66d1c6a699..4380716251 100644 --- a/pkg/controller/defaults/testdata/memory/two-ccc-defaults-should-error/expected.yaml +++ b/pkg/controller/resolvedofferings/testdata/memory/two-pcc-defaults-should-error/expected.yaml @@ -36,6 +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/memory/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/memory/two-pcc-defaults-should-error/input.yaml diff --git a/pkg/controller/defaults/testdata/memory/with-acornfile-memory/existing.yaml b/pkg/controller/resolvedofferings/testdata/memory/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/memory/with-acornfile-memory/existing.yaml diff --git a/pkg/controller/defaults/testdata/memory/with-acornfile-memory/expected.golden b/pkg/controller/resolvedofferings/testdata/memory/with-acornfile-memory/expected.golden similarity index 87% rename from pkg/controller/defaults/testdata/memory/with-acornfile-memory/expected.golden rename to pkg/controller/resolvedofferings/testdata/memory/with-acornfile-memory/expected.golden index cb8df27042..049ef97f03 100644 --- a/pkg/controller/defaults/testdata/memory/with-acornfile-memory/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/memory/with-acornfile-memory/expected.golden @@ -42,14 +42,17 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + containers: + "": + memory: 0 + left: + memory: 1048576 + oneimage: + memory: 1048576 region: local staged: appImage: diff --git a/pkg/controller/defaults/testdata/memory/with-acornfile-memory/input.yaml b/pkg/controller/resolvedofferings/testdata/memory/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/memory/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 85% rename from pkg/controller/defaults/testdata/region/default/expected.golden rename to pkg/controller/resolvedofferings/testdata/region/default/expected.golden index 24ff1b43ab..fb101d73b5 100644 --- a/pkg/controller/defaults/testdata/region/default/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/region/default/expected.golden @@ -25,13 +25,15 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: - memory: - "": 0 - container-name: 0 + containers: + "": + memory: 0 + container-name: + memory: 0 region: local staged: appImage: 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 85% 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 24ff1b43ab..fb101d73b5 100644 --- a/pkg/controller/defaults/testdata/region/project-default-status/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/region/project-default-status/expected.golden @@ -25,13 +25,15 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: - memory: - "": 0 - container-name: 0 + containers: + "": + memory: 0 + container-name: + memory: 0 region: local staged: appImage: 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 85% 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 b338c91cd3..9aa42bc85e 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,15 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: - memory: - "": 0 - container-name: 0 + containers: + "": + memory: 0 + container-name: + memory: 0 region: local staged: appImage: 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 89% 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 6c6c2ab6b6..d648d60cc5 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,13 +32,15 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: - memory: - "": 0 - container-name: 0 + containers: + "": + memory: 0 + container-name: + memory: 0 region: local volumes: foo: 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 88% 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 71a731c3a2..146d84796a 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,12 +31,12 @@ 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 + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: {} 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 88% 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 40d6bbf614..bd3f0886c1 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,13 +31,15 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: - memory: - "": 0 - container-name: 0 + containers: + "": + memory: 0 + container-name: + memory: 0 region: local volumes: foo: 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 89% 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 5af86d210a..5913f03e2e 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,13 +35,15 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: - memory: - "": 0 - container-name: 0 + containers: + "": + memory: 0 + container-name: + memory: 0 region: local volumes: foo: 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-defaults/expected.golden b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults/expected.golden similarity index 89% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults/expected.golden rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults/expected.golden index 1963694c37..c39ad7ff9a 100644 --- a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-defaults/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-defaults/expected.golden @@ -32,13 +32,15 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: - memory: - "": 0 - container-name: 0 + containers: + "": + memory: 0 + container-name: + memory: 0 region: local volumes: foo: 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 89% 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 1b537cc1cf..99652c6956 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,13 +31,15 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: - memory: - "": 0 - container-name: 0 + containers: + "": + memory: 0 + container-name: + memory: 0 region: local volumes: foo: 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-size/expected.golden b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-size/expected.golden similarity index 89% rename from pkg/controller/defaults/testdata/volumeclass/volume-class-fill-size/expected.golden rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-size/expected.golden index bc039662d4..ef51350f86 100644 --- a/pkg/controller/defaults/testdata/volumeclass/volume-class-fill-size/expected.golden +++ b/pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-fill-size/expected.golden @@ -34,13 +34,15 @@ status: reason: Success status: "True" success: true - type: defaults + type: resolved-offerings namespace: app-created-namespace observedGeneration: 1 resolvedOfferings: - memory: - "": 0 - container-name: 0 + containers: + "": + memory: 0 + container-name: + memory: 0 region: local volumes: foo: 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-cluster-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-cluster-defaults/expected.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-cluster-defaults/expected.yaml index d8b5915a02..c62bd0c6c7 100644 --- a/pkg/controller/defaults/testdata/volumeclass/volume-class-two-cluster-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-project-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-project-defaults/expected.yaml rename to pkg/controller/resolvedofferings/testdata/volumeclass/volume-class-two-project-defaults/expected.yaml index d8b5915a02..c62bd0c6c7 100644 --- a/pkg/controller/defaults/testdata/volumeclass/volume-class-two-project-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 88% rename from pkg/controller/defaults/volumeclass.go rename to pkg/controller/resolvedofferings/volumeclass.go index ee764b0020..6bf680754d 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,7 +24,7 @@ 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) } } @@ -42,7 +42,7 @@ func addVolumeClassDefaults(ctx context.Context, c kclient.Client, app *v1.AppIn // 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.ResolvedOfferings.VolumeSize != nil && resolvedVolume.Size == "" { @@ -56,7 +56,7 @@ func addVolumeClassDefaults(ctx context.Context, c kclient.Client, app *v1.AppIn resolvedVolume.Class = vol.Class if vol.Class == "" && defaultVolumeClass != nil { resolvedVolume.Class = defaultVolumeClass.Name - vol.Class = resolvedVolume.Class + vol.Class = defaultVolumeClass.Name } resolvedVolume.AccessModes = vol.AccessModes diff --git a/pkg/controller/defaults/volumeclass_test.go b/pkg/controller/resolvedofferings/volumeclass_test.go similarity index 98% rename from pkg/controller/defaults/volumeclass_test.go rename to pkg/controller/resolvedofferings/volumeclass_test.go index b0d030e313..1392ea0348 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" diff --git a/pkg/controller/routes.go b/pkg/controller/routes.go index fbbf9850df..43a5b671ea 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/testdata/computeclass/all-set-overwrite-computeclass/expected.golden b/pkg/controller/scheduling/testdata/computeclass/all-set-overwrite-computeclass/expected.golden index 29e60d1157..94940564a1 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 @@ -47,11 +47,7 @@ status: type: scheduling namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 2097152 - oneimage: 2097152 + resolvedOfferings: {} scheduling: left: requirements: diff --git a/pkg/controller/scheduling/testdata/computeclass/all-set/expected.golden b/pkg/controller/scheduling/testdata/computeclass/all-set/expected.golden index 184c0f06c2..b8da715706 100644 --- a/pkg/controller/scheduling/testdata/computeclass/all-set/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/all-set/expected.golden @@ -46,19 +46,15 @@ status: type: scheduling namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: requirements: limits: - memory: 1Mi + memory: 2Mi requests: cpu: 1m - memory: 1Mi + memory: 2Mi oneimage: affinity: nodeAffinity: @@ -71,10 +67,10 @@ status: - bar requirements: limits: - memory: 1Mi + memory: 2Mi requests: cpu: 1m - memory: 1Mi + memory: 2Mi tolerations: - key: taints.acorn.io/workload operator: Exists diff --git a/pkg/controller/scheduling/testdata/computeclass/container/expected.golden b/pkg/controller/scheduling/testdata/computeclass/container/expected.golden index d069826723..3a3b6d7ff3 100644 --- a/pkg/controller/scheduling/testdata/computeclass/container/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/container/expected.golden @@ -46,19 +46,15 @@ status: type: scheduling namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: requirements: limits: - memory: 1Mi + memory: 2Mi requests: cpu: 1m - memory: 1Mi + memory: 2Mi oneimage: affinity: nodeAffinity: @@ -71,10 +67,10 @@ status: - bar requirements: limits: - memory: 1Mi + memory: 2Mi requests: cpu: 1m - memory: 1Mi + memory: 2Mi tolerations: - key: taints.acorn.io/workload operator: Exists diff --git a/pkg/controller/scheduling/testdata/computeclass/different-computeclass/expected.golden b/pkg/controller/scheduling/testdata/computeclass/different-computeclass/expected.golden index 4cba4dd97c..12046f83b0 100644 --- a/pkg/controller/scheduling/testdata/computeclass/different-computeclass/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/different-computeclass/expected.golden @@ -49,11 +49,7 @@ status: type: scheduling namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - oneimage: 2097152 - twoimage: 1048576 + resolvedOfferings: {} scheduling: oneimage: affinity: @@ -86,10 +82,10 @@ status: - bar requirements: limits: - memory: 1Mi + memory: 2Mi requests: cpu: 1m - memory: 1Mi + memory: 2Mi tolerations: - key: taints.acorn.io/workload operator: Exists 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 90c714ee97..18671697dd 100644 --- a/pkg/controller/scheduling/testdata/computeclass/different-digest-generation/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/different-digest-generation/expected.golden @@ -47,19 +47,15 @@ status: type: scheduling namespace: app-created-namespace observedImageDigest: foo - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: requirements: limits: - memory: 1Mi + memory: 2Mi requests: cpu: 1m - memory: 1Mi + memory: 2Mi oneimage: affinity: nodeAffinity: @@ -72,10 +68,10 @@ status: - bar requirements: limits: - memory: 1Mi + memory: 2Mi requests: cpu: 1m - memory: 1Mi + memory: 2Mi tolerations: - key: taints.acorn.io/workload operator: Exists 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 38423048b5..5a00f22c45 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 @@ -46,11 +46,7 @@ status: type: scheduling namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: {} scheduling: left: requirements: {} diff --git a/pkg/controller/scheduling/testdata/computeclass/job/expected.golden b/pkg/controller/scheduling/testdata/computeclass/job/expected.golden index 3f3a813f2b..6d9dfa8336 100644 --- a/pkg/controller/scheduling/testdata/computeclass/job/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/job/expected.golden @@ -46,19 +46,15 @@ status: type: scheduling namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: requirements: limits: - memory: 1Mi + memory: 2Mi requests: cpu: 1m - memory: 1Mi + memory: 2Mi oneimage: affinity: nodeAffinity: @@ -71,10 +67,10 @@ status: - bar requirements: limits: - memory: 1Mi + memory: 2Mi requests: cpu: 1m - memory: 1Mi + memory: 2Mi tolerations: - key: taints.acorn.io/workload operator: Exists 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 c52df83c94..3097c49693 100644 --- a/pkg/controller/scheduling/testdata/computeclass/overwrite-acornfile-computeclass/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/overwrite-acornfile-computeclass/expected.golden @@ -47,19 +47,15 @@ status: type: scheduling namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: requirements: limits: - memory: 1Mi + memory: 2Mi requests: cpu: 1m - memory: 1Mi + memory: 2Mi oneimage: affinity: nodeAffinity: @@ -72,10 +68,10 @@ status: - bar requirements: limits: - memory: 1Mi + memory: 2Mi requests: cpu: 1m - memory: 1Mi + memory: 2Mi tolerations: - key: taints.acorn.io/workload operator: Exists diff --git a/pkg/controller/scheduling/testdata/computeclass/priority-class/expected.golden b/pkg/controller/scheduling/testdata/computeclass/priority-class/expected.golden index 65fa942f53..b752aa2263 100644 --- a/pkg/controller/scheduling/testdata/computeclass/priority-class/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/priority-class/expected.golden @@ -44,11 +44,7 @@ status: type: scheduling namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 0 - oneimage: 0 + resolvedOfferings: {} scheduling: left: requirements: {} 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 68410eca77..f3e827e8cc 100644 --- a/pkg/controller/scheduling/testdata/computeclass/same-digest-generation/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/same-digest-generation/expected.golden @@ -47,11 +47,7 @@ status: type: scheduling namespace: app-created-namespace observedImageDigest: foo - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: requirements: diff --git a/pkg/controller/scheduling/testdata/computeclass/same-generation/expected.golden b/pkg/controller/scheduling/testdata/computeclass/same-generation/expected.golden index e867a307cd..ec8bae81b8 100644 --- a/pkg/controller/scheduling/testdata/computeclass/same-generation/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/same-generation/expected.golden @@ -45,11 +45,7 @@ status: success: true type: scheduling namespace: app-created-namespace - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: requirements: diff --git a/pkg/controller/scheduling/testdata/computeclass/two-containers/expected.golden b/pkg/controller/scheduling/testdata/computeclass/two-containers/expected.golden index 56afde3fe8..c9d88d56b2 100644 --- a/pkg/controller/scheduling/testdata/computeclass/two-containers/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/two-containers/expected.golden @@ -48,11 +48,7 @@ status: type: scheduling namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - oneimage: 1048576 - twoimage: 0 + resolvedOfferings: {} scheduling: oneimage: affinity: @@ -66,10 +62,10 @@ status: - bar requirements: limits: - memory: 1Mi + memory: 2Mi requests: cpu: 1m - memory: 1Mi + memory: 2Mi tolerations: - key: taints.acorn.io/workload operator: Exists 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 9467c98b34..8c1f7bd5ef 100644 --- a/pkg/controller/scheduling/testdata/computeclass/with-acornfile-computeclass/expected.golden +++ b/pkg/controller/scheduling/testdata/computeclass/with-acornfile-computeclass/expected.golden @@ -45,19 +45,15 @@ status: type: scheduling namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: requirements: limits: - memory: 1Mi + memory: 2Mi requests: cpu: 1m - memory: 1Mi + memory: 2Mi oneimage: affinity: nodeAffinity: @@ -70,10 +66,10 @@ status: - bar requirements: limits: - memory: 1Mi + memory: 2Mi requests: cpu: 1m - memory: 1Mi + memory: 2Mi tolerations: - key: taints.acorn.io/workload operator: Exists 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 c62ee8378b..ad9c3a5189 100644 --- a/pkg/controller/scheduling/testdata/memory/all-set-overwrite/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/all-set-overwrite/expected.golden @@ -47,11 +47,7 @@ status: type: scheduling namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 1048576 - left: 2097152 - oneimage: 2097152 + resolvedOfferings: {} scheduling: left: requirements: diff --git a/pkg/controller/scheduling/testdata/memory/all-set/expected.golden b/pkg/controller/scheduling/testdata/memory/all-set/expected.golden index 58f7380bb4..b5d708b25a 100644 --- a/pkg/controller/scheduling/testdata/memory/all-set/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/all-set/expected.golden @@ -46,11 +46,7 @@ status: type: scheduling namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 1048576 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: requirements: diff --git a/pkg/controller/scheduling/testdata/memory/container/expected.golden b/pkg/controller/scheduling/testdata/memory/container/expected.golden index c1c351f75f..b337e3824a 100644 --- a/pkg/controller/scheduling/testdata/memory/container/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/container/expected.golden @@ -46,18 +46,10 @@ status: type: scheduling namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: - requirements: - limits: - memory: 1Mi - requests: - memory: 1Mi + requirements: {} oneimage: requirements: limits: diff --git a/pkg/controller/scheduling/testdata/memory/job/expected.golden b/pkg/controller/scheduling/testdata/memory/job/expected.golden index da159d1c10..4db0533d25 100644 --- a/pkg/controller/scheduling/testdata/memory/job/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/job/expected.golden @@ -46,18 +46,10 @@ status: type: scheduling namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: - requirements: - limits: - memory: 1Mi - requests: - memory: 1Mi + requirements: {} oneimage: requirements: limits: 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 803b9ff29f..ca1f48f92e 100644 --- a/pkg/controller/scheduling/testdata/memory/overwrite-acornfile-memory/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/overwrite-acornfile-memory/expected.golden @@ -47,18 +47,10 @@ status: type: scheduling namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: - requirements: - limits: - memory: 1Mi - requests: - memory: 1Mi + requirements: {} oneimage: requirements: limits: diff --git a/pkg/controller/scheduling/testdata/memory/same-generation/expected.golden b/pkg/controller/scheduling/testdata/memory/same-generation/expected.golden index 2a9ae843ee..e5000afe2f 100644 --- a/pkg/controller/scheduling/testdata/memory/same-generation/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/same-generation/expected.golden @@ -45,11 +45,7 @@ status: success: true type: scheduling namespace: app-created-namespace - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + 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 8b53f82c80..3315417186 100644 --- a/pkg/controller/scheduling/testdata/memory/two-containers/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/two-containers/expected.golden @@ -48,11 +48,7 @@ status: type: scheduling namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: oneimage: requirements: 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 427d57a145..fdaf41c83e 100644 --- a/pkg/controller/scheduling/testdata/memory/with-acornfile-memory/expected.golden +++ b/pkg/controller/scheduling/testdata/memory/with-acornfile-memory/expected.golden @@ -45,18 +45,10 @@ status: type: scheduling namespace: app-created-namespace observedGeneration: 1 - resolvedOfferings: - memory: - "": 0 - left: 1048576 - oneimage: 1048576 + resolvedOfferings: {} scheduling: left: - requirements: - limits: - memory: 1Mi - requests: - memory: 1Mi + requirements: {} oneimage: requirements: limits: diff --git a/pkg/labels/labels.go b/pkg/labels/labels.go index cbcb114fdf..1643f237ae 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"