Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cherrypick] OCP 4.14 : Fix Mount volume to autopilot pod only if secret is created #1416

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion drivers/storage/portworx/component/autopilot.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@
) ([]v1.Volume, []v1.VolumeMount) {
volumeSpecs := make([]corev1.VolumeSpec, 0)

if c.isOCPUserWorkloadSupported() && !c.isVolumeMounted {
if c.isOCPUserWorkloadSupported() && !c.isVolumeMounted && c.isAutopilotSecretCreated(cluster.Namespace) {
c.isVolumeMounted = true
autopilotDeploymentVolumes = append(autopilotDeploymentVolumes, openshiftDeploymentVolume...)
}
Expand All @@ -712,6 +712,30 @@
return volumes, volumeMounts
}

func (c *autopilot) isAutopilotSecretCreated(namespace string) bool {
secret := &v1.Secret{}

err := c.k8sClient.Get(
context.TODO(),
types.NamespacedName{
Name: AutopilotSecretName,
Namespace: namespace,
},
secret,
)

if err == nil && secret.Name == AutopilotSecretName {
return true
}

if err != nil && errors.IsNotFound(err) {
return false

Check warning on line 732 in drivers/storage/portworx/component/autopilot.go

View check run for this annotation

Codecov / codecov/patch

drivers/storage/portworx/component/autopilot.go#L731-L732

Added lines #L731 - L732 were not covered by tests
}

logrus.Errorf("error while fetching secret %s ", err)
return false

Check warning on line 736 in drivers/storage/portworx/component/autopilot.go

View check run for this annotation

Codecov / codecov/patch

drivers/storage/portworx/component/autopilot.go#L735-L736

Added lines #L735 - L736 were not covered by tests
}

func (c *autopilot) getPrometheusTokenAndCert() (encodedToken, caCert string, err error) {
secrets := &v1.SecretList{}
err = c.k8sClient.List(
Expand Down
Loading