openshift / oadp-operator

OADP Operator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BUG get image logic

mateusoliveira43 opened this issue · comments

Description

OADP code is changed when sent to production, for example

- name: RELATED_IMAGE_VELERO
value: quay.io/konveyor/velero:latest
- name: RELATED_IMAGE_VELERO_RESTORE_HELPER
value: quay.io/konveyor/velero-restore-helper:latest
- name: RELATED_IMAGE_OPENSHIFT_VELERO_PLUGIN
value: quay.io/konveyor/openshift-velero-plugin:latest
- name: RELATED_IMAGE_VELERO_PLUGIN_FOR_AWS
value: quay.io/konveyor/velero-plugin-for-aws:latest
- name: RELATED_IMAGE_VELERO_PLUGIN_FOR_MICROSOFT_AZURE
value: quay.io/konveyor/velero-plugin-for-microsoft-azure:latest
- name: RELATED_IMAGE_VELERO_PLUGIN_FOR_GCP
value: quay.io/konveyor/velero-plugin-for-gcp:latest
- name: RELATED_IMAGE_VELERO_PLUGIN_FOR_CSI
value: quay.io/konveyor/velero-plugin-for-csi:latest
- name: RELATED_IMAGE_KUBEVIRT_VELERO_PLUGIN
value: quay.io/konveyor/kubevirt-velero-plugin:v0.2.0
- name: RELATED_IMAGE_MUSTGATHER
value: registry.redhat.io/oadp/oadp-mustgather-rhel8:v1.2

values are changed to production images.

But, these values are not changed

const (
VeleroImage = "quay.io/konveyor/velero:latest"
OpenshiftPluginImage = "quay.io/konveyor/openshift-velero-plugin:latest"
AWSPluginImage = "quay.io/konveyor/velero-plugin-for-aws:latest"
AzurePluginImage = "quay.io/konveyor/velero-plugin-for-microsoft-azure:latest"
GCPPluginImage = "quay.io/konveyor/velero-plugin-for-gcp:latest"
CSIPluginImage = "quay.io/konveyor/velero-plugin-for-csi:latest"
RegistryImage = "quay.io/konveyor/registry:latest"
KubeVirtPluginImage = "quay.io/konveyor/kubevirt-velero-plugin:v0.2.0"
)

Which means, in a production environment, all fallback from below functions, are wrong.

func getVeleroImage(dpa *oadpv1alpha1.DataProtectionApplication) string {
if dpa.Spec.UnsupportedOverrides[oadpv1alpha1.VeleroImageKey] != "" {
return dpa.Spec.UnsupportedOverrides[oadpv1alpha1.VeleroImageKey]
}
if os.Getenv("RELATED_IMAGE_VELERO") == "" {
return common.VeleroImage
}
return os.Getenv("RELATED_IMAGE_VELERO")
}

func getAWSPluginImage(dpa *oadpv1alpha1.DataProtectionApplication) string {
if dpa.Spec.UnsupportedOverrides[oadpv1alpha1.AWSPluginImageKey] != "" {
return dpa.Spec.UnsupportedOverrides[oadpv1alpha1.AWSPluginImageKey]
}
if os.Getenv("RELATED_IMAGE_VELERO_PLUGIN_FOR_AWS") == "" {
return common.AWSPluginImage
}
return os.Getenv("RELATED_IMAGE_VELERO_PLUGIN_FOR_AWS")
}
func getCSIPluginImage(dpa *oadpv1alpha1.DataProtectionApplication) string {
if dpa.Spec.UnsupportedOverrides[oadpv1alpha1.CSIPluginImageKey] != "" {
return dpa.Spec.UnsupportedOverrides[oadpv1alpha1.CSIPluginImageKey]
}
if os.Getenv("RELATED_IMAGE_VELERO_PLUGIN_FOR_CSI") == "" {
return common.CSIPluginImage
}
return os.Getenv("RELATED_IMAGE_VELERO_PLUGIN_FOR_CSI")
}
func getGCPPluginImage(dpa *oadpv1alpha1.DataProtectionApplication) string {
if dpa.Spec.UnsupportedOverrides[oadpv1alpha1.GCPPluginImageKey] != "" {
return dpa.Spec.UnsupportedOverrides[oadpv1alpha1.GCPPluginImageKey]
}
if os.Getenv("RELATED_IMAGE_VELERO_PLUGIN_FOR_GCP") == "" {
return common.GCPPluginImage
}
return os.Getenv("RELATED_IMAGE_VELERO_PLUGIN_FOR_GCP")
}
func getOpenshiftPluginImage(dpa *oadpv1alpha1.DataProtectionApplication) string {
if dpa.Spec.UnsupportedOverrides[oadpv1alpha1.OpenShiftPluginImageKey] != "" {
return dpa.Spec.UnsupportedOverrides[oadpv1alpha1.OpenShiftPluginImageKey]
}
if os.Getenv("RELATED_IMAGE_OPENSHIFT_VELERO_PLUGIN") == "" {
return common.OpenshiftPluginImage
}
return os.Getenv("RELATED_IMAGE_OPENSHIFT_VELERO_PLUGIN")
}
func getAzurePluginImage(dpa *oadpv1alpha1.DataProtectionApplication) string {
if dpa.Spec.UnsupportedOverrides[oadpv1alpha1.AzurePluginImageKey] != "" {
return dpa.Spec.UnsupportedOverrides[oadpv1alpha1.AzurePluginImageKey]
}
if os.Getenv("RELATED_IMAGE_VELERO_PLUGIN_FOR_MICROSOFT_AZURE") == "" {
return common.AzurePluginImage
}
return os.Getenv("RELATED_IMAGE_VELERO_PLUGIN_FOR_MICROSOFT_AZURE")
}
func getKubeVirtPluginImage(dpa *oadpv1alpha1.DataProtectionApplication) string {
if dpa.Spec.UnsupportedOverrides[oadpv1alpha1.KubeVirtPluginImageKey] != "" {
return dpa.Spec.UnsupportedOverrides[oadpv1alpha1.KubeVirtPluginImageKey]
}
if os.Getenv("RELATED_IMAGE_KUBEVIRT_VELERO_PLUGIN") == "" {
return common.KubeVirtPluginImage
}
return os.Getenv("RELATED_IMAGE_KUBEVIRT_VELERO_PLUGIN")
}

How to reproduce

Install OADP operator from marketplace and change the value of one these environment variables to an empty string (or remove the environment variable). Create DPA that will use one of these images, without using unsupportedOverrides. OADP will try to use a non production image instead of a production one.

Related work for DPA when API version updates

Instead of having unsupportedOverrides field in DPA, could not we use these environment variables to change images used? Instead of a field in DPA, would need to change value in operator CSV.

change the value of one these environment variables to an empty string

well that's not really a supported configuration. but I could see how it can be interpreted as a bug.

@kaovilai is it dangerous somehow to edit that?

Not dangerous but not sure why one would make a change there and set it to empty.

The empty was just to show that there is no need for the fallback value

What I would really like is to remove unsupportedOverrides (in new version of DPA) and change these environment variables instead. It should be as easy as it is to set a value in DPA.

sounds good.

unsupporetedOverrides would remain for non images

Yeah, need to see if there is a easy way to change this as well

const OperatorTypeKey UnsupportedImageKey = "operator-type"

Let's not change that, it's for MTC.

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

/lifecycle frozen