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

Patch option error: client.FieldOwner does not implement 'SubResourcePatchOption' #2204

Closed
ArenaSu opened this issue Feb 17, 2023 · 5 comments

Comments

@ArenaSu
Copy link

ArenaSu commented Feb 17, 2023

controller-runtime version

sigs.k8s.io/controller-runtime v0.14.1

Code below:

import sigs.k8s.io/controller-runtime/pkg/client
...
func EndReconcileWithNegativeCondition(ctx context.Context, r client.StatusClient, workload ConditionedObject,
	condition ...condition.Condition) error {
	if len(condition) == 0 {
		return nil
	}
	workloadPatch := client.MergeFrom(workload.DeepCopyObject().(client.Object))
	conditionIsChanged := IsConditionChanged(condition, workload)
	workload.SetConditions(condition...)
	if err := r.Status().Patch(ctx, workload, workloadPatch, client.FieldOwner(workload.GetUID())); err != nil {
		return errors.Wrap(err, ErrUpdateStatus)
	}
	if conditionIsChanged {
		// if any condition is changed, patching status can trigger requeue the resource and we should return nil to
		// avoid requeue it again
		return nil
	}
	// if no condition is changed, patching status can not trigger requeue, so we must return an error to
	// requeue the resource
	return errors.Errorf(ErrReconcileErrInCondition, condition[0].Type, condition[0].Message)
}

Goland error messge below:

Cannot use 'client.FieldOwner(workload.GetUID())' (type client.FieldOwner) as the type SubResourcePatchOption Type does not implement 'SubResourcePatchOption' as some methods are missing: ApplyToSubResourcePatch(*SubResourcePatchOptions)
@alvaroaleman
Copy link
Member

Feel free to submit a fix

@alculquicondor
Copy link
Contributor

This was broken by #2072
I can work on a fix tomorrow.

@alculquicondor
Copy link
Contributor

alculquicondor commented Mar 2, 2023

If we provide a fix, how fast can you produce a release?

@alculquicondor
Copy link
Contributor

oh, this was already fixed by #2115

/close

@k8s-ci-robot
Copy link
Contributor

@alculquicondor: Closing this issue.

In response to this:

oh, this was already fixed by #2115

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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

No branches or pull requests

4 participants