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

[bug] Version conflicts when updating the status. #502

Closed
runkecheng opened this issue May 27, 2022 · 0 comments · Fixed by #503
Closed

[bug] Version conflicts when updating the status. #502

runkecheng opened this issue May 27, 2022 · 0 comments · Fixed by #503
Labels
bug Something isn't working

Comments

@runkecheng
Copy link
Collaborator

runkecheng commented May 27, 2022

Is your feature request related to a problem? Please describe.

operator log:

ERROR   syncer.StatusSyncer     failed to update cluster status {"mysqlcluster": "sample", "namespace": "default", "error": "Operation cannot be fulfilled on \"sample\": the object has been modified; please apply your changes to the latest version and try again"}

Describe the solution you'd like

Update () needs to compare ResourceVersion.
If the operator only updates the Status, it doesn’t need to pay attention to ResourceVersion
We can use Patch() to instead of Update().

	defer func() {
		if !reflect.DeepEqual(status, instance.Status) {
			sErr := r.Status().Update(ctx, instance.Unwrap())
			if sErr != nil {
				log.Error(sErr, "failed to update cluster status")
			}
		}
	}()

link: https://github.com/kubernetes-sigs/controller-runtime/blob/master/pkg/client/interfaces.go#L97

Describe alternatives you've considered

Additional context

@runkecheng runkecheng added the bug Something isn't working label May 27, 2022
runkecheng added a commit to runkecheng/radondb-mysql-kubernetes that referenced this issue May 27, 2022
update() will compare the Resource Version, causing the update conflict
patch() does not need to compare

fix radondb#502
runkecheng added a commit to runkecheng/radondb-mysql-kubernetes that referenced this issue May 31, 2022
update() will compare the Resource Version, causing the update conflict
patch() does not need to compare

fix radondb#502
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant