diff --git a/internal/controllers/nmc_reconciler.go b/internal/controllers/nmc_reconciler.go index b25ac955..33d9f170 100644 --- a/internal/controllers/nmc_reconciler.go +++ b/internal/controllers/nmc_reconciler.go @@ -538,16 +538,9 @@ func (h *nmcReconcilerHelperImpl) SyncStatus(ctx context.Context, nmcObj *kmmv1b continue } - if irsName, err := getImageRepoSecretName(&p); err != nil { - logger.Info( - utils.WarnString("Error while looking for the imageRepoSecret volume"), - "error", - err, - ) - } else if irsName != "" { - status.ImageRepoSecret = &v1.LocalObjectReference{Name: irsName} + if p.Spec.ImagePullSecrets != nil { + status.ImageRepoSecret = &p.Spec.ImagePullSecrets[0] } - status.ServiceAccountName = p.Spec.ServiceAccountName podLTT := GetContainerStatus(p.Status.ContainerStatuses, workerContainerName). @@ -729,9 +722,8 @@ const ( configFileName = "config.yaml" configFullPath = volMountPointConfig + "/" + configFileName - volNameConfig = "config" - volNameImageRepoSecret = "image-repo-secret" - volMountPointConfig = "/etc/kmm-worker" + volNameConfig = "config" + volMountPointConfig = "/etc/kmm-worker" ) //go:generate mockgen -source=nmc_reconciler.go -package=controllers -destination=mock_nmc_reconciler.go podManager @@ -1235,22 +1227,6 @@ func setHashAnnotation(pod *v1.Pod) error { return nil } -func getImageRepoSecretName(pod *v1.Pod) (string, error) { - for _, v := range pod.Spec.Volumes { - if v.Name == volNameImageRepoSecret { - svs := v.VolumeSource.Secret - - if svs == nil { - return "", fmt.Errorf("volume %s is not of type secret", volNameImageRepoSecret) - } - - return svs.SecretName, nil - } - } - - return "", nil -} - func getModulesOrderAnnotationValue(modulesNames []string) string { var softDepData strings.Builder for i := 0; i < len(modulesNames)-1; i++ { diff --git a/internal/controllers/nmc_reconciler_test.go b/internal/controllers/nmc_reconciler_test.go index 95450864..f32dcfde 100644 --- a/internal/controllers/nmc_reconciler_test.go +++ b/internal/controllers/nmc_reconciler_test.go @@ -1047,14 +1047,7 @@ var _ = Describe("nmcReconcilerHelperImpl_SyncStatus", func() { }, Spec: v1.PodSpec{ ServiceAccountName: serviceAccountName, - Volumes: []v1.Volume{ - { - Name: volNameImageRepoSecret, - VolumeSource: v1.VolumeSource{ - Secret: &v1.SecretVolumeSource{SecretName: irsName}, - }, - }, - }, + ImagePullSecrets: []v1.LocalObjectReference{v1.LocalObjectReference{Name: irsName}}, }, Status: v1.PodStatus{ Phase: v1.PodSucceeded,