Skip to content

Merge supplementalGroups when combining pod YAML with builder spec - #2850

Open
amarkdotdev wants to merge 1 commit into
jenkinsci:masterfrom
amarkdotdev:fix/supplemental-groups-yaml-override
Open

Merge supplementalGroups when combining pod YAML with builder spec#2850
amarkdotdev wants to merge 1 commit into
jenkinsci:masterfrom
amarkdotdev:fix/supplemental-groups-yaml-override

Conversation

@amarkdotdev

@amarkdotdev amarkdotdev commented Jul 8, 2026

Copy link
Copy Markdown
Member

Fixes #2849

Summary

  • Merge supplementalGroups in PodTemplateUtils.combine(Pod, Pod) alongside existing pod-level runAsUser / runAsGroup handling
  • Add unit tests in PodTemplateUtilsTest and SupplementalGroupsYamlOverrideReproTest

Problem

Pod template Supplemental Groups are dropped when raw pod YAML uses Override merge strategy. Jenkins console raw YAML and the live pod both show only:

securityContext:
  runAsGroup: 1000
  runAsUser: 1000

Test plan

  • PodTemplateUtilsTest#shouldCombinePodSupplementalGroupsFromTemplate
  • SupplementalGroupsYamlOverrideReproTest
  • CI (mvn verify)

@amarkdotdev
amarkdotdev requested a review from a team as a code owner July 8, 2026 20:27
@amarkdotdev
amarkdotdev force-pushed the fix/supplemental-groups-yaml-override branch from 6b021f9 to 1f1b028 Compare July 8, 2026 21:15
@amarkdotdev
amarkdotdev force-pushed the fix/supplemental-groups-yaml-override branch from 1f1b028 to c122a91 Compare July 12, 2026 19:19
@amarkdotdev
amarkdotdev force-pushed the fix/supplemental-groups-yaml-override branch from c122a91 to f362607 Compare July 21, 2026 19:25
@jglick jglick added the bug Bug Fixes label Jul 22, 2026
* Related to jenkinsci/kubernetes-plugin#2444.
*/
@WithJenkins
@ExtendWith(MockitoExtension.class)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Avoid Mockito if at all possible.

I see no purpose to this test. Should PodTemplateUtilsTest not be able to cover it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

moved this into PodTemplateUtilsTest and yanked the mockito test

PodTemplateUtils.combine() only copied runAsUser and runAsGroup into the
merged pod securityContext. supplementalGroups configured on the pod
template (UI, CasC, or pipeline) were dropped whenever raw pod YAML was
present with the Override merge strategy.

Add supplementalGroups resolution alongside the existing pod-level security
context merge and cover the regression in PodTemplateUtilsTest (no Mockito).

Signed-off-by: amarkdotdev <amarkdotdev@users.noreply.github.com>
@amarkdotdev
amarkdotdev force-pushed the fix/supplemental-groups-yaml-override branch from 0256698 to 4cb038e Compare July 27, 2026 20:43
@amarkdotdev

Copy link
Copy Markdown
Member Author

@jglick Dropped SupplementalGroupsYamlOverrideReproTest (and the Mockito/PodTemplateBuilder path). The regression is covered in PodTemplateUtilsTest via combine() — matching PodTemplateBuilder.combine(yamlPod, builderPod) — including the case where the template supplies supplementalGroups and where the parent keeps them when the template omits them. Also rebased onto current master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

supplementalGroups dropped from pod when raw YAML uses Override merge strategy

2 participants