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

fix: pass context throughout applier #656

Merged
merged 1 commit into from
Feb 21, 2025

Conversation

sdowell
Copy link
Contributor

@sdowell sdowell commented Feb 19, 2025

There were various spots in the applier that were not propagating the context and instead just using an empty context. This change fixes all such locations so that the parent context is always honored.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 19, 2025
@k8s-ci-robot k8s-ci-robot requested review from ash2k and seans3 February 19, 2025 21:51
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 19, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @sdowell. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 19, 2025
@karlkfi
Copy link
Contributor

karlkfi commented Feb 20, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 20, 2025
@@ -49,7 +51,7 @@ func (i *DeleteOrUpdateInvTask) Start(taskContext *taskrunner.TaskContext) {
go func() {
var err error
if i.Destroy && i.destroySuccessful(taskContext) {
err = i.deleteInventory()
err = i.deleteInventory(taskContext.Context())
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm. should we make deleteInventory take a taskContext to be consistent with updateInventory?

Copy link
Contributor

Choose a reason for hiding this comment

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

This was the only one I saw, but please double check that all the other interfaces have consistent use of either the TaskContext or the Context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updateInventory actually uses other fields from the taskContext, which is why it needs it. deleteInventory just needs the context.Context. It's such a tiny function it doesn't seem like it matters to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

You know I love consistency, but I agree it's a small enough that it's not a blocker.

There were various spots in the applier that were not propagating the
context and instead just using an empty context. This change fixes all
such locations so that the parent context is always honored.
@karlkfi
Copy link
Contributor

karlkfi commented Feb 21, 2025

/retest

@@ -40,12 +41,12 @@ type Storage interface {
GetObject() (*unstructured.Unstructured, error)
// Apply applies the inventory object. This utility function is used
// in InventoryClient.Merge and merges the metadata, spec and status.
Apply(dynamic.Interface, meta.RESTMapper, StatusPolicy) error
Apply(context.Context, dynamic.Interface, meta.RESTMapper, StatusPolicy) error
Copy link
Contributor

@karlkfi karlkfi Feb 21, 2025

Choose a reason for hiding this comment

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

This will require updating the RG inventory client in order to pull this change into Config Sync (or kpt). So we won't be able to pull this in until we either merge my third_party fork or your inventory client rewrite.

Are we ready to do that now? Or should we line up those PRs to be a little closer to landing?

If waiting is the better option, you could just pull this file's changes out to a different PR and merge the rest of this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not planning to upgrade cli-utils in Config Sync until the next change goes in (#653), which completely changes these interfaces.

My intent here was to fix the context issue as an incremental change before the complete interface rewrite. Alternatively we could fix the context issue as part of the interface rewrite or as a subsequent change. I'm fine either way.

If we submit this change and then for some reason need to immediately bump the cli-utils version, we could always update the kpt client implementation to pass a context through.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright.

I'm gonna extract my third_party fork to its own PR anyway. So that will unblock using these as soon as monday.

Copy link
Contributor

@karlkfi karlkfi left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 21, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: karlkfi, sdowell

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 21, 2025
@k8s-ci-robot k8s-ci-robot merged commit 1a9b045 into kubernetes-sigs:master Feb 21, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants