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

Feature - Add/Modify/Delete tags for model resource #261

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

rkurduka
Copy link

@rkurduka rkurduka commented Mar 1, 2024

Issue 1732, if available:

Description of changes:
Currently tags modification is not supported for model resource . Hence added require changes to support tags modification.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@a-hilaly
Copy link
Member

a-hilaly commented Mar 2, 2024

/retest

Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

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

@rkurduka we have plans to start generating Tag handlers for all the ACK controllers. But nothing stops us from implement some manually if there is urgent need for them :)
I left few comments in-line

Comment on lines +25 to +27
AddTags:
operation_type: Update
resource_name: Model
Copy link
Member

Choose a reason for hiding this comment

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

This generates code that treats AddTags as the Update API Call to update the model.

Copy link
Author

Choose a reason for hiding this comment

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

@a-hilaly - Thanks for review.
Sagemaker model API do not have any modify /update method , as fields are immutable except tags . Also Sagemaker API resource only have "ADDTAG" and "DELETE TAG" . So to handle update on this resource will have to use one of these two. So chose "ADD TAGS" and handling "DELETE tags" using template hooks.

Let me know if you think any other approach we can consider

Copy link
Member

Choose a reason for hiding this comment

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

Agree with Amine, need to discuss this further as we need to throw appropriate error if any other fields except Tags are modified as Model does not have udpate API, maybe implement it completely via hooks

Copy link
Author

@rkurduka rkurduka Mar 6, 2024

Choose a reason for hiding this comment

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

@surajkota - Added check in update_pre hooks to validate field to update, if it is other than tag , reconciler will update "message" status. Please review

Please let me know if you feel anything else is require

helm/Chart.yaml Outdated
@@ -1,8 +1,8 @@
apiVersion: v1
name: sagemaker-chart
description: A Helm chart for the ACK service controller for Amazon SageMaker (SageMaker)
version: 1.2.7
appVersion: 1.2.7
version: 0.0.0-non-release-version
Copy link
Member

Choose a reason for hiding this comment

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

Please pull the controller tags

Copy link
Author

Choose a reason for hiding this comment

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

Done

@@ -3,7 +3,8 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.9.2
Copy link
Member

Choose a reason for hiding this comment

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

You need to install controller-gen v0.14.0

Copy link
Author

Choose a reason for hiding this comment

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

Done

Comment on lines +1 to +5
// this to handle delete/remove tags
_ , err = rm.deleteTags(ctx,desired,latest)
if err != nil {
return nil, err
}
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to delete the tags before performing a tag update.

Copy link
Author

Choose a reason for hiding this comment

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

@a-hilaly - as I mentioned above , SDK update method is handling ADDTAGS only and hooks are deleting tags , there is no modify API available for sagemaker model resource . So in SDKUPDATE , first "DeletTags" method look for any deletion request , if not then proceed and look for add tags request .

Let me know if anything else is require.

)

// deleteTags is used to keep tags in sync by calling Create and Delete API's
func (rm *resourceManager) deleteTags(
Copy link
Member

Choose a reason for hiding this comment

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

This function should stay, syncTags and also handle tag creation

Copy link
Author

Choose a reason for hiding this comment

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

@a-hilaly - same comments as above , let me know if any other approach we should consider here

@a-hilaly
Copy link
Member

a-hilaly commented Mar 2, 2024

/hold

@ack-prow ack-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 2, 2024
@rkurduka
Copy link
Author

rkurduka commented Mar 5, 2024

@rkurduka we have plans to start generating Tag handlers for all the ACK controllers. But nothing stops us from implement some manually if there is urgent need for them :) I left few comments in-line

@a-hilaly - thanks for update . Yes there was customer ask for this . Issue 1732 has details

Copy link

ack-prow bot commented Mar 5, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rkurduka
Once this PR has been reviewed and has the lgtm label, please ask for approval from ryansteakley by writing /assign @ryansteakley in a comment. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

Copy link
Member

@surajkota surajkota left a comment

Choose a reason for hiding this comment

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

}

// computeTagsDelta returns tags to be added and removed from the resource
func computeTagsDelta(
Copy link
Member

Choose a reason for hiding this comment

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

Sagemaker tag API pattern(addTag/deleteTag) resembles memorydb pattern (TagResource/UntagResource).

We have a reference implementation in memorydb which uses ackcompare.GetTagsDifference helper method which can reduce maintenance of SM controller code. https://github.com/aws-controllers-k8s/memorydb-controller/blob/main/pkg/resource/acl/hooks.go#L92

Can you please look into adopting similar pattern?

FYI @ryansteakley @a-hilaly

Copy link
Author

Choose a reason for hiding this comment

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

Thanks @surajkota for sharing this , and looking into it . But it seems memoryDB - ACL resource do have "UpdateACL" API method . So we can plug tags manipulation in it , using hooks. But in sagemaker -model case , there is NO update method available , so "SDKUPDATE block doesn't get generated by code-generator . So had to generate that using "ADDTags" in "Operation" Block , and later handling tags CRUD operations in it . Let me know if you have any suggestion in this case. Thanks again

Copy link

ack-prow bot commented Aug 30, 2024

@rkurduka: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
sagemaker-unit-test 99037c2 link true /test sagemaker-unit-test
sagemaker-kind-e2e 99037c2 link true /test sagemaker-kind-e2e
sagemaker-verify-attribution 99037c2 link true /test sagemaker-verify-attribution

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants