Skip to content

feat: add dependencyInterpretation for MPIJob resource customization#7721

Open
Ahmad-Faraj wants to merge 2 commits into
karmada-io:masterfrom
Ahmad-Faraj:feat/mpijob-dependency-interpretation
Open

feat: add dependencyInterpretation for MPIJob resource customization#7721
Ahmad-Faraj wants to merge 2 commits into
karmada-io:masterfrom
Ahmad-Faraj:feat/mpijob-dependency-interpretation

Conversation

@Ahmad-Faraj

Copy link
Copy Markdown

What type of PR is this?

/kind feature

What this PR does / why we need it:

MPIJob's resource customization has no dependencyInterpretation, so ConfigMaps, Secrets, ServiceAccounts and PVCs referenced from its pod templates are not propagated with the job. Add one mirroring the TFJob script over spec.mpiReplicaSpecs (Launcher and Worker), with testdata like the existing kinds.

Which issue(s) this PR fixes:

Fixes #7720

Special notes for your reviewer:

Test cases follow the TFJob interpretdependency-test.yaml conventions and pass in TestThirdPartyCustomizationsFile.

Does this PR introduce a user-facing change?:

`karmada-controller-manager`: MPIJob dependencies (ConfigMaps, Secrets, ServiceAccounts, PVCs referenced by pod templates) now propagate with the job via the built-in resource interpreter.

MPIJob had no dependencyInterpretation, so ConfigMaps, Secrets,
ServiceAccounts and PVCs referenced from its pod templates were not
propagated with the job. Mirror the TFJob script over
spec.mpiReplicaSpecs (Launcher and Worker), with testdata.

Signed-off-by: Ahmad Faraj <ahmedfrag4040@gmail.com>
Copilot AI review requested due to automatic review settings July 6, 2026 19:17
@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 6, 2026
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces dependency interpretation for MPIJob resources within the resource interpreter. By enabling the propagation of referenced ConfigMaps, Secrets, ServiceAccounts, and PVCs, it ensures that MPIJobs maintain their required dependencies during cross-cluster operations, mirroring the existing functionality provided for TFJobs.

Highlights

  • Dependency Interpretation Added: Implemented dependencyInterpretation for MPIJob resources to ensure ConfigMaps, Secrets, ServiceAccounts, and PVCs are correctly propagated.
  • Lua Script Integration: Added a Lua script to the MPIJob resource customization that iterates through Launcher and Worker replica specs to extract pod dependencies.
  • Comprehensive Test Coverage: Added new test data to verify dependency interpretation across various scenarios, including empty specs, default service accounts, and environment variable references.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@karmada-bot

Copy link
Copy Markdown
Contributor

[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 chaunceyjiang for approval. For more information see the 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

@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 6, 2026

Copilot AI 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.

Pull request overview

Adds built-in dependency interpretation for Kubeflow MPIJob (v2beta1) so Karmada can automatically propagate referenced ConfigMaps, Secrets, ServiceAccounts, and PVCs from Launcher/Worker pod templates, matching existing TFJob/PyTorchJob behavior.

Changes:

  • Add dependencyInterpretation Lua script for MPIJob that walks spec.mpiReplicaSpecs for Launcher and Worker and collects pod-template dependencies via kube.getPodDependencies.
  • Add interpretdependency-test.yaml testdata covering multiple dependency sources, empty specs, default ServiceAccount exclusion, and envFrom references.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/resourceinterpreter/default/thirdparty/resourcecustomizations/kubeflow.org/v2beta1/MPIJob/customizations.yaml Adds dependencyInterpretation for MPIJob by collecting dependencies from Launcher/Worker pod templates.
pkg/resourceinterpreter/default/thirdparty/resourcecustomizations/kubeflow.org/v2beta1/MPIJob/testdata/interpretdependency-test.yaml Adds test cases verifying correct dependency extraction behavior for MPIJob.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Copy link
Copy Markdown

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 dependency interpretation for MPIJob resources by adding a Lua script to extract dependencies from replica specs (Launcher and Worker) and includes corresponding test cases. The reviewer suggested dynamically iterating over the replica specs using pairs instead of hardcoding the replica types to improve robustness and maintain consistency with other parts of the codebase.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +232 to +244
-- Iterate all MPIJob replica types
local replicaTypes = {"Launcher", "Worker"}
for _, replicaType in ipairs(replicaTypes) do
local spec = desiredObj.spec.mpiReplicaSpecs[replicaType]
if spec ~= nil and spec.template ~= nil then
local deps = kube.getPodDependencies(spec.template, desiredObj.metadata.namespace)
if deps ~= nil then
for _, dep in ipairs(deps) do
table.insert(refs, dep)
end
end
end
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Instead of hardcoding the replica types as {"Launcher", "Worker"}, we can dynamically iterate over all keys in desiredObj.spec.mpiReplicaSpecs using pairs. This is more robust, future-proof, and aligns with how replica specs are processed in GetComponents (line 56) in the same file.

          -- Iterate over all replica specs dynamically to extract dependencies
          for _, spec in pairs(desiredObj.spec.mpiReplicaSpecs) do
            if spec ~= nil and spec.template ~= nil then
              local deps = kube.getPodDependencies(spec.template, desiredObj.metadata.namespace)
              if deps ~= nil then
                for _, dep in ipairs(deps) do
                  table.insert(refs, dep)
                end
              end
            end
          end

@codecov-commenter

codecov-commenter commented Jul 6, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.07%. Comparing base (09eb45a) to head (0fa9dfa).
⚠️ Report is 10 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7721   +/-   ##
=======================================
  Coverage   42.06%   42.07%           
=======================================
  Files         879      879           
  Lines       54831    54831           
=======================================
+ Hits        23063    23068    +5     
+ Misses      30023    30019    -4     
+ Partials     1745     1744    -1     
Flag Coverage Δ
unittests 42.07% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Signed-off-by: Ahmad Faraj <ahmedfrag4040@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. 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.

MPIJob resource customization has no dependencyInterpretation

4 participants