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

Support Kubernetes 1.27 #525

Merged
merged 10 commits into from
May 29, 2023
Merged

Support Kubernetes 1.27 #525

merged 10 commits into from
May 29, 2023

Conversation

masa213f
Copy link
Contributor

@masa213f masa213f commented May 11, 2023

close: #531

This PR updates k8s libraries and some tools.

The controller-runtime v0.15.0 has breaking changes. So I fix some codes.
Please see PR's comments for the reason of changes.
https://github.com/kubernetes-sigs/controller-runtime/releases/tag/v0.15.0

Signed-off-by: Masayuki Ishii masa213f@gmail.com

@masa213f masa213f self-assigned this May 11, 2023
@masa213f masa213f changed the title Update go modules Support Kubernetes 1.27 May 11, 2023
@masa213f
Copy link
Contributor Author

masa213f commented May 11, 2023

We cannot update supported k8s until the controller-runtime will be updated.
operator-framework/operator-sdk#6396

controller-runtime v0.15.0 was released.

Signed-off-by: Masayuki Ishii <masa213f@gmail.com>
@masa213f masa213f force-pushed the k8s-1.27 branch 3 times, most recently from bf29d3d to a5299cb Compare May 29, 2023 06:21
Signed-off-by: Masayuki Ishii <masa213f@gmail.com>
Signed-off-by: Masayuki Ishii <masa213f@gmail.com>
Signed-off-by: Masayuki Ishii <masa213f@gmail.com>
Signed-off-by: Masayuki Ishii <masa213f@gmail.com>
Signed-off-by: Masayuki Ishii <masa213f@gmail.com>
Signed-off-by: Masayuki Ishii <masa213f@gmail.com>
Signed-off-by: Masayuki Ishii <masa213f@gmail.com>
Signed-off-by: Masayuki Ishii <masa213f@gmail.com>
zoetrope
zoetrope previously approved these changes May 29, 2023
@@ -975,7 +974,7 @@ func (r *MySQLClusterReconciler) reconcileV1StatefulSet(ctx context.Context, req
log.Info("volumeClaimTemplates has changed, delete StatefulSet and try to recreate it", "statefulSetName", cluster.PrefixedName())

// When DeletePropagationOrphan is used to delete, it waits because it is not deleted immediately.
if err := wait.PollImmediate(time.Millisecond*500, time.Second*5, func() (bool, error) {
if err := wait.PollUntilContextTimeout(ctx, time.Millisecond*500, time.Second*5, true, func(ctx context.Context) (bool, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

For newly added but not used context.Context argument, this function accepts with ctx but the function at line 2046 accepts with _.

If you care about it, please fix 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.

This ctx will be used for the Get() immediately after...

By the way, I will change argument name form _ to ctx at line 2046.
Because I found that some existing functions accept ctx even though it was not used.
https://github.com/cybozu-go/moco/blob/v0.16.1/api/v1beta2/mysqlcluster_webhook.go#L37

Copy link
Contributor

Choose a reason for hiding this comment

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

This ctx will be used for the Get() immediately after...

oops...

umezawatakeshi
umezawatakeshi previously approved these changes May 29, 2023
Signed-off-by: Masayuki Ishii <masa213f@gmail.com>
@masa213f masa213f dismissed stale reviews from umezawatakeshi and zoetrope via 76aba78 May 29, 2023 09:03
@@ -29,27 +30,27 @@ type backupPolicyAdmission struct {

var _ webhook.CustomValidator = &backupPolicyAdmission{}

func (a *backupPolicyAdmission) ValidateCreate(ctx context.Context, obj runtime.Object) error {
func (a *backupPolicyAdmission) ValidateCreate(ctx context.Context, obj runtime.Object) (admission.Warnings, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ValidateCreate(), ValidateUpdate() and ValidateDelete() need to retern (warnings Warnings, err error)

ref: kubernetes-sigs/controller-runtime#2014

@@ -146,13 +146,6 @@ func subMain(ns, addr string, port int) error {
return err
}

if config.pprofAddr != "" && config.pprofAddr != "0" {
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 manager supports pprof server by default.
So we can remove the original pprof server added in #500.

ref: kubernetes-sigs/controller-runtime#1943

Watches(&source.Kind{Type: certificateObj}, certHandler).
Watches(&source.Kind{Type: &corev1.ConfigMap{}}, configMapHandler).
Watches(&source.Kind{Type: &mocov1beta2.BackupPolicy{}}, backupPolicyHandler).
Watches(certificateObj, certHandler).
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 signature of Watches() has changed.

ref: kubernetes-sigs/controller-runtime#2135

@@ -2044,7 +2043,7 @@ func setControllerReferenceWithCronJob(cluster *mocov1beta2.MySQLCluster, cronJo

// SetupWithManager sets up the controller with the Manager.
func (r *MySQLClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
certHandler := handler.EnqueueRequestsFromMapFunc(func(a client.Object) []reconcile.Request {
certHandler := handler.EnqueueRequestsFromMapFunc(func(_ context.Context, a client.Object) []reconcile.Request {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

MapFunc requires context.Context.

refs: kubernetes-sigs/controller-runtime#2139

@@ -975,7 +974,7 @@ func (r *MySQLClusterReconciler) reconcileV1StatefulSet(ctx context.Context, req
log.Info("volumeClaimTemplates has changed, delete StatefulSet and try to recreate it", "statefulSetName", cluster.PrefixedName())

// When DeletePropagationOrphan is used to delete, it waits because it is not deleted immediately.
if err := wait.PollImmediate(time.Millisecond*500, time.Second*5, func() (bool, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

PollImmediate is deprecated.

refs: kubernetes/kubernetes#107826 and kubernetes/kubernetes#117143

@@ -975,7 +974,7 @@ func (r *MySQLClusterReconciler) reconcileV1StatefulSet(ctx context.Context, req
log.Info("volumeClaimTemplates has changed, delete StatefulSet and try to recreate it", "statefulSetName", cluster.PrefixedName())

// When DeletePropagationOrphan is used to delete, it waits because it is not deleted immediately.
if err := wait.PollImmediate(time.Millisecond*500, time.Second*5, func() (bool, error) {
if err := wait.PollUntilContextTimeout(ctx, time.Millisecond*500, time.Second*5, true, func(ctx context.Context) (bool, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This ctx will be used for the Get() immediately after...

By the way, I will change argument name form _ to ctx at line 2046.
Because I found that some existing functions accept ctx even though it was not used.
https://github.com/cybozu-go/moco/blob/v0.16.1/api/v1beta2/mysqlcluster_webhook.go#L37

@masa213f masa213f merged commit e47a611 into main May 29, 2023
15 checks passed
@masa213f masa213f deleted the k8s-1.27 branch May 29, 2023 09:35
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.

Support Kubernetes v1.27
3 participants