Skip to content

fix: propagate context through dataflow affinity job paths#5880

Merged
cheyang merged 4 commits into
fluid-cloudnative:masterfrom
CAICAIIs:5705-dataflowaffinity-context
Jun 9, 2026
Merged

fix: propagate context through dataflow affinity job paths#5880
cheyang merged 4 commits into
fluid-cloudnative:masterfrom
CAICAIIs:5705-dataflowaffinity-context

Conversation

@CAICAIIs

@CAICAIIs CAICAIIs commented May 15, 2026

Copy link
Copy Markdown
Contributor

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

fluid-e2e-bot Bot commented May 15, 2026

Copy link
Copy Markdown

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.

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

Copy link
Copy Markdown
Contributor

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

codecov Bot commented May 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 32.69231% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.31%. Comparing base (ed9b7ef) to head (ff283b3).
⚠️ Report is 50 commits behind head on master.

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%   63.31%   +1.66%     
==========================================
  Files         480      481       +1     
  Lines       32613    33113     +500     
==========================================
+ Hits        20108    20967     +859     
+ Misses      10897    10473     -424     
- Partials     1608     1673      +65     

☔ View full report in Codecov by Harness.
📢 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>
@cheyang

cheyang commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Looks good overall. Context propagation is complete through the entire Reconcile -> injectPodNodeLabelsToJob path, backward compatibility is preserved via the delegation pattern, and cancellation behavior is properly tested. One minor consistency nit on error wrapping below, otherwise LGTM.

Comment thread pkg/utils/kubeclient/job.go
Signed-off-by: CAICAIIs <3360776475@qq.com>
@sonarqubecloud

sonarqubecloud Bot commented Jun 8, 2026

Copy link
Copy Markdown

@cheyang cheyang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All CI checks passed and maintainer has approved. Auto-approving to satisfy branch protection.

@fluid-e2e-bot

fluid-e2e-bot Bot commented Jun 9, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cheyang

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

The pull request process is described 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

@cheyang cheyang merged commit dae5534 into fluid-cloudnative:master Jun 9, 2026
23 checks passed
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.

2 participants