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

Add support for customizing terminationGracePeriodSeconds of the VTTablet pods #500

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions deploy/crds/planetscale.com_vitessclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,9 @@ spec:
x-kubernetes-int-or-string: true
type: object
type: object
terminationGracePeriodSeconds:
format: int64
type: integer
required:
- resources
type: object
Expand Down Expand Up @@ -1960,6 +1963,9 @@ spec:
x-kubernetes-int-or-string: true
type: object
type: object
terminationGracePeriodSeconds:
format: int64
type: integer
required:
- resources
type: object
Expand Down
6 changes: 6 additions & 0 deletions deploy/crds/planetscale.com_vitesskeyspaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,9 @@ spec:
x-kubernetes-int-or-string: true
type: object
type: object
terminationGracePeriodSeconds:
format: int64
type: integer
required:
- resources
type: object
Expand Down Expand Up @@ -1008,6 +1011,9 @@ spec:
x-kubernetes-int-or-string: true
type: object
type: object
terminationGracePeriodSeconds:
format: int64
type: integer
required:
- resources
type: object
Expand Down
3 changes: 3 additions & 0 deletions deploy/crds/planetscale.com_vitessshards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,9 @@ spec:
x-kubernetes-int-or-string: true
type: object
type: object
terminationGracePeriodSeconds:
format: int64
type: integer
required:
- resources
type: object
Expand Down
12 changes: 12 additions & 0 deletions docs/api/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7892,6 +7892,18 @@ <h3 id="planetscale.com/v2.VttabletSpec">VttabletSpec
to vttablet container</p>
</td>
</tr>
<tr>
<td>
<code>terminationGracePeriodSeconds</code></br>
<em>
int64
</em>
</td>
<td>
<p>TerminationGracePeriodSeconds can optionally be used to customize
terminationGracePeriodSeconds of the vttablet pod.</p>
</td>
</tr>
</tbody>
</table>
<h3 id="planetscale.com/v2.WorkflowState">WorkflowState
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/planetscale/v2/vitessshard_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ type VttabletSpec struct {
// +kubebuilder:validation:Schemaless
// +kubebuilder:pruning:PreserveUnknownFields
Lifecycle corev1.Lifecycle `json:"lifecycle,omitempty"`

// TerminationGracePeriodSeconds can optionally be used to customize
// terminationGracePeriodSeconds of the vttablet pod.
TerminationGracePeriodSeconds *int64 `json:"terminationGracePeriodSeconds,omitempty"`
}

// MysqldSpec configures the local MySQL server within a tablet.
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/planetscale/v2/zz_generated.deepcopy.go

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

6 changes: 5 additions & 1 deletion pkg/operator/vttablet/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,11 @@ func UpdatePod(obj *corev1.Pod, spec *Spec) {
obj.Spec.SecurityContext.FSGroup = pointer.Int64Ptr(planetscalev2.DefaultVitessFSGroup)
}

obj.Spec.TerminationGracePeriodSeconds = pointer.Int64Ptr(terminationGracePeriodSeconds)
if spec.Vttablet.TerminationGracePeriodSeconds != nil {
obj.Spec.TerminationGracePeriodSeconds = spec.Vttablet.TerminationGracePeriodSeconds
} else {
obj.Spec.TerminationGracePeriodSeconds = pointer.Int64Ptr(terminationGracePeriodSeconds)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, but I feel like we should rename this variable to defaultTerminationGracePeriodSeconds now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattlord Thank you for your review! I renamed it befb94e.

}

// In both the case of the user injecting their own affinity and the default, we
// simply override the pod's existing affinity configuration.
Expand Down
8 changes: 8 additions & 0 deletions test/integration/vitesscluster/vitesscluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ spec:
- cell: cell1
type: replica
replicas: 3
vttablet:
terminationGracePeriodSeconds: 60
mysqld: {}
dataVolumeClaimTemplate:
accessModes: [ReadWriteOnce]
Expand Down Expand Up @@ -219,9 +221,15 @@ func verifyBasicVitessShard(f *framework.Fixture, ns, cluster, keyspace, shard s
// Each vttablet Pod should have a PVC.
for i := range cell1Pods.Items {
f.MustGet(ns, cell1Pods.Items[i].Name, &corev1.PersistentVolumeClaim{})
if *cell1Pods.Items[i].Spec.TerminationGracePeriodSeconds != 60 {
f.Fatalf("TerminationGracePeriodSeconds should be 60, but got %d", *cell1Pods.Items[i].Spec.TerminationGracePeriodSeconds)
}
}
for i := range cell2Pods.Items {
f.MustGet(ns, cell2Pods.Items[i].Name, &corev1.PersistentVolumeClaim{})
if *cell2Pods.Items[i].Spec.TerminationGracePeriodSeconds != 1800 {
f.Fatalf("TerminationGracePeriodSeconds should be 1800, but got %d", *cell2Pods.Items[i].Spec.TerminationGracePeriodSeconds)
}
}

// VitessShard creates vtbackup-init Pod/PVC.
Expand Down
Loading