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: Panic when running odo list namespaces without an active Kubernetes context #6367

Conversation

valaparthvi
Copy link
Contributor

@valaparthvi valaparthvi commented Dec 1, 2022

What type of PR is this:
/kind bug

What does this PR do / why we need it:

Which issue(s) this PR fixes:

Fixes #6316

PR acceptance criteria:

  • Unit test

  • Integration test

  • Documentation

How to test changes / Special notes to the reviewer:
odo list namespace no longer panics, instead throws an appropriate error.

KUBECONFIG=/dev/null odo list namespace
$ KUBECONFIG=/dev/null odo list namespace
 ✗  
Please ensure you have an active kubernetes context to your cluster. 
Consult your Kubernetes distribution's documentation for more details.
Error: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable

odo remove binding still works when the cluster is inaccessible. The test for this was failing when a new REMOVE_BINDING dep was not added. Commit f542b22 fixes that.

KUBECONFIG=/dev/null odo remove binding --name something
$ KUBECONFIG=/dev/null odo remove binding --name something
 ✗  Service Binding "something" not found in the devfile. Available Service Bind
ings:

@netlify
Copy link

netlify bot commented Dec 1, 2022

Deploy Preview for odo-docusaurus-preview canceled.

Name Link
🔨 Latest commit 48bd771
🔍 Latest deploy log https://app.netlify.com/sites/odo-docusaurus-preview/deploys/638dcf0b6fea380008fc762b

@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Dec 1, 2022
@openshift-ci openshift-ci bot requested review from kadel and rm3l December 1, 2022 13:33
@odo-robot
Copy link

odo-robot bot commented Dec 1, 2022

Windows Tests (OCP) on commit db79bae finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Dec 1, 2022

NoCluster Tests on commit db79bae finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Dec 1, 2022

Unit Tests on commit db79bae finished successfully.
View logs: TXT HTML

Copy link
Member

@rm3l rm3l 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 can you add a simple integration test case for this in cmd_namespace_test?

I think this should be do-able now that we can put a nocluster label on Ginkgo tests. Labelling the test spec with this label should make the spec run without an active Kubernetes context.

@odo-robot
Copy link

odo-robot bot commented Dec 1, 2022

Validate Tests on commit db79bae finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Dec 1, 2022

Kubernetes Tests on commit db79bae finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Dec 1, 2022

OpenShift Tests on commit db79bae finished with errors.
View logs: TXT HTML

@valaparthvi valaparthvi closed this Dec 5, 2022
@valaparthvi valaparthvi reopened this Dec 5, 2022
@valaparthvi valaparthvi force-pushed the 6316-fix-list-namespace branch from 62044cb to c71eb51 Compare December 5, 2022 05:02
@valaparthvi
Copy link
Contributor Author

/retest

@@ -86,7 +86,7 @@ func NewCmdBinding(name, fullName string) *cobra.Command {
},
}
bindingCmd.Flags().String(backend.FLAG_NAME, "", "Name of the Binding to create")
clientset.Add(bindingCmd, clientset.BINDING, clientset.FILESYSTEM)
clientset.Add(bindingCmd, clientset.REMOVE_BINDING, clientset.FILESYSTEM)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not comfortable with this solution. If the problem is to define if KUBERNETES must be nullable or not for a specific command, we need to find a way to specify this directly

Copy link
Contributor Author

@valaparthvi valaparthvi Dec 5, 2022

Choose a reason for hiding this comment

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

Intuitively, I think KUBERNETES and KUBERNETES_NULLABLE should be mutually exclusive, but in cases where both are needed, we could only return an error if KUBERNETES_NULLABLE was not defined. WDYT?

I've tried an alternate solution here which seems to be working fine: 3a88ffe

Copy link
Contributor

Choose a reason for hiding this comment

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

@valaparthvi Yes, that seems a very good idea to me

@valaparthvi valaparthvi requested a review from feloy December 5, 2022 09:02
@valaparthvi valaparthvi force-pushed the 6316-fix-list-namespace branch from 3a88ffe to 7269c0a Compare December 5, 2022 09:56
@valaparthvi
Copy link
Contributor Author

/retest
cluster setup failure.

@valaparthvi valaparthvi force-pushed the 6316-fix-list-namespace branch from 7269c0a to 48bd771 Compare December 5, 2022 10:59
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 5, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.3% 0.3% Duplication

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Dec 5, 2022
@feloy
Copy link
Contributor

feloy commented Dec 5, 2022

/override OpenShift-Integration-tests/OpenShift-Integration-tests
Flaky e2e test

/go/odo_1/tests/e2escenarios/e2e_test.go:19
  starting with non-empty Directory add Binding
  /go/odo_1/tests/e2escenarios/e2e_test.go:279
    [It] should verify developer workflow of using binding as env in innerloop
    /go/odo_1/tests/e2escenarios/e2e_test.go:321

@openshift-ci
Copy link

openshift-ci bot commented Dec 5, 2022

@feloy: Overrode contexts on behalf of feloy: OpenShift-Integration-tests/OpenShift-Integration-tests

In response to this:

/override OpenShift-Integration-tests/OpenShift-Integration-tests
Flaky e2e test

/go/odo_1/tests/e2escenarios/e2e_test.go:19
 starting with non-empty Directory add Binding
 /go/odo_1/tests/e2escenarios/e2e_test.go:279
   [It] should verify developer workflow of using binding as env in innerloop
   /go/odo_1/tests/e2escenarios/e2e_test.go:321

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.

@feloy
Copy link
Contributor

feloy commented Dec 5, 2022

/override ci/prow/v4.11-integration-e2e
Tests pass on IBM Cloud

@openshift-ci
Copy link

openshift-ci bot commented Dec 5, 2022

@feloy: Overrode contexts on behalf of feloy: ci/prow/v4.11-integration-e2e

In response to this:

/override ci/prow/v4.11-integration-e2e
Tests pass on IBM Cloud

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.

@openshift-merge-robot openshift-merge-robot merged commit d6371a4 into redhat-developer:main Dec 5, 2022
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. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Panic when running odo list namespaces without an active Kubernetes context
4 participants