Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

Commit 8b9acb4

Browse files
authored
Revert "Resolved offerings (#2369)" (#2376)
This reverts commit dbd950d. Signed-off-by: Grant Linville <[email protected]>
1 parent dbd950d commit 8b9acb4

File tree

275 files changed

+1352
-2166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

275 files changed

+1352
-2166
lines changed

docs/docs/40-admin/03-computeclasses.md

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ affinity: # The same affinity fields for Pods
4040
operator: In
4141
values:
4242
- bar
43-
supportedRegions: ["local"] # should always be set to ["local"]
4443
```
4544
4645
If `memory.min`, `memory.max`, `memory.values`, `affinity`, and `tolerations` are not given, then there are no scheduling rules for workloads using the compute class.

pkg/apis/api.acorn.io/v1/types.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ func (in *App) GetStopped() bool {
2323
}
2424

2525
func (in *App) GetRegion() string {
26-
return in.Status.ResolvedOfferings.Region
26+
if in.Spec.Region != "" {
27+
return in.Spec.Region
28+
}
29+
return in.Status.Defaults.Region
2730
}
2831

2932
type Acornfile v1.AppSpec

pkg/apis/internal.acorn.io/v1/appinstance.go

+19-20
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type AppInstanceCondition string
1414

1515
var (
1616
AppInstanceConditionDefined = "defined"
17-
AppInstanceConditionResolvedOfferings = "resolved-offerings"
17+
AppInstanceConditionDefaults = "defaults"
1818
AppInstanceConditionScheduling = "scheduling"
1919
AppInstanceConditionNamespace = "namespace"
2020
AppInstanceConditionParsed = "parsed"
@@ -52,18 +52,23 @@ type AppInstance struct {
5252
}
5353

5454
func (in *AppInstance) HasRegion(region string) bool {
55-
return in.Status.ResolvedOfferings.Region == region
55+
return in.Status.Defaults.Region == region || in.Spec.Region == region
5656
}
5757

5858
func (in *AppInstance) GetRegion() string {
59-
return in.Status.ResolvedOfferings.Region
59+
if in.Spec.Region != "" {
60+
return in.Spec.Region
61+
}
62+
return in.Status.Defaults.Region
6063
}
6164

6265
func (in *AppInstance) SetDefaultRegion(region string) {
63-
if in.Spec.Region != "" {
64-
in.Status.ResolvedOfferings.Region = in.Spec.Region
65-
} else if in.Status.ResolvedOfferings.Region == "" {
66-
in.Status.ResolvedOfferings.Region = region
66+
if in.Spec.Region == "" {
67+
if in.Status.Defaults.Region == "" {
68+
in.Status.Defaults.Region = region
69+
}
70+
} else {
71+
in.Status.Defaults.Region = ""
6772
}
6873
}
6974

@@ -204,7 +209,7 @@ type AppInstanceStatus struct {
204209
AppStatus AppStatus `json:"appStatus,omitempty"`
205210
Scheduling map[string]Scheduling `json:"scheduling,omitempty"`
206211
Conditions []Condition `json:"conditions,omitempty"`
207-
ResolvedOfferings ResolvedOfferings `json:"resolvedOfferings,omitempty"`
212+
Defaults Defaults `json:"defaults,omitempty"`
208213
Summary CommonSummary `json:"summary,omitempty"`
209214
Permissions []Permissions `json:"permissions,omitempty"` // Permissions given to this appInstance (only containers within, not nested Acorns/Services)
210215
DeniedConsumerPermissions []Permissions `json:"deniedConsumerPermissions,omitempty"` // Permissions given to this appInstance by a consumed service, which it is not authorized to have
@@ -224,25 +229,19 @@ type AppStatusStaged struct {
224229
ImageAllowed *bool `json:"imageAllowed,omitempty"`
225230
}
226231

227-
type ResolvedOfferings struct {
228-
Volumes map[string]VolumeResolvedOffering `json:"volumes,omitempty"`
229-
VolumeSize *resource.Quantity `json:"volumeSize,omitempty"`
230-
Containers map[string]ContainerResolvedOffering `json:"containers,omitempty"`
231-
Region string `json:"region,omitempty"`
232+
type Defaults struct {
233+
VolumeSize *resource.Quantity `json:"volumeSize,omitempty"`
234+
Volumes map[string]VolumeDefault `json:"volumes,omitempty"`
235+
Memory map[string]*int64 `json:"memory,omitempty"`
236+
Region string `json:"region,omitempty"`
232237
}
233238

234-
type VolumeResolvedOffering struct {
239+
type VolumeDefault struct {
235240
Class string `json:"class,omitempty"`
236241
Size Quantity `json:"size,omitempty"`
237242
AccessModes AccessModes `json:"accessModes,omitempty"`
238243
}
239244

240-
type ContainerResolvedOffering struct {
241-
Class string `json:"class,omitempty"`
242-
Memory *int64 `json:"memory,omitempty"`
243-
CPUScaler *float64 `json:"cpuScaler,omitempty"`
244-
}
245-
246245
type Scheduling struct {
247246
Requirements corev1.ResourceRequirements `json:"requirements,omitempty"`
248247
Affinity *corev1.Affinity `json:"affinity,omitempty"`

pkg/apis/internal.acorn.io/v1/zz_generated.deepcopy.go

+63-80
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/cli/testdata/TestAll/acorn_all_-o_json.golden

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ACORNS:
3131
},
3232
"appSpec": {},
3333
"appStatus": {},
34-
"resolvedOfferings": {},
34+
"defaults": {},
3535
"summary": {}
3636
}
3737
}

pkg/cli/testdata/TestAll/acorn_all_-o_yaml.golden

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ items:
1717
appSpec: {}
1818
appStatus: {}
1919
columns: {}
20-
resolvedOfferings: {}
20+
defaults: {}
2121
staged:
2222
appImage:
2323
buildContext: {}

pkg/controller/appdefinition/deploy.go

-22
Original file line numberDiff line numberDiff line change
@@ -597,34 +597,12 @@ func containerAnnotation(container v1.Container) string {
597597
return string(json)
598598
}
599599

600-
func resolvedOfferingsAnnotation(appInstance *v1.AppInstance, container v1.Container) (string, error) {
601-
if resolved, exists := appInstance.Status.ResolvedOfferings.Containers[container.Name]; exists {
602-
data, err := convert.EncodeToMap(resolved)
603-
if err != nil {
604-
return "", err
605-
}
606-
607-
j, err := json.Marshal(data)
608-
if err != nil {
609-
return "", err
610-
}
611-
612-
return string(j), nil
613-
}
614-
return "", nil
615-
}
616-
617600
func podAnnotations(appInstance *v1.AppInstance, container v1.Container) map[string]string {
618601
annotations := map[string]string{
619602
labels.AcornContainerSpec: containerAnnotation(container),
620603
}
621604
addPrometheusAnnotations(annotations, container)
622605

623-
offerings, err := resolvedOfferingsAnnotation(appInstance, container)
624-
if err == nil && offerings != "" {
625-
annotations[labels.AcornContainerResolvedOfferings] = offerings
626-
}
627-
628606
images := map[string]string{}
629607
addImageAnnotations(images, appInstance, container)
630608

pkg/controller/appdefinition/testdata/TestComputeMem.golden

+3-3
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ status:
116116
appSpec: {}
117117
appStatus: {}
118118
columns: {}
119-
resolvedOfferings: {}
119+
defaults: {}
120120
staged:
121121
appImage:
122122
buildContext: {}
@@ -157,7 +157,7 @@ status:
157157
appSpec: {}
158158
appStatus: {}
159159
columns: {}
160-
resolvedOfferings: {}
160+
defaults: {}
161161
staged:
162162
appImage:
163163
buildContext: {}
@@ -200,8 +200,8 @@ status:
200200
status: "True"
201201
success: true
202202
type: defined
203+
defaults: {}
203204
namespace: app-created-namespace
204-
resolvedOfferings: {}
205205
staged:
206206
appImage:
207207
buildContext: {}

pkg/controller/appdefinition/testdata/acorn/basic/expected.golden

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ status:
132132
appSpec: {}
133133
appStatus: {}
134134
columns: {}
135-
resolvedOfferings: {}
135+
defaults: {}
136136
staged:
137137
appImage:
138138
buildContext: {}
@@ -212,8 +212,8 @@ status:
212212
status: "True"
213213
success: true
214214
type: defined
215+
defaults: {}
215216
namespace: app-created-namespace
216-
resolvedOfferings: {}
217217
staged:
218218
appImage:
219219
buildContext: {}

0 commit comments

Comments
 (0)