Skip to content

Commit e506144

Browse files
Merge pull request #676 from openshift-bot/synchronize-upstream
OCPBUGS-76380: Synchronize From Upstream Repositories
2 parents 70b40c4 + de842db commit e506144

6 files changed

Lines changed: 236 additions & 12 deletions

File tree

commitchecker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
expectedMergeBase: a307a6daf5c5b1bd78c75e0ed02aeaf5c7f9d94d
1+
expectedMergeBase: c16a97bc1853e36955b4e1825b8e8ecea565f69a
22
upstreamBranch: main
33
upstreamOrg: operator-framework
44
upstreamRepo: operator-controller

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ require (
3131
github.com/stretchr/testify v1.11.1
3232
go.podman.io/image/v5 v5.39.1
3333
golang.org/x/exp v0.0.0-20260209203927-2842357ff358
34-
golang.org/x/mod v0.33.0
34+
golang.org/x/mod v0.34.0
3535
golang.org/x/sync v0.20.0
3636
golang.org/x/tools v0.42.0
3737
helm.sh/helm/v3 v3.20.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,8 @@ golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
610610
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
611611
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
612612
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
613-
golang.org/x/mod v0.33.0 h1:tHFzIWbBifEmbwtGz65eaWyGiGZatSrT9prnU8DbVL8=
614-
golang.org/x/mod v0.33.0/go.mod h1:swjeQEj+6r7fODbD2cqrnje9PnziFuw4bmLbBZFrQ5w=
613+
golang.org/x/mod v0.34.0 h1:xIHgNUUnW6sYkcM5Jleh05DvLOtwc6RitGHbDk4akRI=
614+
golang.org/x/mod v0.34.0/go.mod h1:ykgH52iCZe79kzLLMhyCUzhMci+nQj+0XkbXpNYtVjY=
615615
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
616616
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
617617
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=

internal/operator-controller/rukpak/render/registryv1/generators/generators.go

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -671,19 +671,32 @@ func applyEnvironmentFromConfig(deployment *appsv1.Deployment, config *config.De
671671
}
672672
}
673673

674-
// applyVolumeConfig appends volumes to the deployment's pod spec.
675-
// This follows OLMv0 behavior:
674+
// applyVolumeConfig merges volumes into the deployment's pod spec.
675+
// Volumes from config override existing volumes with the same name.
676+
// This differs from OLMv0, which appends volumes without checking for duplicates:
676677
// https://github.com/operator-framework/operator-lifecycle-manager/blob/v0.39.0/pkg/controller/operators/olm/overrides/inject/inject.go#L104-L117
677678
func applyVolumeConfig(deployment *appsv1.Deployment, config *config.DeploymentConfig) {
678679
if len(config.Volumes) == 0 {
679680
return
680681
}
681682

682-
deployment.Spec.Template.Spec.Volumes = append(deployment.Spec.Template.Spec.Volumes, config.Volumes...)
683+
existingVolMap := make(map[string]int, len(deployment.Spec.Template.Spec.Volumes))
684+
for i, vol := range deployment.Spec.Template.Spec.Volumes {
685+
existingVolMap[vol.Name] = i
686+
}
687+
688+
for _, configVol := range config.Volumes {
689+
if idx, exists := existingVolMap[configVol.Name]; exists {
690+
deployment.Spec.Template.Spec.Volumes[idx] = configVol
691+
} else {
692+
deployment.Spec.Template.Spec.Volumes = append(deployment.Spec.Template.Spec.Volumes, configVol)
693+
}
694+
}
683695
}
684696

685-
// applyVolumeMountConfig appends volume mounts to all containers in the deployment.
686-
// This follows OLMv0 behavior:
697+
// applyVolumeMountConfig merges volume mounts into all containers in the deployment.
698+
// Volume mounts from config override existing volume mounts with the same name.
699+
// This differs from OLMv0, which appends volume mounts without checking for duplicates:
687700
// https://github.com/operator-framework/operator-lifecycle-manager/blob/v0.39.0/pkg/controller/operators/olm/overrides/inject/inject.go#L149-L165
688701
func applyVolumeMountConfig(deployment *appsv1.Deployment, config *config.DeploymentConfig) {
689702
if len(config.VolumeMounts) == 0 {
@@ -692,7 +705,19 @@ func applyVolumeMountConfig(deployment *appsv1.Deployment, config *config.Deploy
692705

693706
for i := range deployment.Spec.Template.Spec.Containers {
694707
container := &deployment.Spec.Template.Spec.Containers[i]
695-
container.VolumeMounts = append(container.VolumeMounts, config.VolumeMounts...)
708+
709+
existingMountMap := make(map[string]int, len(container.VolumeMounts))
710+
for idx, mount := range container.VolumeMounts {
711+
existingMountMap[mount.Name] = idx
712+
}
713+
714+
for _, configMount := range config.VolumeMounts {
715+
if idx, exists := existingMountMap[configMount.Name]; exists {
716+
container.VolumeMounts[idx] = configMount
717+
} else {
718+
container.VolumeMounts = append(container.VolumeMounts, configMount)
719+
}
720+
}
696721
}
697722
}
698723

internal/operator-controller/rukpak/render/registryv1/generators/generators_test.go

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3085,6 +3085,205 @@ func Test_BundleCSVDeploymentGenerator_WithDeploymentConfig(t *testing.T) {
30853085
require.Equal(t, "existing_value", dep.Spec.Template.Spec.Containers[0].Env[0].Value)
30863086
},
30873087
},
3088+
{
3089+
name: "merges volumes from deployment config - overrides matching names",
3090+
bundle: &bundle.RegistryV1{
3091+
CSV: clusterserviceversion.Builder().
3092+
WithStrategyDeploymentSpecs(
3093+
v1alpha1.StrategyDeploymentSpec{
3094+
Name: "test-deployment",
3095+
Spec: appsv1.DeploymentSpec{
3096+
Template: corev1.PodTemplateSpec{
3097+
Spec: corev1.PodSpec{
3098+
Containers: []corev1.Container{
3099+
{Name: "manager"},
3100+
},
3101+
Volumes: []corev1.Volume{
3102+
{
3103+
Name: "bundle-emptydir-vol",
3104+
VolumeSource: corev1.VolumeSource{
3105+
EmptyDir: &corev1.EmptyDirVolumeSource{},
3106+
},
3107+
},
3108+
{
3109+
Name: "existing-vol",
3110+
VolumeSource: corev1.VolumeSource{
3111+
EmptyDir: &corev1.EmptyDirVolumeSource{},
3112+
},
3113+
},
3114+
},
3115+
},
3116+
},
3117+
},
3118+
},
3119+
).Build(),
3120+
},
3121+
opts: render.Options{
3122+
InstallNamespace: "test-ns",
3123+
TargetNamespaces: []string{"test-ns"},
3124+
DeploymentConfig: &config.DeploymentConfig{
3125+
Volumes: []corev1.Volume{
3126+
{
3127+
Name: "bundle-emptydir-vol",
3128+
VolumeSource: corev1.VolumeSource{
3129+
ConfigMap: &corev1.ConfigMapVolumeSource{
3130+
LocalObjectReference: corev1.LocalObjectReference{
3131+
Name: "test-cm-vol",
3132+
},
3133+
},
3134+
},
3135+
},
3136+
{
3137+
Name: "config-secret-vol",
3138+
VolumeSource: corev1.VolumeSource{
3139+
Secret: &corev1.SecretVolumeSource{
3140+
SecretName: "test-secret-vol",
3141+
},
3142+
},
3143+
},
3144+
},
3145+
},
3146+
},
3147+
verify: func(t *testing.T, objs []client.Object) {
3148+
require.Len(t, objs, 1)
3149+
dep := objs[0].(*appsv1.Deployment)
3150+
volumes := dep.Spec.Template.Spec.Volumes
3151+
3152+
// Should have 3 volumes total:
3153+
// - bundle-emptydir-vol (overridden to ConfigMap)
3154+
// - existing-vol (unchanged)
3155+
// - config-secret-vol (new)
3156+
require.Len(t, volumes, 3)
3157+
3158+
// Verify bundle-emptydir-vol was overridden (now ConfigMap, not EmptyDir)
3159+
var bundleVol *corev1.Volume
3160+
for i := range volumes {
3161+
if volumes[i].Name == "bundle-emptydir-vol" {
3162+
bundleVol = &volumes[i]
3163+
break
3164+
}
3165+
}
3166+
require.NotNil(t, bundleVol, "bundle-emptydir-vol should exist")
3167+
require.NotNil(t, bundleVol.ConfigMap, "bundle-emptydir-vol should be ConfigMap")
3168+
require.Equal(t, "test-cm-vol", bundleVol.ConfigMap.Name)
3169+
require.Nil(t, bundleVol.EmptyDir, "bundle-emptydir-vol should not be EmptyDir")
3170+
3171+
// Verify existing-vol remains unchanged
3172+
var existingVol *corev1.Volume
3173+
for i := range volumes {
3174+
if volumes[i].Name == "existing-vol" {
3175+
existingVol = &volumes[i]
3176+
break
3177+
}
3178+
}
3179+
require.NotNil(t, existingVol, "existing-vol should exist")
3180+
require.NotNil(t, existingVol.EmptyDir, "existing-vol should still be EmptyDir")
3181+
3182+
// Verify config-secret-vol was added
3183+
var secretVol *corev1.Volume
3184+
for i := range volumes {
3185+
if volumes[i].Name == "config-secret-vol" {
3186+
secretVol = &volumes[i]
3187+
break
3188+
}
3189+
}
3190+
require.NotNil(t, secretVol, "config-secret-vol should exist")
3191+
require.NotNil(t, secretVol.Secret, "config-secret-vol should be Secret")
3192+
require.Equal(t, "test-secret-vol", secretVol.Secret.SecretName)
3193+
},
3194+
},
3195+
{
3196+
name: "merges volumeMounts from deployment config - overrides matching names",
3197+
bundle: &bundle.RegistryV1{
3198+
CSV: clusterserviceversion.Builder().
3199+
WithStrategyDeploymentSpecs(
3200+
v1alpha1.StrategyDeploymentSpec{
3201+
Name: "test-deployment",
3202+
Spec: appsv1.DeploymentSpec{
3203+
Template: corev1.PodTemplateSpec{
3204+
Spec: corev1.PodSpec{
3205+
Containers: []corev1.Container{
3206+
{
3207+
Name: "manager",
3208+
VolumeMounts: []corev1.VolumeMount{
3209+
{
3210+
Name: "bundle-vol",
3211+
MountPath: "/old/path",
3212+
},
3213+
{
3214+
Name: "existing-vol",
3215+
MountPath: "/existing/path",
3216+
},
3217+
},
3218+
},
3219+
},
3220+
},
3221+
},
3222+
},
3223+
},
3224+
).Build(),
3225+
},
3226+
opts: render.Options{
3227+
InstallNamespace: "test-ns",
3228+
TargetNamespaces: []string{"test-ns"},
3229+
DeploymentConfig: &config.DeploymentConfig{
3230+
VolumeMounts: []corev1.VolumeMount{
3231+
{
3232+
Name: "bundle-vol",
3233+
MountPath: "/new/path",
3234+
},
3235+
{
3236+
Name: "config-vol",
3237+
MountPath: "/config/path",
3238+
},
3239+
},
3240+
},
3241+
},
3242+
verify: func(t *testing.T, objs []client.Object) {
3243+
require.Len(t, objs, 1)
3244+
dep := objs[0].(*appsv1.Deployment)
3245+
volumeMounts := dep.Spec.Template.Spec.Containers[0].VolumeMounts
3246+
3247+
// Should have 3 volume mounts total:
3248+
// - bundle-vol (overridden to /new/path)
3249+
// - existing-vol (unchanged)
3250+
// - config-vol (new)
3251+
require.Len(t, volumeMounts, 3)
3252+
3253+
// Verify bundle-vol was overridden
3254+
var bundleMount *corev1.VolumeMount
3255+
for i := range volumeMounts {
3256+
if volumeMounts[i].Name == "bundle-vol" {
3257+
bundleMount = &volumeMounts[i]
3258+
break
3259+
}
3260+
}
3261+
require.NotNil(t, bundleMount, "bundle-vol should exist")
3262+
require.Equal(t, "/new/path", bundleMount.MountPath, "bundle-vol mount path should be overridden")
3263+
3264+
// Verify existing-vol remains unchanged
3265+
var existingMount *corev1.VolumeMount
3266+
for i := range volumeMounts {
3267+
if volumeMounts[i].Name == "existing-vol" {
3268+
existingMount = &volumeMounts[i]
3269+
break
3270+
}
3271+
}
3272+
require.NotNil(t, existingMount, "existing-vol should exist")
3273+
require.Equal(t, "/existing/path", existingMount.MountPath)
3274+
3275+
// Verify config-vol was added
3276+
var configMount *corev1.VolumeMount
3277+
for i := range volumeMounts {
3278+
if volumeMounts[i].Name == "config-vol" {
3279+
configMount = &volumeMounts[i]
3280+
break
3281+
}
3282+
}
3283+
require.NotNil(t, configMount, "config-vol should exist")
3284+
require.Equal(t, "/config/path", configMount.MountPath)
3285+
},
3286+
},
30883287
} {
30893288
t.Run(tc.name, func(t *testing.T) {
30903289
objs, err := generators.BundleCSVDeploymentGenerator(tc.bundle, tc.opts)

vendor/modules.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,8 +1008,8 @@ golang.org/x/crypto/scrypt
10081008
## explicit; go 1.24.0
10091009
golang.org/x/exp/maps
10101010
golang.org/x/exp/slices
1011-
# golang.org/x/mod v0.33.0
1012-
## explicit; go 1.24.0
1011+
# golang.org/x/mod v0.34.0
1012+
## explicit; go 1.25.0
10131013
golang.org/x/mod/internal/lazyregexp
10141014
golang.org/x/mod/modfile
10151015
golang.org/x/mod/module

0 commit comments

Comments
 (0)