Skip to content
This repository was archived by the owner on Dec 18, 2019. It is now read-only.

feat(reconcile): added a flag to skip validation of the namespace#72

Merged
craicoverflow merged 2 commits intoaerogear:masterfrom
craicoverflow:AG-9170
May 10, 2019
Merged

feat(reconcile): added a flag to skip validation of the namespace#72
craicoverflow merged 2 commits intoaerogear:masterfrom
craicoverflow:AG-9170

Conversation

@craicoverflow
Copy link
Copy Markdown

@craicoverflow craicoverflow commented May 10, 2019

Motivation

https://issues.jboss.org/browse/AEROGEAR-9170

What

Added an option to skip checking if the operator namespace is valid during the Reconcile loop.

Why

The Reconcile function recently to check if the namespace provided in a CR is valid.

To do this, the Operator SDK reads the file at /var/run/secrets/kubernetes.io/serviceaccount/namespace to see if the CR namespace matches the one at this location.

This is fine when the operator is live, but /var/run/secrets/kubernetes.io/serviceaccount/namespace would not exist locally where unit tests are running in isolation, so this check will always fail.

This flag can be passed in a CR to skip this validation. It is a workaround and will be removed in the future when the Operator SDK is updated. See operator-framework/operator-sdk#1388

How

Added a new property to each CR spec, and if this is set to true then the namespace validation is skipped.

Verification Steps

Add the steps required to check this change. Following an example.

  1. Go to file deploy/crds/mobile-security-service_v1alpha1_mobilesecurityservice_cr.yaml.
  2. Add a new property to spec:
spec:
  skipNamespaceValidation: true
  1. Go to pkg/controller/mobilesecurityservice/controller.go.
  2. Add a breakpoint to line 156.
  3. Go to pkg/controller/mobilesecurityservice/controller_test.go.
  4. Debug the test TestReconcileMobileSecurityService_Reconcile.
  5. The breakpoint in pkg/controller/mobilesecurityservice/controller.go should not be hit when skipNamespaceValidation is true.
  6. Repeat 1-7 for the two other controllers.

Checklist:

  • Code has been tested locally by PR requester
  • Changes have been successfully verified by another team member

Progress

  • Finished task
  • TODO

@damienomurchu
Copy link
Copy Markdown
Contributor

Changes look good 👍 I haven't verified them though.

Copy link
Copy Markdown
Member

@davidffrench davidffrench left a comment

Choose a reason for hiding this comment

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

Changes look good to me as well. Could you split the code specific to the bypass in a separate commit, this will make it easier to revert later on using just git.

@craicoverflow craicoverflow force-pushed the AG-9170 branch 2 times, most recently from 7b103f4 to a234f6e Compare May 10, 2019 14:28
@@ -0,0 +1,118 @@
package mobilesecurityservice
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we merge the test here? I am fine with that since we are in the initial dev phase. Just to be sure.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I plan to remove this before merge as it is incomplete. It is just to allow you to verify this PR more easily.

@craicoverflow
Copy link
Copy Markdown
Author

craicoverflow commented May 10, 2019

Changes look good to me as well. Could you split the code specific to the bypass in a separate commit, this will make it easier to revert later on using just git.

Changes look good to me as well. Could you split the code specific to the bypass in a separate commit, this will make it easier to revert later on using just git.

@davidffrench My editor automatically corrects formatting on save so I didn't really notice! Fixed now.

Copy link
Copy Markdown
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

The code changes show fine for me. I'd just suggest for all places where you are passing the bool you add a comment with //FIXME: + small explanation over why it is used.

It also passed in the CI.
#!/bin/bash -eo pipefail
make test

Running tests:
ok  	github.com/aerogear/mobile-security-service-operator/pkg/controller/mobilesecurityservice	0.040s	coverage: 36.8% of statements

Great job 🥇

@craicoverflow craicoverflow force-pushed the AG-9170 branch 2 times, most recently from 4139fca to ef948ae Compare May 10, 2019 15:01
@craicoverflow craicoverflow merged commit 9a3a3ae into aerogear:master May 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants