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

Updating config cmds and tests for logged out senario #4975

Merged

Conversation

mohammedzee1000
Copy link
Contributor

@mohammedzee1000 mohammedzee1000 commented Aug 9, 2021

Signed-off-by: Mohammed Zeeshan Ahmed mohammed.zee1000@gmail.com

What type of PR is this?
See topic
Also, identified 2 cases:

  • invalid kubeconfig path
  • Kubeconfig was not being handled.

Essentially it boils down to us not handling error from context.New()

/kind bug

What does this PR do / why we need it:
See topic

Which issue(s) this PR fixes:

Fixes #4910

PR acceptance criteria:

  • Unit test

  • Integration test

  • Documentation

  • Update changelog

  • I have read the test guidelines

How to test changes / Special notes to the reviewer:

> odo create nodejs
Devfile Object Validation
 ✓  Checking devfile existence [87112ns]
 ✓  Creating a devfile component from registry: DefaultDevfileRegistry [150916ns]
Validation
 ✓  Validating if devfile name is correct [114120ns]

Please use `odo push` command to create the component with source deployed
> odo config view
ComponentName: nodejs
Configs:
- ContainerName: runtime
  Ports:
  - ExposedPort: 3000
    Name: http-3000
    Protocol: http
Memory: 1024Mi
> mv ~/.kube/config ~/.kube/configback
> ls ~/.kube
cache  configback  http-cache
> odo config view
ComponentName: nodejs
Configs:
- ContainerName: runtime
  Ports:
  - ExposedPort: 3000
    Name: http-3000
    Protocol: http
Memory: 1024Mi

> odo config set --env hello=world
 ✗  invalid KUBECONFIG provided. Please point to a valid KUBECONFIG. You do not have to be logged in 
Please ensure you have an active kubernetes context to your cluster. 
Consult your Kubernetes distribution's documentation for more details
: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
> odo config unset --env hello
 ✗  invalid KUBECONFIG provided. Please point to a valid KUBECONFIG. You do not have to be logged in 
Please ensure you have an active kubernetes context to your cluster. 
Consult your Kubernetes distribution's documentation for more details
: invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable
> sudo cp -avrf ~/.kube/configback ~/.kube/config
[sudo] password for mzee1000: 
'/home/mzee1000/.kube/configback' -> '/home/mzee1000/.kube/config'
> oc logout
Logged "mzee1000" out on "<redacted>"
> odo config set --env hello=world
------
 ✓  Environment variables were successfully updated

Run `odo push` command to apply changes to the cluster
> odo config view
ComponentName: nodejs
Configs:
- ContainerName: runtime
  EnvironmentVariables:
  - Name: hello
    Value: world
  Ports:
  - ExposedPort: 3000
    Name: http-3000
    Protocol: http
Memory: 1024Mi
> odo config unset --env hello
 ✓  Environment variables were successfully updated

Run `odo push` command to apply changes to the cluster
> odo config view
ComponentName: nodejs
Configs:
- ContainerName: runtime
  Ports:
  - ExposedPort: 3000
    Name: http-3000
    Protocol: http
Memory: 1024Mi

@openshift-ci openshift-ci bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. kind/bug Categorizes issue or PR as related to a bug. labels Aug 9, 2021
@mohammedzee1000 mohammedzee1000 force-pushed the test_crash branch 3 times, most recently from 7f201fe to 8e9a9ba Compare August 11, 2021 11:31
@mohammedzee1000
Copy link
Contributor Author

timeout
/test psi-unit-test-mac
/test psi-unit-test-windows

1 similar comment
@mohammedzee1000
Copy link
Contributor Author

timeout
/test psi-unit-test-mac
/test psi-unit-test-windows

@mohammedzee1000
Copy link
Contributor Author

project list json output
/retest

@mohammedzee1000 mohammedzee1000 changed the title WIP Updating config cmds and tests for logged out senario Updating config cmds and tests for logged out senario Aug 12, 2021
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Aug 12, 2021
@mohammedzee1000
Copy link
Contributor Author

timeout
/test psi-unit-test-windows
/test psi-unit-test-mac

Copy link
Member

@dharmit dharmit left a comment

Choose a reason for hiding this comment

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

Code is adding a bunch of err1 and err2. I'm not sure why we're not just using err. Subsequent calls would either set err to nil or an error returned by the function called. What's wrong in using it?

pkg/odo/cli/catalog/list/components.go Outdated Show resolved Hide resolved
pkg/odo/cli/config/set.go Outdated Show resolved Hide resolved
pkg/odo/cli/config/set.go Outdated Show resolved Hide resolved
@dharmit
Copy link
Member

dharmit commented Aug 16, 2021

@mohammedzee1000 can you please update the Changelog.md and add the steps to test the change in this PR?

@mohammedzee1000
Copy link
Contributor Author

prow error
test psi-kubernetes-integration-e2e

@mohammedzee1000
Copy link
Contributor Author

Unrelated error

• Failure [55.931 seconds]
odo devfile push command tests
/go/src/github.com/openshift/odo/tests/integration/devfile/cmd_devfile_push_test.go:18
  verify command executions
  /go/src/github.com/openshift/odo/tests/integration/devfile/cmd_devfile_push_test.go:464
    when default build and run commands are defined
    /go/src/github.com/openshift/odo/tests/integration/devfile/cmd_devfile_push_test.go:494
      should execute correct commands [It]
      /go/src/github.com/openshift/odo/tests/integration/devfile/cmd_devfile_push_test.go:495
      Unexpected error:
      
          <*errors.errorString | 0xc0003583e0>: {
              s: "cmd [ps -ef] failed with error Signal 23 (URG) caught by ps (3.3.15).\nps:ps/display.c:66: please report this bug\ncommand terminated with exit code 1\n on pod ammwlb-app-f48ddc5d7-vcmck",
          }
          cmd [ps -ef] failed with error Signal 23 (URG) caught by ps (3.3.15).
          ps:ps/display.c:66: please report this bug
          command terminated with exit code 1
           on pod ammwlb-app-f48ddc5d7-vcmck
      occurred
      /go/src/github.com/openshift/odo/tests/integration/devfile/cmd_devfile_push_test.go:514
------------------------------
•••••••••

/test v4.8-integration-e2e

Timed out

/test psi-kubernetes-integration-e2e

pkg/odo/cli/config/set.go Show resolved Hide resolved
pkg/odo/cli/config/set.go Outdated Show resolved Hide resolved
pkg/util/util.go Outdated Show resolved Hide resolved
pkg/util/util.go Outdated Show resolved Hide resolved
tests/integration/cmd_pref_config_test.go Show resolved Hide resolved
tests/integration/cmd_pref_config_test.go Show resolved Hide resolved
tests/integration/cmd_pref_config_test.go Show resolved Hide resolved
pkg/util/util.go Outdated
} else {
klog.V(4).Infof("no KUBECONFIG provided and cannot fallback to default")
return false
func IsValidKubeConfigPath() error {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if the return value of this function should be error. Function name indicates that the response to expect from it should be either Yes or No, that is, a boolean value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renaming

Copy link
Member

Choose a reason for hiding this comment

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

I'm more inclined at not changing the signature of the function, if possible.

pkg/util/util.go Outdated
func IsValidKubeConfigPath() error {
kubeConfigPath := os.Getenv("KUBECONFIG")
if kubeConfigPath != "" {
f1, err := os.Stat(kubeConfigPath)
Copy link
Member

Choose a reason for hiding this comment

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

Why f1 and not f? Something to do with Formula 1? 😉

pkg/util/util.go Outdated Show resolved Hide resolved
pkg/util/util.go Outdated
return nil
}

func NewInvalidKubeConfigPathError() error {
Copy link
Member

Choose a reason for hiding this comment

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

Why NewInvalidKubeConfigPathError and not InvalidKubeConfigPathError? Also, why define a function instead of defining it as an error type? For example: https://github.com/openshift/odo/blob/089b8ea26c253592cd4788ed615a698297d620a5/pkg/kclient/operators.go#L15-L17

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updating

@mohammedzee1000
Copy link
Contributor Author

time out
/test psi-unit-test-windows

@mohammedzee1000
Copy link
Contributor Author

mohammedzee1000 commented Aug 20, 2021

Prow error
/retest

@mohammedzee1000
Copy link
Contributor Author

/retest

mohammedzee1000 and others added 12 commits August 26, 2021 12:43
Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>
Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>
Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>
Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>
Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>
Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>
Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>
Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>
Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>
Co-authored-by: Dharmit Shah <shahdharmit@gmail.com>
Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>
Co-authored-by: Philippe Martin <contact@elol.fr>
@openshift-ci openshift-ci bot removed lgtm Indicates that a PR is ready to be merged. Required by Prow. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. labels Aug 26, 2021
@sonarcloud
Copy link

sonarcloud bot commented Aug 26, 2021

SonarCloud Quality Gate failed.    Quality Gate failed

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
7.5% 7.5% Duplication

@feloy
Copy link
Contributor

feloy commented Sep 1, 2021

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Sep 1, 2021
@mohammedzee1000
Copy link
Contributor Author

json format project error
/retest

@valaparthvi
Copy link
Member

/approve

@openshift-ci
Copy link

openshift-ci bot commented Sep 1, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: valaparthvi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. label Sep 1, 2021
@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

5 similar comments
@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 455815b into redhat-developer:main Sep 2, 2021
@kadel kadel mentioned this pull request Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. Required by Prow. 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.

Crash observed while executing integration tests on Power (ppc64le)
6 participants