From f3161382653bd788230f295b339fd82fa67808b7 Mon Sep 17 00:00:00 2001 From: Nikita Bhatia Date: Mon, 5 Feb 2024 14:12:24 +0530 Subject: [PATCH] Update plugin deployment imagePolicy to Always regardless of STC's imagePullPolicy --- drivers/storage/portworx/component/plugin.go | 14 ++++++++------ drivers/storage/portworx/components_test.go | 7 +++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/storage/portworx/component/plugin.go b/drivers/storage/portworx/component/plugin.go index a9f8a8b3f..fd070de78 100644 --- a/drivers/storage/portworx/component/plugin.go +++ b/drivers/storage/portworx/component/plugin.go @@ -230,12 +230,6 @@ func (p *plugin) createDeployment(filename, deploymentName string, ownerRef *met } deployment.Namespace = cluster.Namespace deployment.OwnerReferences = []metav1.OwnerReference{*ownerRef} - if deployment.Name == PluginDeploymentName { - deployment.Spec.Template.Spec.Containers[0].Image = getDesiredPluginImage(cluster) - } - if deployment.Name == NginxDeploymentName { - deployment.Spec.Template.Spec.Containers[0].Image = getDesiredPluginProxyImage(cluster) - } deployment.Spec.Template.ObjectMeta = k8s.AddManagedByOperatorLabel(deployment.Spec.Template.ObjectMeta) existingDeployment := &appsv1.Deployment{} @@ -253,6 +247,14 @@ func (p *plugin) createDeployment(filename, deploymentName string, ownerRef *met pxutil.ApplyStorageClusterSettingsToPodSpec(cluster, &deployment.Spec.Template.Spec) + if deployment.Name == PluginDeploymentName { + deployment.Spec.Template.Spec.Containers[0].Image = getDesiredPluginImage(cluster) + deployment.Spec.Template.Spec.Containers[0].ImagePullPolicy = v1.PullAlways + } + if deployment.Name == NginxDeploymentName { + deployment.Spec.Template.Spec.Containers[0].Image = getDesiredPluginProxyImage(cluster) + } + equal, _ := util.DeepEqualPodTemplate(&deployment.Spec.Template, &existingDeployment.Spec.Template) if (!p.isPluginDeploymentCreated && deployment.Name == PluginDeploymentName) || diff --git a/drivers/storage/portworx/components_test.go b/drivers/storage/portworx/components_test.go index 1d869d714..a8a9223e7 100644 --- a/drivers/storage/portworx/components_test.go +++ b/drivers/storage/portworx/components_test.go @@ -15887,6 +15887,10 @@ func TestPluginInstallAndUninstall(t *testing.T) { Name: "px-cluster", Namespace: "kube-test", }, + Spec: corev1.StorageClusterSpec{ + Image: "portworx/image:2.2", + ImagePullPolicy: v1.PullIfNotPresent, + }, } err = driver.PreInstall(cluster) @@ -15935,11 +15939,14 @@ func TestPluginInstallAndUninstall(t *testing.T) { // test creation of plugin-deployment expectedPluginDeployment := testutil.GetExpectedDeployment(t, "plugin-deployment.yaml") pxutil.ApplyStorageClusterSettingsToPodSpec(cluster, &expectedPluginDeployment.Spec.Template.Spec) + expectedPluginDeployment.Spec.Template.Spec.Containers[0].ImagePullPolicy = v1.PullAlways + actualPluginDeployment := &appsv1.Deployment{} err = testutil.Get(k8sClient, actualPluginDeployment, component.PluginDeploymentName, "kube-test") require.NoError(t, err) require.Equal(t, expectedPluginDeployment.Name, actualPluginDeployment.Name) require.Equal(t, expectedPluginDeployment.Spec, actualPluginDeployment.Spec) + require.Equal(t, expectedPluginDeployment.Spec.Template.Spec.Containers[0].ImagePullPolicy, actualPluginDeployment.Spec.Template.Spec.Containers[0].ImagePullPolicy) pluginComponent, _ := component.Get(component.PluginComponentName) err = pluginComponent.Delete(cluster)