Skip to content

test framework: handle double-registered --kubeconfig flag - #2731

Merged
estroz merged 1 commit into
operator-framework:masterfrom
estroz:bugfix/test-framework-kubeconfig-flag
Mar 31, 2020
Merged

estroz merged 1 commit into
operator-framework:masterfrom
estroz:bugfix/test-framework-kubeconfig-flag

Conversation

@estroz

@estroz estroz commented Mar 27, 2020 •

Copy link
Copy Markdown
Contributor

Description of the change:

  • pkg/test: only register --kubeconfig if not registered, get value if already registered

Motivation for the change: controller-runtime currently adds the --kubeconfig flag if pkg/client/config is imported (set up in an init() function). The SDK's test framework also adds this flag, which will panic if both packages are imported and the test framework is initialized.

Closes: kubernetes-sigs/controller-runtime#878

/cc @joelanford @camilamacedo86 @DirectXMan12 @akoserwal
/kind bug

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Mar 27, 2020
@openshift-ci-robot

Copy link
Copy Markdown

@estroz: GitHub didn't allow me to request PR reviews from the following users: akoserwal, DirectXMan12.

Note that only operator-framework members and repo collaborators can review this PR, and authors cannot review their own PRs.

Details

In response to this:

Description of the change:

  • pkg/test: use local flag.FlagSet instead of flag.CommandLine

Motivation for the change: controller-runtime currently adds the --kubeconfig flag if pkg/client/config is imported (set up in an init() function). The SDK's test framework also adds this flag, which will panic if both packages are imported and the test framework is initialized. This commit creates a new flag.FlagSet for the test framework instead of using the global one.

Closes: kubernetes-sigs/controller-runtime#878

/cc @joelanford @camilamacedo86 @DirectXMan12 @akoserwal
/kind bug

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@estroz
estroz force-pushed the bugfix/test-framework-kubeconfig-flag branch from ae4665c to e718209 Compare March 27, 2020 05:11
@estroz
estroz force-pushed the bugfix/test-framework-kubeconfig-flag branch from e718209 to ef61373 Compare March 27, 2020 05:57
@estroz estroz changed the title test framework: use local flag.FlagSet instead of global test framework: handle double-registered --kubeconfig flag Mar 27, 2020
Comment thread pkg/test/main_entry.go Resolved
Comment thread pkg/test/main_entry.go Resolved

@jmrodri jmrodri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

overall lgtm, I would add a test though. And confirm or deny my understanding of the flag parsing. If I misunderstood it, then we should add a changelog entry. If not, no changelog entry required.

Comment thread pkg/test/main_entry.go Resolved
Comment thread pkg/test/main_entry.go Resolved
@operator-framework operator-framework deleted a comment from jmrodri Mar 27, 2020
Comment thread pkg/test/framework.go Resolved
@estroz
estroz force-pushed the bugfix/test-framework-kubeconfig-flag branch from 786d4f9 to 3046e84 Compare March 27, 2020 17:45

f "github.com/operator-framework/operator-sdk/pkg/test"

// This import tests double-registration of the --kubebuilder flag:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jmrodri @camilamacedo86 confirmed that this import causes a panic w/o these changes.

@estroz estroz closed this Mar 27, 2020
@estroz estroz reopened this Mar 27, 2020
@estroz estroz closed this Mar 28, 2020
@estroz estroz reopened this Mar 28, 2020
pkg/client/config is imported (set up in an init() function).
The SDK's test framework also adds this flag, which will panic
if both are imported and the test framework is initialized.
This commit only registers --kubeconfig if it is not already
registered, and gets its value if so.

pkg/test: only register --kubeconfig if not registered, get value
if already registered

test/e2e: add import of controller-runtime/pkg/client/config to test --kubebuilder registration

CHANGELOG.md: add --kubeconfig double registration fix
@estroz
estroz force-pushed the bugfix/test-framework-kubeconfig-flag branch from 6fb7e20 to f20560c Compare March 28, 2020 18:48
@estroz estroz closed this Mar 31, 2020
@estroz estroz reopened this Mar 31, 2020

@camilamacedo86 camilamacedo86 left a comment

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.

/lgtm
/approved

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 31, 2020
@estroz
estroz merged commit 1e06378 into operator-framework:master Mar 31, 2020
@estroz
estroz deleted the bugfix/test-framework-kubeconfig-flag branch March 31, 2020 21:50
@abkieling

Copy link
Copy Markdown

@camilamacedo86

camilamacedo86 commented Jul 8, 2020 •

Copy link
Copy Markdown
Contributor

Hi @akieling,

SDK is in the version 0.18.2 already. So, 0.15.x is quite old and we would like to recommend you uprade your project.
See its Backport Policy in https://sdk.operatorframework.io/docs/contribution-guidelines/backport-policy/

@abkieling

Copy link
Copy Markdown

OK @camilamacedo86 . Thanks for the quick reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

flag redefined: kubeconfig: allow double vendoring this library but still register flags on behalf of users

5 participants