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

Revert "Resolved offerings (#2369)" #2376

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/docs/40-admin/03-computeclasses.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ affinity: # The same affinity fields for Pods
operator: In
values:
- bar
supportedRegions: ["local"] # should always be set to ["local"]
```

If `memory.min`, `memory.max`, `memory.values`, `affinity`, and `tolerations` are not given, then there are no scheduling rules for workloads using the compute class.
Expand Down
5 changes: 4 additions & 1 deletion pkg/apis/api.acorn.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ func (in *App) GetStopped() bool {
}

func (in *App) GetRegion() string {
return in.Status.ResolvedOfferings.Region
if in.Spec.Region != "" {
return in.Spec.Region
}
return in.Status.Defaults.Region
}

type Acornfile v1.AppSpec
Expand Down
39 changes: 19 additions & 20 deletions pkg/apis/internal.acorn.io/v1/appinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type AppInstanceCondition string

var (
AppInstanceConditionDefined = "defined"
AppInstanceConditionResolvedOfferings = "resolved-offerings"
AppInstanceConditionDefaults = "defaults"
AppInstanceConditionScheduling = "scheduling"
AppInstanceConditionNamespace = "namespace"
AppInstanceConditionParsed = "parsed"
Expand Down Expand Up @@ -52,18 +52,23 @@ type AppInstance struct {
}

func (in *AppInstance) HasRegion(region string) bool {
return in.Status.ResolvedOfferings.Region == region
return in.Status.Defaults.Region == region || in.Spec.Region == region
}

func (in *AppInstance) GetRegion() string {
return in.Status.ResolvedOfferings.Region
if in.Spec.Region != "" {
return in.Spec.Region
}
return in.Status.Defaults.Region
}

func (in *AppInstance) SetDefaultRegion(region string) {
if in.Spec.Region != "" {
in.Status.ResolvedOfferings.Region = in.Spec.Region
} else if in.Status.ResolvedOfferings.Region == "" {
in.Status.ResolvedOfferings.Region = region
if in.Spec.Region == "" {
if in.Status.Defaults.Region == "" {
in.Status.Defaults.Region = region
}
} else {
in.Status.Defaults.Region = ""
}
}

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

type ResolvedOfferings struct {
Volumes map[string]VolumeResolvedOffering `json:"volumes,omitempty"`
VolumeSize *resource.Quantity `json:"volumeSize,omitempty"`
Containers map[string]ContainerResolvedOffering `json:"containers,omitempty"`
Region string `json:"region,omitempty"`
type Defaults struct {
VolumeSize *resource.Quantity `json:"volumeSize,omitempty"`
Volumes map[string]VolumeDefault `json:"volumes,omitempty"`
Memory map[string]*int64 `json:"memory,omitempty"`
Region string `json:"region,omitempty"`
}

type VolumeResolvedOffering struct {
type VolumeDefault struct {
Class string `json:"class,omitempty"`
Size Quantity `json:"size,omitempty"`
AccessModes AccessModes `json:"accessModes,omitempty"`
}

type ContainerResolvedOffering struct {
Class string `json:"class,omitempty"`
Memory *int64 `json:"memory,omitempty"`
CPUScaler *float64 `json:"cpuScaler,omitempty"`
}

type Scheduling struct {
Requirements corev1.ResourceRequirements `json:"requirements,omitempty"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
Expand Down
143 changes: 63 additions & 80 deletions pkg/apis/internal.acorn.io/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/cli/testdata/TestAll/acorn_all_-o_json.golden
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ACORNS:
},
"appSpec": {},
"appStatus": {},
"resolvedOfferings": {},
"defaults": {},
"summary": {}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/testdata/TestAll/acorn_all_-o_yaml.golden
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ items:
appSpec: {}
appStatus: {}
columns: {}
resolvedOfferings: {}
defaults: {}
staged:
appImage:
buildContext: {}
Expand Down
22 changes: 0 additions & 22 deletions pkg/controller/appdefinition/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,34 +597,12 @@ func containerAnnotation(container v1.Container) string {
return string(json)
}

func resolvedOfferingsAnnotation(appInstance *v1.AppInstance, container v1.Container) (string, error) {
if resolved, exists := appInstance.Status.ResolvedOfferings.Containers[container.Name]; exists {
data, err := convert.EncodeToMap(resolved)
if err != nil {
return "", err
}

j, err := json.Marshal(data)
if err != nil {
return "", err
}

return string(j), nil
}
return "", nil
}

func podAnnotations(appInstance *v1.AppInstance, container v1.Container) map[string]string {
annotations := map[string]string{
labels.AcornContainerSpec: containerAnnotation(container),
}
addPrometheusAnnotations(annotations, container)

offerings, err := resolvedOfferingsAnnotation(appInstance, container)
if err == nil && offerings != "" {
annotations[labels.AcornContainerResolvedOfferings] = offerings
}

images := map[string]string{}
addImageAnnotations(images, appInstance, container)

Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/appdefinition/testdata/TestComputeMem.golden
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ status:
appSpec: {}
appStatus: {}
columns: {}
resolvedOfferings: {}
defaults: {}
staged:
appImage:
buildContext: {}
Expand Down Expand Up @@ -157,7 +157,7 @@ status:
appSpec: {}
appStatus: {}
columns: {}
resolvedOfferings: {}
defaults: {}
staged:
appImage:
buildContext: {}
Expand Down Expand Up @@ -200,8 +200,8 @@ status:
status: "True"
success: true
type: defined
defaults: {}
namespace: app-created-namespace
resolvedOfferings: {}
staged:
appImage:
buildContext: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ status:
appSpec: {}
appStatus: {}
columns: {}
resolvedOfferings: {}
defaults: {}
staged:
appImage:
buildContext: {}
Expand Down Expand Up @@ -212,8 +212,8 @@ status:
status: "True"
success: true
type: defined
defaults: {}
namespace: app-created-namespace
resolvedOfferings: {}
staged:
appImage:
buildContext: {}
Expand Down
Loading
Loading