From 60ad4b5e756a053c87706ebbda7754d0f554f180 Mon Sep 17 00:00:00 2001 From: "zhiyong.huang" Date: Thu, 9 Dec 2021 16:15:15 +0800 Subject: [PATCH] add flag --enable_online_fs_expansion: control whether pods that reference the resized volume need to be restarted. Kubernetes v1.11 also introduces an alpha feature called online file system expansion. This feature enables file system expansion while a volume is still in-use by a pod. Because this feature is alpha, it requires enabling the feature gate, ExpandInUsePersistentVolumes. It is supported by the in-tree volume plugins GCE-PD, AWS-EBS, Cinder, and Ceph RBD. When this feature is enabled, pod referencing the resized volume do not need to be restarted. Instead, the file system will automatically be resized while in use as part of volume expansion. File system expansion does not happen until a pod references the resized volume, so if no pods referencing the volume are running file system expansion will not happen. Signed-off-by: zhiyong.huang --- pkg/controller/vitessshard/reconcile_disk.go | 4 +++- pkg/controller/vitessshard/reconcile_tablets.go | 4 +++- pkg/controller/vitessshard/vitessshard_controller.go | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/controller/vitessshard/reconcile_disk.go b/pkg/controller/vitessshard/reconcile_disk.go index 3a5c1275..fa3c39bd 100644 --- a/pkg/controller/vitessshard/reconcile_disk.go +++ b/pkg/controller/vitessshard/reconcile_disk.go @@ -105,7 +105,9 @@ func (r *ReconcileVitessShard) reconcileDisk(ctx context.Context, vts *planetsca // If disk size has changed and the changes are all ready, mark the shard as ready to cascade. Otherwise, skip this. if anythingChanged { - rollout.Cascade(vts) + if !*onlineFileSystemExpansion { + rollout.Cascade(vts) + } err := r.client.Update(ctx, vts) if err != nil { return resultBuilder.Error(err) diff --git a/pkg/controller/vitessshard/reconcile_tablets.go b/pkg/controller/vitessshard/reconcile_tablets.go index 8341e16d..56ac238d 100644 --- a/pkg/controller/vitessshard/reconcile_tablets.go +++ b/pkg/controller/vitessshard/reconcile_tablets.go @@ -182,7 +182,9 @@ func (r *ReconcileVitessShard) reconcileTablets(ctx context.Context, vts *planet UpdateRollingRecreate: func(key client.ObjectKey, obj runtime.Object) { newObj := obj.(*corev1.Pod) tablet := tabletMap[key] - r.updatePVCFilesystemResizeAnnotation(ctx, tablet, newObj) + if !*onlineFileSystemExpansion { + r.updatePVCFilesystemResizeAnnotation(ctx, tablet, newObj) + } vttablet.UpdatePod(newObj, tablet) }, Status: func(key client.ObjectKey, obj runtime.Object) { diff --git a/pkg/controller/vitessshard/vitessshard_controller.go b/pkg/controller/vitessshard/vitessshard_controller.go index 20bc6802..1fc860ca 100644 --- a/pkg/controller/vitessshard/vitessshard_controller.go +++ b/pkg/controller/vitessshard/vitessshard_controller.go @@ -50,6 +50,7 @@ const ( var ( maxConcurrentReconciles = flag.Int("vitessshard_concurrent_reconciles", 10, "the maximum number of different vitessshards to reconcile concurrently") resyncPeriod = flag.Duration("vitessshard_resync_period", 30*time.Second, "reconcile vitessshards with this period even if no Kubernetes events occur") + onlineFileSystemExpansion = flag.Bool("enable_online_fs_expansion", true, "if true, pod referencing the resized volume do not need to be restarted, but provided that the volume plug-in supports, such as GCE-PD, AWS-EBS, Cinder, and Ceph RBD") ) var log = logrus.WithField("controller", "VitessShard")