Skip to content

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 [email protected]

@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 <[email protected]>
@masa213f masa213f force-pushed the k8s-1.27 branch 3 times, most recently from bf29d3d to a5299cb Compare May 29, 2023 06:21
masa213f added 7 commits May 29, 2023 06:32
Signed-off-by: Masayuki Ishii <[email protected]>
Signed-off-by: Masayuki Ishii <[email protected]>
Signed-off-by: Masayuki Ishii <[email protected]>
Signed-off-by: Masayuki Ishii <[email protected]>
Signed-off-by: Masayuki Ishii <[email protected]>
Signed-off-by: Masayuki Ishii <[email protected]>
Signed-off-by: Masayuki Ishii <[email protected]>
zoetrope
zoetrope previously approved these changes May 29, 2023

// 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 <[email protected]>
@masa213f masa213f dismissed stale reviews from umezawatakeshi and zoetrope via 76aba78 May 29, 2023 09:03
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

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

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

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


// 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 requested a review from umezawatakeshi May 29, 2023 09:25
@masa213f masa213f merged commit e47a611 into main May 29, 2023
@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