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

fix: don't set empty image pull secrets #936

Merged

Conversation

oliver-rew
Copy link

@oliver-rew oliver-rew commented Jan 24, 2022

Summary Of Changes

commit "5f98b43" added the ability to set image pull secrets from the
DEFAULT_IMAGE_PULL_SECRETS env var.
5f98b43

In the case where the DEFAULT_IMAGE_PULL_SECRETS env var is unset, DefaultImagePullSecrets will be "", and strings.Split(r.DefaultImagePullSecrets, ",") will return an array of length one containing an empty string and an image pull secret will be created with an empty string. This commit adds check to the output of strings.Split() to ensure we don't set an empty strings.

When this empty string is saved and parsed by k8s, resulting operations get this error:

$ kubectl rollout restart statefulset/rabbitmq-cluster-server
error: statefulsets.apps "rabbitmq-cluster-server" map: map[] does not contain declared merge key: name

you can also see the problem here:

$ kubectl get statefulset/rabbitmq-cluster-server -o json | grep -i imagepullsecret -A2
                "imagePullSecrets": [
                    {}
                ],

Additional Context

Local Testing

Please ensure you run the unit, integration and system tests before approving the PR.

To run the unit and integration tests:

$ make unit-tests integration-tests

You will need to target a k8s cluster and have the operator deployed for running the system tests.

For example, for a Kubernetes context named dev-bunny:

$ kubectx dev-bunny
$ make destroy deploy-dev
# wait for operator to be deployed
$ make system-tests

commit "5f98b43" added the ability to set image pull secrets from the
DEFAULT_IMAGE_PULL_SECRETS env var, when they are not otherwise set.
However, this introduced a regression, when neither were set, where
an empty image pull secret would be saved. This fix adds a check to
ensure any saved image pull secrets are not empty.
@Zerpet Zerpet self-requested a review January 26, 2022 16:25
Copy link
Collaborator

@Zerpet Zerpet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! The error in the system tests looks like a flake caused by GitHub Actions.

Copy link
Contributor

@coro coro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@Zerpet Zerpet merged commit 657dbbb into rabbitmq:main Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants