Skip to content

Commit

Permalink
Add support for customizing terminationGracePeriodSeconds of the VTTa…
Browse files Browse the repository at this point in the history
…blet pods

Signed-off-by: Yohei Yoshimuta <[email protected]>
  • Loading branch information
yoheimuta committed Nov 6, 2023
1 parent f583949 commit 8bb2c00
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 1 deletion.
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)
}

// 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

0 comments on commit 8bb2c00

Please sign in to comment.