Skip to content

Commit

Permalink
Allow configuration MaxGracefulTerminationSec on ClusterAutoscaler (#…
Browse files Browse the repository at this point in the history
…4697)

Co-authored-by: Ismail Alidzhikov <[email protected]>

Co-authored-by: Ismail Alidzhikov <[email protected]>
  • Loading branch information
prashanth26 and ialidzhikov authored Sep 28, 2021
1 parent 7a20ba3 commit 095a07f
Show file tree
Hide file tree
Showing 23 changed files with 1,345 additions and 1,192 deletions.
1 change: 1 addition & 0 deletions example/90-shoot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ spec:
# SomeKubernetesFeature: true
# clusterAutoscaler:
# expander: "least-waste" # see: https://github.com/gardener/autoscaler/blob/machine-controller-manager-provider/cluster-autoscaler/FAQ.md#what-are-expanders
# maxGracefulTerminationSeconds: 600
# maxNodeProvisionTime: 20m
# scaleDownUtilizationThreshold: 0.5
# scaleDownUnneededTime: 30m
Expand Down
12 changes: 12 additions & 0 deletions hack/api-reference/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -2676,6 +2676,18 @@ Kubernetes meta/v1.Duration
<p>MaxNodeProvisionTime defines how long CA waits for node to be provisioned (default: 20 mins).</p>
</td>
</tr>
<tr>
<td>
<code>maxGracefulTerminationSeconds</code></br>
<em>
int32
</em>
</td>
<td>
<em>(Optional)</em>
<p>MaxGracefulTerminationSeconds is the number of seconds CA waits for pod termination when trying to scale down a node (default: 600).</p>
</td>
</tr>
</tbody>
</table>
<h3 id="core.gardener.cloud/v1beta1.ClusterInfo">ClusterInfo
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/core/types_shoot.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ type ClusterAutoscaler struct {
Expander *ExpanderMode
// MaxNodeProvisionTime defines how long CA waits for node to be provisioned (default: 20 mins).
MaxNodeProvisionTime *metav1.Duration
// MaxGracefulTerminationSeconds is the number of seconds CA waits for pod termination when trying to scale down a node (default: 600).
MaxGracefulTerminationSeconds *int32
}

// ExpanderMode is type used for Expander values
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/core/v1alpha1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ func SetDefaults_ClusterAutoscaler(obj *ClusterAutoscaler) {
if obj.MaxNodeProvisionTime == nil {
obj.MaxNodeProvisionTime = &metav1.Duration{Duration: 20 * time.Minute}
}
if obj.MaxGracefulTerminationSeconds == nil {
obj.MaxGracefulTerminationSeconds = pointer.Int32(600)
}
}

// SetDefaults_NginxIngress sets default values for NginxIngress objects.
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/core/v1alpha1/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ var _ = Describe("Defaults", func() {
Expect(obj.ScanInterval).To(PointTo(Equal(metav1.Duration{Duration: 10 * time.Second})))
Expect(obj.MaxNodeProvisionTime).To(PointTo(Equal(metav1.Duration{Duration: 20 * time.Minute})))
Expect(obj.Expander).To(PointTo(Equal(expanderLeastWaste)))
Expect(obj.MaxGracefulTerminationSeconds).To(PointTo(Equal(int32(600))))
})

It("should not default explicitly set fields", func() {
Expand All @@ -565,6 +566,7 @@ var _ = Describe("Defaults", func() {
ScanInterval: &metav1.Duration{Duration: 5 * time.Hour},
Expander: &expanderRandom,
MaxNodeProvisionTime: &metav1.Duration{Duration: 6 * time.Hour},
MaxGracefulTerminationSeconds: pointer.Int32(60 * 60 * 24),
}

SetDefaults_ClusterAutoscaler(obj)
Expand All @@ -576,6 +578,7 @@ var _ = Describe("Defaults", func() {
Expect(obj.ScanInterval).To(PointTo(Equal(metav1.Duration{Duration: 5 * time.Hour})))
Expect(obj.MaxNodeProvisionTime).To(PointTo(Equal(metav1.Duration{Duration: 6 * time.Hour})))
Expect(obj.Expander).To(PointTo(Equal(ClusterAutoscalerExpanderRandom)))
Expect(obj.MaxGracefulTerminationSeconds).To(PointTo(Equal(int32(60 * 60 * 24))))
})
})

Expand Down
1,231 changes: 631 additions & 600 deletions pkg/apis/core/v1alpha1/generated.pb.go

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions pkg/apis/core/v1alpha1/generated.proto

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

3 changes: 3 additions & 0 deletions pkg/apis/core/v1alpha1/types_shoot.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ type ClusterAutoscaler struct {
// MaxNodeProvisionTime defines how long CA waits for node to be provisioned (default: 20 mins).
// +optional
MaxNodeProvisionTime *metav1.Duration `json:"maxNodeProvisionTime,omitempty" protobuf:"bytes,8,opt,name=maxNodeProvisionTime"`
// MaxGracefulTerminationSeconds is the number of seconds CA waits for pod termination when trying to scale down a node (default: 600).
// +optional
MaxGracefulTerminationSeconds *int32 `json:"maxGracefulTerminationSeconds,omitempty" protobuf:"varint,9,opt,name=maxGracefulTerminationSeconds"`
}

// ExpanderMode is type used for Expander values
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/core/v1alpha1/zz_generated.conversion.go

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

5 changes: 5 additions & 0 deletions pkg/apis/core/v1alpha1/zz_generated.deepcopy.go

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

3 changes: 3 additions & 0 deletions pkg/apis/core/v1beta1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ func SetDefaults_ClusterAutoscaler(obj *ClusterAutoscaler) {
if obj.MaxNodeProvisionTime == nil {
obj.MaxNodeProvisionTime = &metav1.Duration{Duration: 20 * time.Minute}
}
if obj.MaxGracefulTerminationSeconds == nil {
obj.MaxGracefulTerminationSeconds = pointer.Int32(600)
}
}

// SetDefaults_NginxIngress sets default values for NginxIngress objects.
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/core/v1beta1/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ var _ = Describe("Defaults", func() {
Expect(obj.ScanInterval).To(PointTo(Equal(metav1.Duration{Duration: 10 * time.Second})))
Expect(obj.MaxNodeProvisionTime).To(PointTo(Equal(metav1.Duration{Duration: 20 * time.Minute})))
Expect(obj.Expander).To(PointTo(Equal(expanderLeastWaste)))
Expect(obj.MaxGracefulTerminationSeconds).To(PointTo(Equal(int32(600))))
})

It("should correctly override values the ClusterAutoscaler on setting them", func() {
Expand All @@ -565,6 +566,7 @@ var _ = Describe("Defaults", func() {
ScanInterval: &metav1.Duration{Duration: 5 * time.Hour},
Expander: &expanderRandom,
MaxNodeProvisionTime: &metav1.Duration{Duration: 6 * time.Hour},
MaxGracefulTerminationSeconds: pointer.Int32(60 * 60 * 24),
}

SetDefaults_ClusterAutoscaler(obj)
Expand All @@ -576,6 +578,7 @@ var _ = Describe("Defaults", func() {
Expect(obj.ScanInterval).To(PointTo(Equal(metav1.Duration{Duration: 5 * time.Hour})))
Expect(obj.MaxNodeProvisionTime).To(PointTo(Equal(metav1.Duration{Duration: 6 * time.Hour})))
Expect(obj.Expander).To(PointTo(Equal(ClusterAutoscalerExpanderRandom)))
Expect(obj.MaxGracefulTerminationSeconds).To(PointTo(Equal(int32(60 * 60 * 24))))
})
})

Expand Down
Loading

0 comments on commit 095a07f

Please sign in to comment.