Skip to content

fix: propagate context through dataflow affinity job paths#5880

Open
CAICAIIs wants to merge 3 commits into
fluid-cloudnative:masterfrom
CAICAIIs:5705-dataflowaffinity-context
Open

fix: propagate context through dataflow affinity job paths#5880
CAICAIIs wants to merge 3 commits into
fluid-cloudnative:masterfrom
CAICAIIs:5705-dataflowaffinity-context

Conversation

@CAICAIIs
Copy link
Copy Markdown
Contributor

@CAICAIIs CAICAIIs commented May 15, 2026

What this PR does

Related to #5705.
This PR continues the context propagation work from #5705 by wiring the reconcile context.Context through DataFlowAffinity job reconciliation paths.

It updates the DataFlowAffinity job controller to use context-aware kubeclient helpers when:

  • fetching the reconciled Job
  • listing the succeeded Pod for a completed Job
  • fetching the Pod's Node
  • updating injected Job annotations

It also adds context-aware Job and Node helper variants while keeping the existing helper APIs as compatibility wrappers.

Why this is needed

Some DataFlowAffinity job paths still used helper functions backed by context.TODO(), so cancellation/deadline signals from the reconciler were not propagated through all Kubernetes client calls.

Tests

go test ./pkg/controllers/v1alpha1/fluidapp/dataflowaffinity -count=1 -v
go test ./pkg/utils/kubeclient -count=1 -v
GOTOOLCHAIN=go1.24.12 test -z "$($(GOTOOLCHAIN=go1.24.12 go env GOROOT)/bin/gofmt -l ./pkg ./cmd ./api)"

Signed-off-by: CAICAIIs <3360776475@qq.com>
@fluid-e2e-bot
Copy link
Copy Markdown

fluid-e2e-bot Bot commented May 15, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign cheyang for approval by writing /assign @cheyang 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.

Details 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

@fluid-e2e-bot
Copy link
Copy Markdown

fluid-e2e-bot Bot commented May 15, 2026

Hi @CAICAIIs. Thanks for your PR.

I'm waiting for a fluid-cloudnative 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.

Details

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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces WithContext variants for Kubernetes client operations (Get, Update, List) within the kubeclient utility and updates the DataOpJobReconciler to utilize these methods, effectively replacing context.TODO() with the reconciliation context. It also includes comprehensive unit tests to verify correct error handling when contexts are canceled. The review feedback suggests avoiding variable shadowing of the client package name, reducing code duplication by moving test helpers to a shared utility, and maintaining consistency by calling the client directly where wrappers do not add value.

Comment thread pkg/controllers/v1alpha1/fluidapp/dataflowaffinity/dataflowaffinity_controller.go Outdated
Comment thread pkg/utils/kubeclient/job.go Outdated
Comment thread pkg/utils/kubeclient/job.go Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 31.37255% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.60%. Comparing base (ed9b7ef) to head (1870bb1).

Files with missing lines Patch % Lines
pkg/utils/fake/client.go 0.00% 35 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5880      +/-   ##
==========================================
- Coverage   61.65%   61.60%   -0.05%     
==========================================
  Files         480      480              
  Lines       32613    32656      +43     
==========================================
+ Hits        20108    20119      +11     
- Misses      10897    10930      +33     
+ Partials     1608     1607       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

CAICAIIs added 2 commits May 15, 2026 12:54
Signed-off-by: CAICAIIs <3360776475@qq.com>
Signed-off-by: CAICAIIs <3360776475@qq.com>
@sonarqubecloud
Copy link
Copy Markdown

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.

1 participant