Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defer containers #19

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
23 changes: 23 additions & 0 deletions pkg/api/resource/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,29 @@ func PodRequestsAndLimits(pod *api.Pod) (reqs map[api.ResourceName]resource.Quan
}
}
}
// defer containers define the minimum of any resource
for _, container := range pod.Spec.DeferContainers {
for name, quantity := range container.Resources.Requests {
value, ok := reqs[name]
if !ok {
reqs[name] = *quantity.Copy()
continue
}
if quantity.Cmp(value) > 0 {
reqs[name] = *quantity.Copy()
}
}
for name, quantity := range container.Resources.Limits {
value, ok := limits[name]
if !ok {
limits[name] = *quantity.Copy()
continue
}
if quantity.Cmp(value) > 0 {
limits[name] = *quantity.Copy()
}
}
}
return
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/api/testing/serialization_proto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ func TestProtobufRoundTrip(t *testing.T) {
// InitContainers are turned into annotations by conversion.
obj.Spec.InitContainers = nil
obj.Status.InitContainerStatuses = nil
// deferContainers are turned into annotations by conversion
obj.Spec.DeferContainers = nil
obj.Status.DeferContainerStatuses = nil
data, err := obj.Marshal()
if err != nil {
t.Fatal(err)
Expand Down
168 changes: 168 additions & 0 deletions pkg/apis/apps/v1/zz_generated.defaults.go

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

84 changes: 84 additions & 0 deletions pkg/apis/apps/v1beta1/zz_generated.defaults.go

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

Loading