Skip to content

Commit

Permalink
The comment and the usage were right, but the config name was wrong. (k…
Browse files Browse the repository at this point in the history
…native#3551)

I'd originally called this `RevisionCPU` and went back and appended the wrong suffix places.  This actually sets the CPU *requests* not *limits*.
  • Loading branch information
mattmoor authored and knative-prow-robot committed Mar 27, 2019
1 parent 306de3d commit 3e758dd
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions config/config-defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ data:
# none is specified.
revision-timeout-seconds: "300" # 5 minutes
# revision-cpu-limit contains the cpu allocation to assign
# revision-cpu-request contains the cpu allocation to assign
# to revisions by default.
revision-cpu-limit: "400m" # 0.4 of a CPU (aka 400 milli-CPU)
revision-cpu-request: "400m" # 0.4 of a CPU (aka 400 milli-CPU)
12 changes: 6 additions & 6 deletions pkg/apis/config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ func NewDefaultsConfigFromMap(data map[string]string) (*Defaults, error) {
// specified exactly when optional
defaultValue resource.Quantity
}{{
key: "revision-cpu-limit",
field: &nc.RevisionCPULimit,
defaultValue: DefaultRevisionCPULimit,
key: "revision-cpu-request",
field: &nc.RevisionCPURequest,
defaultValue: DefaultRevisionCPURequest,
}} {
if raw, ok := data[rsrc.key]; !ok {
*rsrc.field = rsrc.defaultValue
Expand All @@ -87,13 +87,13 @@ const (

// Pseudo-constants
var (
// DefaultRevisionCPULimit will be set if resources.limits.cpu is not specified.
DefaultRevisionCPULimit = resource.MustParse("400m")
// DefaultRevisionCPURequest will be set if resources.requests.cpu is not specified.
DefaultRevisionCPURequest = resource.MustParse("400m")
)

// Defaults includes the default values to be populated by the webhook.
type Defaults struct {
RevisionTimeoutSeconds int64

RevisionCPULimit resource.Quantity
RevisionCPURequest resource.Quantity
}
8 changes: 4 additions & 4 deletions pkg/apis/config/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestDefaultsConfiguration(t *testing.T) {
wantErr: false,
wantDefaults: &Defaults{
RevisionTimeoutSeconds: DefaultRevisionTimeoutSeconds,
RevisionCPULimit: DefaultRevisionCPULimit,
RevisionCPURequest: DefaultRevisionCPURequest,
},
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -65,7 +65,7 @@ func TestDefaultsConfiguration(t *testing.T) {
wantErr: false,
wantDefaults: &Defaults{
RevisionTimeoutSeconds: 123,
RevisionCPULimit: resource.MustParse("123m"),
RevisionCPURequest: resource.MustParse("123m"),
},
config: &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -74,7 +74,7 @@ func TestDefaultsConfiguration(t *testing.T) {
},
Data: map[string]string{
"revision-timeout-seconds": "123",
"revision-cpu-limit": "123m",
"revision-cpu-request": "123m",
},
},
}, {
Expand All @@ -100,7 +100,7 @@ func TestDefaultsConfiguration(t *testing.T) {
Name: DefaultsConfigName,
},
Data: map[string]string{
"revision-cpu-limit": "bad",
"revision-cpu-request": "bad",
},
},
}}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/config/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/apis/serving/v1alpha1/revision_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (rs *RevisionSpec) SetDefaults(ctx context.Context) {
rs.Container.Resources.Requests = corev1.ResourceList{}
}
if _, ok := rs.Container.Resources.Requests[corev1.ResourceCPU]; !ok {
rs.Container.Resources.Requests[corev1.ResourceCPU] = cfg.Defaults.RevisionCPULimit
rs.Container.Resources.Requests[corev1.ResourceCPU] = cfg.Defaults.RevisionCPURequest
}

vms := rs.Container.VolumeMounts
Expand Down

0 comments on commit 3e758dd

Please sign in to comment.