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(scheduler): pod-spec-patch was not working on default init containers #484

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

defgenx
Copy link

@defgenx defgenx commented Jan 24, 2025

Description

This PR resolves an issue where the PodSpecPatch for default initContainers was not functioning correctly in the scheduler.

Changes

  • Fixed duplication of init containers in podSpecPatch when the init-container exists.
  • Update the documentation for patching resources.
  • Ensure the documentation of pod-spec-patch is aligned with what the code is doing.

@defgenx defgenx force-pushed the fix-pod-spec-patch-init-container branch 2 times, most recently from 30f1247 to a9f5427 Compare January 24, 2025 16:51
@defgenx defgenx force-pushed the fix-pod-spec-patch-init-container branch from a9f5427 to 2d9b15c Compare January 24, 2025 16:53
@defgenx defgenx changed the title fix(scheduler): pod-spec-patch was not working on init containers fix(scheduler): pod-spec-patch was not working on default init containers Jan 24, 2025
Copy link
Contributor

@DrJosh9000 DrJosh9000 left a comment

Choose a reason for hiding this comment

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

Thanks for raising this PR, @defgenx ! I have a question, see below.

@@ -560,7 +560,7 @@ func (w *worker) Build(podSpec *corev1.PodSpec, skipCheckout bool, inputs buildI
)
}

initContainers := []corev1.Container{w.createWorkspaceSetupContainer(podSpec, workspaceVolume)}
podSpec.InitContainers = []corev1.Container{w.createWorkspaceSetupContainer(podSpec, workspaceVolume)}
Copy link
Contributor

Choose a reason for hiding this comment

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

If the user has supplied a podSpec that already defines one or more init containers, this would replace them with the workspace setup container.

It would also make the workspace setup container patchable, which would make it easy to break the way the agent is designed to work in the pod. Is that the intent of this PR? What's the use case you have in mind?

Copy link
Author

@defgenx defgenx Jan 28, 2025

Choose a reason for hiding this comment

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

Thanks for reviewing and answering !

Yes true, my bad. We can move to an `append" here instead. I forgot about plugins to be honest.

From my understanding, pod-spec-patch is an advanced feature allowing anyone to patch the podSpec default values at runtime.
In our case we want to change the resources and the image pull policy of the copy-agent init container. It looks like it's nothing new because it was possible with the old pod-spec-patch implementation; making me think it's more a regression than a feature.
It's also possible to patch the containers of the agent right now so it would make sense to allow patching the init containers too. What do you think about it ?

Let me know if you have anything else in mind, but controlling the cost is really important for us and since we bumped from an old agent version to the last one, we cannot do that anymore so I tried to make it works again. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, thanks for clarifying. I think the init container commands and args should still be protected from modification (with an override in the form of #449), but allowing the resources to be limited makes total sense.

Since these default containers should require bare minimum resources on pretty much any system, I wonder if they should be generated with default limits - that way you wouldn't have to patch them at all!

Copy link
Author

@defgenx defgenx Feb 4, 2025

Choose a reason for hiding this comment

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

Yes we can keep the command protected but I feel we should be able to patch the rest (as for containers). I can update the PR so we raise an error if the command is touched. Is it ok for you ?

If we could have a configuration to define the resources by default for the copy-agent init container, I would use it instead. We would still need to be able to change the pull policy too or anything which is configurable except the command.

Can we keep this PR to make it works like for containers and then add the feature to configure the copy-agent in another PR later?

EDIT: made the fix to prevent command from default init containers (only copy-agent right now) to be modified.

@defgenx defgenx requested a review from a team as a code owner February 4, 2025 11:17
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.

2 participants