Skip to content

Apply validator resources to init containers#2557

Open
Shivkumar13 wants to merge 1 commit into
NVIDIA:mainfrom
Shivkumar13:gh-702-init-container-resources
Open

Apply validator resources to init containers#2557
Shivkumar13 wants to merge 1 commit into
NVIDIA:mainfrom
Shivkumar13:gh-702-init-container-resources

Conversation

@Shivkumar13

Copy link
Copy Markdown
Collaborator

Fixes #702.

This change applies the existing spec.validator.resources settings to validator init containers as well as the main validator container. The affected init containers run the validator image for driver, toolkit, CUDA, and plugin checks, so using the existing validator resource field keeps the API surface unchanged while making those init containers configurable.

Validation:

  • go test ./controllers -run TestTransformValidatorComponentWithResources -count=1
  • go test ./controllers -run TestTransformValidator -count=1
  • go test ./controllers -run TestTransformSandboxValidator -count=1

@rahulait

rahulait commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Thanks @Shivkumar13 , the changes look fine to me. We should be doing this for all driver daemonsets managed by gpu-operator. For example, we are still missing requests/limits for k8s-driver-manager init container in driver daemonset. There are few other init containers as well which are also missing requests/limits.

@Shivkumar13

Copy link
Copy Markdown
Collaborator Author

@rahulait should we do that in this PR or separate ones?

@rahulait

Copy link
Copy Markdown
Contributor

Lets do them in single PR if possible. Its easier to review together and keep things consistent and tied to single commit.

@rahulait

Copy link
Copy Markdown
Contributor

@tariq1890 any objections to the change being done here?

@tariq1890

Copy link
Copy Markdown
Contributor

Lets do them in single PR if possible. Its easier to review together and keep things consistent and tied to single commit.

Agreed, we should be making this change in this PR. This behavioural change should applied consistently to all components managed by the operator

@Shivkumar13
Shivkumar13 force-pushed the gh-702-init-container-resources branch from 98cfccd to 0af5a73 Compare July 26, 2026 07:46
Comment thread controllers/object_controls.go Outdated

// apply plugin configuration through ConfigMap if one is provided
err = handleDevicePluginConfig(obj, config)
err = handleDevicePluginConfig(obj, config, config.DevicePlugin.Resources)

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.

If Resources is nested within config, why add one more function argument? Can't we just access .DevicePlugin.Resources from the existing config function arg?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment thread controllers/object_controls.go Outdated

// apply spec changes to make custom configurations provided via a ConfigMap available to all containers
func handleDevicePluginConfig(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec) error {
func handleDevicePluginConfig(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, resources *gpuv1.ResourceRequirements) error {

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.

Suggested change
func handleDevicePluginConfig(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, resources *gpuv1.ResourceRequirements) error {
func handleDevicePluginConfig(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec) error {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

Comment thread controllers/object_controls.go Outdated
}

func transformConfigManagerInitContainer(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec) error {
func transformConfigManagerInitContainer(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, resources *gpuv1.ResourceRequirements) error {

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.

Suggested change
func transformConfigManagerInitContainer(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, resources *gpuv1.ResourceRequirements) error {
func transformConfigManagerInitContainer(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec) error {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed it

Comment thread controllers/object_controls.go Outdated
if config.DevicePlugin.ImagePullPolicy != "" {
initContainer.ImagePullPolicy = gpuv1.ImagePullPolicy(config.DevicePlugin.ImagePullPolicy)
}
applyResourceRequirements(initContainer, resources)

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.

Suggested change
applyResourceRequirements(initContainer, resources)
applyResourceRequirements(initContainer, config.DevicePlugin.Resources)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

@rahulait

rahulait commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

This PR does not update the DRA driver DaemonSet at manifests/state-dra-driver/0500_daemonset.yaml. Its driver-validation init container still has no resources. Since both the regular containers can have their own requests/limits, we should use the max of them for init container.

Signed-off-by: Shivkumar Ople <sople@nvidia.com>
@Shivkumar13
Shivkumar13 force-pushed the gh-702-init-container-resources branch from 0af5a73 to bd73cd3 Compare July 27, 2026 07:05
@Shivkumar13
Shivkumar13 requested a review from tariq1890 July 27, 2026 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

InitContainers have non configurable and explicitely empty resrources

3 participants