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

PVC resizing support #616

Merged
merged 2 commits into from
Jul 11, 2024
Merged

PVC resizing support #616

merged 2 commits into from
Jul 11, 2024

Conversation

makhov
Copy link
Contributor

@makhov makhov commented Jun 12, 2024

Fixes #610

k0smotron removes and recreates the Statefulset with an updated size. If the StorageClass allows expansion, k0smotron resizes PVCs and deletes pods to apply the changed PVC.

Also includes a minor etcd improvement, that makes check-etcd-scaling test pass

@makhov makhov force-pushed the pvc-update branch 10 times, most recently from 01405de to 19b279a Compare June 13, 2024 07:55
@makhov makhov marked this pull request as ready for review June 13, 2024 08:21
@makhov makhov requested a review from a team as a code owner June 13, 2024 08:21
@makhov makhov force-pushed the pvc-update branch 5 times, most recently from 90e5907 to 5bc9c45 Compare June 13, 2024 11:41
verbs:
- get
- list
- patch
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need to patch storageclasses objects 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Env: []v1.EnvVar{
{Name: "SVC_NAME", Value: kmc.GetEtcdServiceName()},
},
},
Copy link
Member

Choose a reason for hiding this comment

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

What's the purpose of this? I get that it checks the etcd svc can resolve, but why do we need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The check ensures the node is accessible from the other nodes during the join process.

return fmt.Errorf("failed to delete pod '%s' for resizing: %w", fmt.Sprintf("%s-%d", stsName, i), err)
}
} else {
// Do not check other PVCs if expansion is not allowed
Copy link
Member

Choose a reason for hiding this comment

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

hmm, maybe we should somehow tell user this? I see two options, update the reconcile state and/or create an event

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


return "200Mi" == sts.Spec.VolumeClaimTemplates[0].Spec.Resources.Requests.Storage().String(), nil
})
s.Require().NoError(err)
Copy link
Member

Choose a reason for hiding this comment

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

I guess in the current test setup we cannot check much more as the local provisioners do not really support resizing?

In optimal case I think we'd need to verify couple things:

  • resize actually happened
  • no data has been lost
  • child cluster still behaves properly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Updated the test.

@makhov makhov force-pushed the pvc-update branch 9 times, most recently from dc9aa9b to df144a4 Compare June 20, 2024 11:36
Signed-off-by: Alexey Makhov <[email protected]>
@makhov makhov force-pushed the pvc-update branch 2 times, most recently from df8e4bc to 088de56 Compare June 20, 2024 17:41
@@ -299,6 +299,18 @@ func (r *ClusterReconciler) initialCluster(kmc *km.Cluster, replicas int32) stri

func (r *ClusterReconciler) generateEtcdInitContainers(kmc *km.Cluster) []v1.Container {
return []v1.Container{
{
// Wait for the pods dns name is resolvable, since it takes some tima after the pod is created
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a typo here, tima instead of time

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed!

return false, nil
}

return "250Mi" == sts.Spec.VolumeClaimTemplates[0].Spec.Resources.Requests.Storage().String(), nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should also verify that the etcd volume has been resized to 70Mi

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, makes a lot of sense, thanks! Added the check for etcd statefulset

Signed-off-by: Alexey Makhov <[email protected]>
@makhov makhov merged commit 4ceb4ba into k0sproject:main Jul 11, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Persistent volume resize
3 participants