mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-10-01 04:05:38 +00:00
Add imagePullSecrets inheritage for VGDP pod and maintenance job. (#9096)
Run the E2E test on kind / build (push) Failing after 8m21s
Run the E2E test on kind / setup-test-matrix (push) Successful in 4s
Run the E2E test on kind / run-e2e-test (push) Has been skipped
Main CI / Build (push) Failing after 42s
Close stale issues and PRs / stale (push) Successful in 21s
Trivy Nightly Scan / Trivy nightly scan (velero, main) (push) Failing after 1m49s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-aws, main) (push) Failing after 1m17s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-gcp, main) (push) Failing after 3m30s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-microsoft-azure, main) (push) Failing after 3m12s
Run the E2E test on kind / build (push) Failing after 8m21s
Run the E2E test on kind / setup-test-matrix (push) Successful in 4s
Run the E2E test on kind / run-e2e-test (push) Has been skipped
Main CI / Build (push) Failing after 42s
Close stale issues and PRs / stale (push) Successful in 21s
Trivy Nightly Scan / Trivy nightly scan (velero, main) (push) Failing after 1m49s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-aws, main) (push) Failing after 1m17s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-gcp, main) (push) Failing after 3m30s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-microsoft-azure, main) (push) Failing after 3m12s
Signed-off-by: Xun Jiang <xun.jiang@broadcom.com>
This commit is contained in:
@@ -407,8 +407,16 @@ func StartNewJob(cli client.Client, ctx context.Context, repo *velerov1api.Backu
|
||||
return maintenanceJob.Name, nil
|
||||
}
|
||||
|
||||
func buildJob(cli client.Client, ctx context.Context, repo *velerov1api.BackupRepository, bslName string, config *JobConfigs,
|
||||
podResources kube.PodResources, logLevel logrus.Level, logFormat *logging.FormatFlag) (*batchv1api.Job, error) {
|
||||
func buildJob(
|
||||
cli client.Client,
|
||||
ctx context.Context,
|
||||
repo *velerov1api.BackupRepository,
|
||||
bslName string,
|
||||
config *JobConfigs,
|
||||
podResources kube.PodResources,
|
||||
logLevel logrus.Level,
|
||||
logFormat *logging.FormatFlag,
|
||||
) (*batchv1api.Job, error) {
|
||||
// Get the Velero server deployment
|
||||
deployment := &appsv1api.Deployment{}
|
||||
err := cli.Get(ctx, types.NamespacedName{Name: "velero", Namespace: repo.Namespace}, deployment)
|
||||
@@ -437,6 +445,8 @@ func buildJob(cli client.Client, ctx context.Context, repo *velerov1api.BackupRe
|
||||
// Get the pod security context from the Velero server deployment
|
||||
podSecurityContext := veleroutil.GetPodSecurityContextsFromVeleroServer(deployment)
|
||||
|
||||
imagePullSecrets := veleroutil.GetImagePullSecretsFromVeleroServer(deployment)
|
||||
|
||||
// Get image
|
||||
image := veleroutil.GetVeleroServerImage(deployment)
|
||||
|
||||
@@ -528,6 +538,7 @@ func buildJob(cli client.Client, ctx context.Context, repo *velerov1api.BackupRe
|
||||
Value: "windows",
|
||||
},
|
||||
},
|
||||
ImagePullSecrets: imagePullSecrets,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -910,6 +910,11 @@ func TestBuildJob(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
ImagePullSecrets: []corev1api.LocalObjectReference{
|
||||
{
|
||||
Name: "imagePullSecret1",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -934,6 +939,7 @@ func TestBuildJob(t *testing.T) {
|
||||
expectedPodLabel map[string]string
|
||||
expectedSecurityContext *corev1api.SecurityContext
|
||||
expectedPodSecurityContext *corev1api.PodSecurityContext
|
||||
expectedImagePullSecrets []corev1api.LocalObjectReference
|
||||
}{
|
||||
{
|
||||
name: "Valid maintenance job without third party labels",
|
||||
@@ -981,6 +987,11 @@ func TestBuildJob(t *testing.T) {
|
||||
expectedPodSecurityContext: &corev1api.PodSecurityContext{
|
||||
RunAsNonRoot: boolptr.True(),
|
||||
},
|
||||
expectedImagePullSecrets: []corev1api.LocalObjectReference{
|
||||
{
|
||||
Name: "imagePullSecret1",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Valid maintenance job with third party labels",
|
||||
@@ -1025,6 +1036,11 @@ func TestBuildJob(t *testing.T) {
|
||||
},
|
||||
expectedSecurityContext: nil,
|
||||
expectedPodSecurityContext: nil,
|
||||
expectedImagePullSecrets: []corev1api.LocalObjectReference{
|
||||
{
|
||||
Name: "imagePullSecret1",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Error getting Velero server deployment",
|
||||
@@ -1076,7 +1092,16 @@ func TestBuildJob(t *testing.T) {
|
||||
cli := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(objs...).Build()
|
||||
|
||||
// Call the function to test
|
||||
job, err := buildJob(cli, t.Context(), param.BackupRepo, param.BackupLocation.Name, tc.m, *tc.m.PodResources, tc.logLevel, tc.logFormat)
|
||||
job, err := buildJob(
|
||||
cli,
|
||||
t.Context(),
|
||||
param.BackupRepo,
|
||||
param.BackupLocation.Name,
|
||||
tc.m,
|
||||
*tc.m.PodResources,
|
||||
tc.logLevel,
|
||||
tc.logFormat,
|
||||
)
|
||||
|
||||
// Check the error
|
||||
if tc.expectedError {
|
||||
@@ -1131,6 +1156,8 @@ func TestBuildJob(t *testing.T) {
|
||||
assert.Equal(t, expectedArgs, container.Args)
|
||||
|
||||
assert.Equal(t, tc.expectedPodLabel, job.Spec.Template.Labels)
|
||||
|
||||
assert.Equal(t, tc.expectedImagePullSecrets, job.Spec.Template.Spec.ImagePullSecrets)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user