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

Allow DNS pod selectors to be configured #987

Merged

Conversation

zubron
Copy link
Contributor

@zubron zubron commented Nov 8, 2019

What this PR does / why we need it:
The preflight checks for Sonobuoy assume the namespace and labels of the
DNS pods. Although the preflight checks can be skipped, some users may
want to still run these checks and ensure that they pass before testing.
To allow this, this change introduces two new flags that are applied to
the PreflightConfig so that the namespace and labels to use for
finding the DNS pods can be configured.

The two new flags are: --dns-namespace and --dns-pod-labels.
The default values are the values that were previously being used so
this does not impact existing users.

Signed-off-by: Bridget McErlean [email protected]

Which issue(s) this PR fixes

Special notes for your reviewer:
I've verified that this change works with an OpenShift 4.x cluster by creating one locally using CRC.

Release note:

The namespace and label selectors used by Sonobuoy to find the DNS pods during the preflight checks can now be customised using the flags `--dns-namespace` and `--dns-pod-labels`.

@zubron zubron requested a review from johnSchnake November 8, 2019 16:54
func AddDNSPodLabelsFlag(str *[]string, flags *pflag.FlagSet) {
flags.StringArrayVar(
str, "dns-pod-labels", config.DefaultDNSPodLabels,
"The label selectors to use for locating DNS pods during preflight checks.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we clarify in the help how to specify multiple ones? Its a comma-delimited list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh, I'm so glad you asked me about this. It encouraged me to do a bit more testing locally and realised I was using the wrong pflag function and that it didn't do what I thought it did!

"github.com/vmware-tanzu/sonobuoy/pkg/client"
"github.com/vmware-tanzu/sonobuoy/pkg/config"
"github.com/vmware-tanzu/sonobuoy/pkg/errlog"
imagepkg "github.com/vmware-tanzu/sonobuoy/pkg/image"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it was already a problem before this PR but yours is touching it now; ideally the vmware-tanzu/sonobuoy imports would be in their own block (2nd block) and the external ones like cobra/pflag would be in a 3rd block (with stdlib being the first block)

"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/vmware-tanzu/sonobuoy/pkg/buildinfo"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: same comment about fixing these blocks

Copy link
Contributor

@johnSchnake johnSchnake left a comment

Choose a reason for hiding this comment

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

LGTM but a few nits if you want to fix them.

The preflight checks for Sonobuoy assume the namespace and labels of the
DNS pods. Although the preflight checks can be skipped, some users may
want to still run these checks and ensure that they pass before testing.
To allow this, this change introduces two new flags that are applied to
the `PreflightConfig` so that the namespace and labels to use for
finding the DNS pods can be configured.

The two new flags are: `--dns-namespace` and `--dns-pod-labels`.
The default values are the values that were previously being used so
this does not impact existing users.

Signed-off-by: Bridget McErlean <[email protected]>
@zubron zubron force-pushed the allow-custom-dns-namespace-labels-975 branch from fd52819 to a8d39f1 Compare November 11, 2019 20:12
@codecov-io
Copy link

Codecov Report

Merging #987 into master will decrease coverage by 0.06%.
The diff coverage is 55.17%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #987      +/-   ##
==========================================
- Coverage   47.69%   47.62%   -0.07%     
==========================================
  Files          76       76              
  Lines        5298     5314      +16     
==========================================
+ Hits         2527     2531       +4     
- Misses       2617     2627      +10     
- Partials      154      156       +2
Impacted Files Coverage Δ
pkg/client/interfaces.go 80.95% <ø> (ø) ⬆️
pkg/config/config.go 61.29% <ø> (ø) ⬆️
cmd/sonobuoy/app/run.go 36.53% <0%> (-3.05%) ⬇️
cmd/sonobuoy/app/e2e.go 20.58% <0%> (-0.63%) ⬇️
cmd/sonobuoy/app/gen.go 74.1% <100%> (+0.37%) ⬆️
cmd/sonobuoy/app/args.go 90.28% <100%> (+0.58%) ⬆️
pkg/client/preflight.go 54.54% <57.14%> (-2.81%) ⬇️
pkg/plugin/aggregation/aggregator.go 72.67% <0%> (-3.11%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bda80c2...a8d39f1. Read the comment docs.

@zubron zubron merged commit 31b5728 into vmware-tanzu:master Nov 11, 2019
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.

Sonobuoy not working with Openshift 4.x
3 participants