Skip to content

Commit

Permalink
Copy "envFrom" from Velero node-agent when creating data mover pods
Browse files Browse the repository at this point in the history
Signed-off-by: Evan Hanson <[email protected]>
  • Loading branch information
a-really-great-username committed Oct 31, 2024
1 parent 70d8890 commit f981dd4
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/exposer/csi_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ func (e *csiSnapshotExposer) createBackupPod(
VolumeMounts: volumeMounts,
VolumeDevices: volumeDevices,
Env: podInfo.env,
EnvFrom: podInfo.envFrom,
Resources: resources,
},
},
Expand Down
1 change: 1 addition & 0 deletions pkg/exposer/generic_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ func (e *genericRestoreExposer) createRestorePod(ctx context.Context, ownerObjec
VolumeMounts: volumeMounts,
VolumeDevices: volumeDevices,
Env: podInfo.env,
EnvFrom: podInfo.envFrom,
Resources: resources,
},
},
Expand Down
2 changes: 2 additions & 0 deletions pkg/exposer/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type inheritedPodInfo struct {
image string
serviceAccount string
env []v1.EnvVar
envFrom []v1.EnvFromSource
volumeMounts []v1.VolumeMount
volumes []v1.Volume
logLevelArgs []string
Expand All @@ -53,6 +54,7 @@ func getInheritedPodInfo(ctx context.Context, client kubernetes.Interface, veler
podInfo.serviceAccount = podSpec.ServiceAccountName

podInfo.env = podSpec.Containers[0].Env
podInfo.envFrom = podSpec.Containers[0].EnvFrom
podInfo.volumeMounts = podSpec.Containers[0].VolumeMounts
podInfo.volumes = podSpec.Volumes

Expand Down
64 changes: 64 additions & 0 deletions pkg/exposer/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ func TestGetInheritedPodInfo(t *testing.T) {
Value: "value-2",
},
},
EnvFrom: []v1.EnvFromSource{
{
ConfigMapRef: &v1.ConfigMapEnvSource{
LocalObjectReference: v1.LocalObjectReference{
Name: "test-configmap",
},
},
},
{
SecretRef: &v1.SecretEnvSource{
LocalObjectReference: v1.LocalObjectReference{
Name: "test-secret",
},
},
},
},
VolumeMounts: []v1.VolumeMount{
{
Name: "volume-1",
Expand Down Expand Up @@ -116,6 +132,22 @@ func TestGetInheritedPodInfo(t *testing.T) {
Value: "value-2",
},
},
EnvFrom: []v1.EnvFromSource{
{
ConfigMapRef: &v1.ConfigMapEnvSource{
LocalObjectReference: v1.LocalObjectReference{
Name: "test-configmap",
},
},
},
{
SecretRef: &v1.SecretEnvSource{
LocalObjectReference: v1.LocalObjectReference{
Name: "test-secret",
},
},
},
},
VolumeMounts: []v1.VolumeMount{
{
Name: "volume-1",
Expand Down Expand Up @@ -191,6 +223,22 @@ func TestGetInheritedPodInfo(t *testing.T) {
Value: "value-2",
},
},
envFrom: []v1.EnvFromSource{
{
ConfigMapRef: &v1.ConfigMapEnvSource{
LocalObjectReference: v1.LocalObjectReference{
Name: "test-configmap",
},
},
},
{
SecretRef: &v1.SecretEnvSource{
LocalObjectReference: v1.LocalObjectReference{
Name: "test-secret",
},
},
},
},
volumeMounts: []v1.VolumeMount{
{
Name: "volume-1",
Expand Down Expand Up @@ -228,6 +276,22 @@ func TestGetInheritedPodInfo(t *testing.T) {
Value: "value-2",
},
},
envFrom: []v1.EnvFromSource{
{
ConfigMapRef: &v1.ConfigMapEnvSource{
LocalObjectReference: v1.LocalObjectReference{
Name: "test-configmap",
},
},
},
{
SecretRef: &v1.SecretEnvSource{
LocalObjectReference: v1.LocalObjectReference{
Name: "test-secret",
},
},
},
},
volumeMounts: []v1.VolumeMount{
{
Name: "volume-1",
Expand Down

0 comments on commit f981dd4

Please sign in to comment.