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

✨ implement patch function in ManifestWorkAgentClient #271

Conversation

skeeey
Copy link
Member

@skeeey skeeey commented Aug 31, 2023

Summary

implement path function in ManifestWorkAgentClient

@skeeey
Copy link
Member Author

skeeey commented Aug 31, 2023

/assign @qiujian16

@qiujian16 qiujian16 changed the title ✨ implement path function in ManifestWorkAgentClient ✨ implement patch function in ManifestWorkAgentClient Aug 31, 2023
func (c *ManifestWorksAgentClient) Create(ctx context.Context, manifestWork *workv1.ManifestWork, opts metav1.CreateOptions) (*workv1.ManifestWork, error) {
klog.Fatal("Create function for ManifestWorksAgentClient is unsupported")
func (c *ManifestWorkAgentClient) Create(ctx context.Context, manifestWork *workv1.ManifestWork, opts metav1.CreateOptions) (*workv1.ManifestWork, error) {
klog.Fatal("Create function for ManifestWorkAgentClient is unsupported")
Copy link
Member

Choose a reason for hiding this comment

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

fatal seems not appropriate, should we just return not supported error here/.

Copy link
Member Author

Choose a reason for hiding this comment

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

return MethodNotSupported error

if err != nil {
return nil, err
}
case types.StrategicMergePatchType:
Copy link
Member

Choose a reason for hiding this comment

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

StrategicMergePatchType is not supported in CRD.

Copy link
Member Author

Choose a reason for hiding this comment

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

do we need handle the crd here? we patch a work here, if a work has a crd, we will stop here? or the caller should not use this type when they patch their works that contain crds?

Copy link
Member Author

Choose a reason for hiding this comment

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

and it seems to be difficult for us to distinguish pacth a work or patch the crds in works

Copy link
Member

Choose a reason for hiding this comment

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

no I mean resource served by crd, in this case ManifestWork does not support StrategicMergePatchType

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, remvoe the StrategicMergePatchType support

eventDataType, err := types.ParseCloudEventsDataType(patchedWork.Annotations[codec.CloudEventsDataTypeAnnotationKey])
if err != nil {
return nil, err
}

eventType := types.CloudEventsType{
CloudEventsDataType: *eventDataType,
SubResource: types.SubResourceStatus,
Copy link
Member

Choose a reason for hiding this comment

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

should we set SubResource after checking the sub resource?

Copy link
Member Author

@skeeey skeeey Aug 31, 2023

Choose a reason for hiding this comment

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

we don't need, we just send the work status to source here (deletion is also a status update for a source)

// send resync request to fetch manifestworks from source when the ManifestWorkInformer status
if err := c.cloudEventsClient.Resync(ctx); err != nil {
return nil, err
if IsStatusUpdate(subresources) {
Copy link
Member

Choose a reason for hiding this comment

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

if it is not status subresource we should return error

Copy link
Member Author

Choose a reason for hiding this comment

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

return the error at the end

Copy link
Member

Choose a reason for hiding this comment

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

i mean it could be either patch the finalizer (patch spec) or patch status. We can not patch other sub resources.

Copy link
Member Author

Choose a reason for hiding this comment

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

return the error if the patch is not for status or finalizers and allow update finalizers(add/remvoe)

@skeeey skeeey force-pushed the cloudevents-patch branch 7 times, most recently from c6f518c to 0943e5f Compare September 1, 2023 06:51
Signed-off-by: Wei Liu <liuweixa@redhat.com>
@qiujian16
Copy link
Member

/approve
/lgtm

@openshift-ci openshift-ci bot added the lgtm label Sep 1, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 1, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qiujian16, skeeey

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Sep 1, 2023
@openshift-merge-robot openshift-merge-robot merged commit 14fa3e0 into open-cluster-management-io:main Sep 1, 2023
10 checks passed
@skeeey skeeey deleted the cloudevents-patch branch September 4, 2023 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants