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

List namespace right after namespace has been created #6922

Conversation

valaparthvi
Copy link
Member

What type of PR is this:
/kind bug
/flake

What does this PR do / why we need it:
This PR fixes the bug where odo create namespace -w does not work as expected.
Which issue(s) this PR fixes:

Fixes #6827

PR acceptance criteria:

  • Unit test

  • Integration test

  • Documentation

How to test changes / Special notes to the reviewer:

@netlify
Copy link

netlify bot commented Jun 22, 2023

🔨 Deploy Preview deleted from internal cluster!

Name Link
🔨 Latest commit 14b846b
😎 Deploy Preview https://odo-dev-pr-6922.odo-test-kubernete-449701-49529fc6e6a4a9fe7ebba9a3db5b55c4-0000.eu-de.containers.appdomain.cloud/

@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 22, 2023
@openshift-ci openshift-ci bot requested review from feloy and rnapoles-rh June 22, 2023 10:59
@odo-robot
Copy link

odo-robot bot commented Jun 22, 2023

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

@odo-robot
Copy link

odo-robot bot commented Jun 22, 2023

OpenShift Unauthenticated Tests on commit baabf8b finished successfully.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Jun 22, 2023

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

@odo-robot
Copy link

odo-robot bot commented Jun 22, 2023

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

@valaparthvi valaparthvi requested review from rm3l and removed request for rnapoles-rh June 22, 2023 11:17
@odo-robot
Copy link

odo-robot bot commented Jun 22, 2023

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

@odo-robot
Copy link

odo-robot bot commented Jun 22, 2023

Windows Tests (OCP) on commit baabf8b finished with errors.
View logs: TXT HTML

@odo-robot
Copy link

odo-robot bot commented Jun 22, 2023

OpenShift Tests on commit baabf8b finished successfully.
View logs: TXT HTML

if ns.Name == nco.namespaceName {
break L
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add a sleep for let's say 50ms at this point, to not respawn the List operation too fast

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good idea.

Copy link
Contributor

@feloy feloy left a comment

Choose a reason for hiding this comment

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

Thanks for this fix

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jun 23, 2023
@@ -105,7 +108,29 @@ func (nco *NamespaceCreateOptions) Run(ctx context.Context) (err error) {
if err != nil {
return err
}

if nco.waitFlag {
var timeOut = time.After(nco.clientset.PreferenceClient.GetTimeout())
Copy link
Member

Choose a reason for hiding this comment

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

The default value for nco.clientset.PreferenceClient.GetTimeout() is currently 1 second. Isn't that too low?

Copy link
Member

@rm3l rm3l Jun 23, 2023

Choose a reason for hiding this comment

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

Also, to me, if the user sets --wait, it means that they purposely are willing to wait until they get confirmation that the namespace/project is returned correctly.
I'm thinking for example of a script using odo create namespace --wait before doing other things..
The user would need to interrupt the process to cancel the wait.
So IMO, we should not even have a timeout.

Copy link
Contributor

Choose a reason for hiding this comment

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

For me, it's a matter of 10's of milliseconds. Having to break manually can be dangerous if executed from a script: is the user expecting the command will never return in case of problem? I would instead return an error if the namespace is not created after a reasonable time. As the timeout is configurable, I would keep as is, and users in heavy loaded systems could increase it.

Copy link
Member

Choose a reason for hiding this comment

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

Yup, that makes sense. Personally, I found this Timeout preference confusing and not used consistently. I think every command with a --wait flag should also provide an additional --timeout flag to set a timeout only for this command, but that's a different story.
Alright, in this case, returning an error if the timeout is reached would indeed make more sense. The error should also clearly indicate how the user can adjust this timeout, I think.

cc @valaparthvi

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.

One last comment: I think the success message (Namespace "$ns" is ready for use) should be displayed only after the new checks are done. Otherwise, the output might be confusing if the namespace still does not appear in the list after the timeout is reached, e.g.:

$ odo create namespace test-ns11 --wait
 ✓  Waiting for namespace to come up [11ms]
 ✓  Namespace "test-ns11" is ready for use
 ⚠  Timeout while waiting for namespace "test-ns11"; it may take a while to appear

I'd suggest displaying ✓ Namespace "test-ns11" is ready for use only if the namespace does appear in the list. What do you think?

EDIT: Actually, I think the Waiting for namespace to come up line should return successfully only after we are done with the checks. Then we could display ✓ Namespace "$ns" is ready for use.

@rm3l rm3l added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. Required by Prow. label Jun 23, 2023
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jun 27, 2023
pkg/odo/cli/create/namespace/namespace.go Outdated Show resolved Hide resolved
@rm3l rm3l removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. Required by Prow. label Jun 27, 2023
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jun 27, 2023
@rm3l rm3l added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. Required by Prow. label Jun 27, 2023
Signed-off-by: Parthvi Vala <pvala@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>
Signed-off-by: Parthvi Vala <pvala@redhat.com>
@valaparthvi valaparthvi force-pushed the 6827-w-flag-for-odo-create-namespace-doesn-t-work-as-expected-on-crc-2.18-and-2.19 branch from 4cbc111 to b3d20bf Compare June 27, 2023 11:43
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jun 27, 2023
@valaparthvi valaparthvi temporarily deployed to internal June 27, 2023 11:43 — with GitHub Actions Inactive
@odo-robot
Copy link

odo-robot bot commented Jun 27, 2023

Kubernetes Docs Tests on commit 324d73f finished successfully.
View logs: TXT HTML

Signed-off-by: Parthvi Vala <pvala@redhat.com>
@valaparthvi valaparthvi force-pushed the 6827-w-flag-for-odo-create-namespace-doesn-t-work-as-expected-on-crc-2.18-and-2.19 branch from b3d20bf to 14b846b Compare June 27, 2023 12:19
@valaparthvi valaparthvi temporarily deployed to internal June 27, 2023 12:19 — with GitHub Actions Inactive
@sonarcloud
Copy link

sonarcloud bot commented Jun 27, 2023

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 1 Code Smell

No Coverage information No Coverage information
0.5% 0.5% Duplication

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. Required by Prow. label Jun 27, 2023
@rm3l rm3l removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. Required by Prow. label Jun 27, 2023
@rm3l
Copy link
Member

rm3l commented Jun 27, 2023

+ [FAILED] [1.948 seconds]
odo preference and config command tests label nocluster when telemetry is enabled when unsetting value for preference ImageRegistry [It] should track parameter that is unset without any value [nocluster]
C:/Users/Administrator.ANSIBLE-TEST-VS/4273/tests/integration/cmd_pref_config_test.go:244

  Timeline >>
  Created dir: C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\3302507260
  Created dir: C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509
  Current working dir: C:\Users\Administrator.ANSIBLE-TEST-VS\4273\tests\integration
  Running odo.exe with args [odo preference remove registry DefaultDevfileRegistry -f] and odo env: []
  [odo] I0627 08:02:55.914701    4632 implem.go:114] The path for preference file is C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509\preference.yaml
  [odo] I0627 08:02:55.914701    4632 implem.go:114] The path for preference file is C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509\preference.yaml
  [odo] Successfully removed registry
  [odo] I0627 08:02:55.934232    4632 segment.go:264] Checking telemetry enable status
  [odo] I0627 08:02:55.934232    4632 segment.go:282] Sending telemetry disabled by env variable
  Running odo.exe with args [odo preference add registry DefaultDevfileRegistry https://devfile-registry-ci-devfile-registry.odo-test-kubernete-449701-49529fc6e6a4a9fe7ebba9a3db5b55c4-0000.eu-de.containers.appdomain.cloud]/ and odo env: []
  [odo] I0627 08:02:56.160068    7348 implem.go:114] The path for preference file is C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509\preference.yaml
  [odo] I0627 08:02:56.160885    7348 implem.go:114] The path for preference file is C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509\preference.yaml
  [odo] New registry successfully added
  [odo] I0627 08:02:56.167553    7348 segment.go:264] Checking telemetry enable status
  [odo] I0627 08:02:56.167553    7348 segment.go:282] Sending telemetry disabled by env variable
  Running odo.exe with args [odo preference unset ImageRegistry --force] and odo env: []
  [odo] I0627 08:02:56.383470    5936 implem.go:114] The path for preference file is C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509\preference.yaml
  [odo] I0627 08:02:56.383470    5936 implem.go:114] The path for preference file is C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509\preference.yaml
  [odo]  V  Value of 'imageregistry' preference was removed from preferences. Its default value will be used.
  [odo] I0627 08:02:56.395277    5936 segment.go:264] Checking telemetry enable status
  [odo] I0627 08:02:56.395277    5936 segment.go:285] Sending telemetry enabled by env variable
  Running odo.exe with args [odo preference unset ImageRegistry --force] and odo env: []
  [odo] I0627 08:02:56.588301    9016 implem.go:114] The path for preference file is C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509\preference.yaml
  [odo] I0627 08:02:56.588553    9016 implem.go:114] The path for preference file is C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509\preference.yaml
  [odo]  V  Value of 'imageregistry' preference was removed from preferences. Its default value will be used.
  [odo] I0627 08:02:56.595904    9016 segment.go:264] Checking telemetry enable status
  [odo] I0627 08:02:56.595904    9016 segment.go:285] Sending telemetry enabled by env variable
  [FAILED] in [It] - C:/Users/Administrator.ANSIBLE-TEST-VS/4273/tests/helper/helper_telemetry.go:67 @ 06/27/23 08:02:57.67
  Setting current dir to: C:\Users\Administrator.ANSIBLE-TEST-VS\4273\tests\integration
  Deleting dir: C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\3302507260
  Deleting dir: C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509
  << Timeline

  [FAILED] Unexpected error:
      <*json.SyntaxError | 0xc0004902a0>: 
      invalid character '}' after top-level value
      {
          msg: "invalid character '}' after top-level value",
          Offset: 296,
      }
  occurred
  In [It] at: C:/Users/Administrator.ANSIBLE-TEST-VS/4273/tests/helper/helper_telemetry.go:67 @ 06/27/23 08:02:57.67

...

Summarizing 1 Failure:
  [FAIL] odo preference and config command tests label nocluster when telemetry is enabled when unsetting value for preference ImageRegistry [It] should track parameter that is unset without any value [nocluster]
  C:/Users/Administrator.ANSIBLE-TEST-VS/4273/tests/helper/helper_telemetry.go:67

Ran 125 of 932 Specs in 22.902 seconds
FAIL! -- 124 Passed | 1 Failed | 0 Pending | 807 Skipped


Ginkgo ran 1 suite in 1m12.2459429s

Unrelated, but keeping an eye on this to see if it occurs again.

/override windows-integration-test/Windows-test

@openshift-ci
Copy link

openshift-ci bot commented Jun 27, 2023

@rm3l: Overrode contexts on behalf of rm3l: windows-integration-test/Windows-test

In response to this:

+ [FAILED] [1.948 seconds]
odo preference and config command tests label nocluster when telemetry is enabled when unsetting value for preference ImageRegistry [It] should track parameter that is unset without any value [nocluster]
C:/Users/Administrator.ANSIBLE-TEST-VS/4273/tests/integration/cmd_pref_config_test.go:244

 Timeline >>
 Created dir: C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\3302507260
 Created dir: C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509
 Current working dir: C:\Users\Administrator.ANSIBLE-TEST-VS\4273\tests\integration
 Running odo.exe with args [odo preference remove registry DefaultDevfileRegistry -f] and odo env: []
 [odo] I0627 08:02:55.914701    4632 implem.go:114] The path for preference file is C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509\preference.yaml
 [odo] I0627 08:02:55.914701    4632 implem.go:114] The path for preference file is C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509\preference.yaml
 [odo] Successfully removed registry
 [odo] I0627 08:02:55.934232    4632 segment.go:264] Checking telemetry enable status
 [odo] I0627 08:02:55.934232    4632 segment.go:282] Sending telemetry disabled by env variable
 Running odo.exe with args [odo preference add registry DefaultDevfileRegistry https://devfile-registry-ci-devfile-registry.odo-test-kubernete-449701-49529fc6e6a4a9fe7ebba9a3db5b55c4-0000.eu-de.containers.appdomain.cloud]/ and odo env: []
 [odo] I0627 08:02:56.160068    7348 implem.go:114] The path for preference file is C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509\preference.yaml
 [odo] I0627 08:02:56.160885    7348 implem.go:114] The path for preference file is C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509\preference.yaml
 [odo] New registry successfully added
 [odo] I0627 08:02:56.167553    7348 segment.go:264] Checking telemetry enable status
 [odo] I0627 08:02:56.167553    7348 segment.go:282] Sending telemetry disabled by env variable
 Running odo.exe with args [odo preference unset ImageRegistry --force] and odo env: []
 [odo] I0627 08:02:56.383470    5936 implem.go:114] The path for preference file is C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509\preference.yaml
 [odo] I0627 08:02:56.383470    5936 implem.go:114] The path for preference file is C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509\preference.yaml
 [odo]  V  Value of 'imageregistry' preference was removed from preferences. Its default value will be used.
 [odo] I0627 08:02:56.395277    5936 segment.go:264] Checking telemetry enable status
 [odo] I0627 08:02:56.395277    5936 segment.go:285] Sending telemetry enabled by env variable
 Running odo.exe with args [odo preference unset ImageRegistry --force] and odo env: []
 [odo] I0627 08:02:56.588301    9016 implem.go:114] The path for preference file is C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509\preference.yaml
 [odo] I0627 08:02:56.588553    9016 implem.go:114] The path for preference file is C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509\preference.yaml
 [odo]  V  Value of 'imageregistry' preference was removed from preferences. Its default value will be used.
 [odo] I0627 08:02:56.595904    9016 segment.go:264] Checking telemetry enable status
 [odo] I0627 08:02:56.595904    9016 segment.go:285] Sending telemetry enabled by env variable
 [FAILED] in [It] - C:/Users/Administrator.ANSIBLE-TEST-VS/4273/tests/helper/helper_telemetry.go:67 @ 06/27/23 08:02:57.67
 Setting current dir to: C:\Users\Administrator.ANSIBLE-TEST-VS\4273\tests\integration
 Deleting dir: C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\3302507260
 Deleting dir: C:\Users\Administrator.ANSIBLE-TEST-VS\AppData\Local\Temp\2531324509
 << Timeline

 [FAILED] Unexpected error:
     <*json.SyntaxError | 0xc0004902a0>: 
     invalid character '}' after top-level value
     {
         msg: "invalid character '}' after top-level value",
         Offset: 296,
     }
 occurred
 In [It] at: C:/Users/Administrator.ANSIBLE-TEST-VS/4273/tests/helper/helper_telemetry.go:67 @ 06/27/23 08:02:57.67

...

Summarizing 1 Failure:
 [FAIL] odo preference and config command tests label nocluster when telemetry is enabled when unsetting value for preference ImageRegistry [It] should track parameter that is unset without any value [nocluster]
 C:/Users/Administrator.ANSIBLE-TEST-VS/4273/tests/helper/helper_telemetry.go:67

Ran 125 of 932 Specs in 22.902 seconds
FAIL! -- 124 Passed | 1 Failed | 0 Pending | 807 Skipped


Ginkgo ran 1 suite in 1m12.2459429s

Unrelated, but keeping an eye on this to see if it occurs again.

/override windows-integration-test/Windows-test

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 3bf5ffc into redhat-developer:main Jun 27, 2023
23 checks passed
@openshift-merge-robot openshift-merge-robot temporarily deployed to internal June 27, 2023 14:03 — with GitHub Actions Inactive
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.

-w flag for odo create namespace doesn't work as expected on crc 2.18 and 2.19
4 participants