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

Watch for the service account token to be ready #668

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

nitishm
Copy link

@nitishm nitishm commented Aug 13, 2021

Instead of using a sleep use an actual watcher to ensure that the token
is ready before proceeding.

Closes #403

Signed-off-by: Nitish Malhotra nitish.malhotra@gmail.com

@nitishm nitishm force-pushed the nitishm/refactor/403/watch-for-service-account-and-token branch from 0b37616 to cbe20c0 Compare August 13, 2021 23:39
@bacongobbler
Copy link
Collaborator

Hi @nitishm. Sorry for the late response.

Generally speaking we ask for unit tests to accompany any changes. That way we can ensure future changes won't introduce a code regression, and we have some context around why certain changes were made in the past. Would you mind writing some tests? Thanks!

@bacongobbler
Copy link
Collaborator

Looking at this closer... It might be too difficult to implement tests for the tests. I think we can make an exception here.

Copy link
Member

@thomastaylor312 thomastaylor312 left a comment

Choose a reason for hiding this comment

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

Looking great, just one minor change to remove old commented out code and the associated TODO

tests/test_resource_manager.rs Outdated Show resolved Hide resolved
@thomastaylor312
Copy link
Member

Looks like tests are failing due to cargo fmt. You should just be able to run cargo fmt --all and things should be good after that

@thomastaylor312
Copy link
Member

Looks like you have a compilation error (and some warnings) in the new tests you added:

warning: unused import: `Metadata`
 --> tests/test_resource_manager.rs:6:5
  |
6 |     Metadata,
  |     ^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: unused import: `WatchEvent`
 --> tests/test_resource_manager.rs:9:54
  |
9 |     api::{Api, DeleteParams, ListParams, PostParams, WatchEvent},
  |                                                      ^^^^^^^^^^

error[E0599]: no method named `first` found for enum `std::option::Option` in the current scope
   --> tests/test_resource_manager.rs:125:40
    |
125 |                 let secret = o.secrets.first().unwrap().clone();
    |                                        ^^^^^ method not found in `std::option::Option<Vec<ObjectReference>>`

warning: unused import: `ResourceExt`
  --> tests/test_resource_manager.rs:10:5
   |
10 |     ResourceExt,
   |     ^^^^^^^^^^^

@thomastaylor312
Copy link
Member

Hey there @nitishm! Sorry for the delay. We were having some e2e test problems that should probably solve your issue. Mind rebasing now that #694 is merged? I can do it for you as well if you don't mind me force pushing

@nitishm
Copy link
Author

nitishm commented Oct 22, 2021

Go for it! I don't mind you force pushing

Instead of using a sleep use an actual watcher to ensure that the token
is ready before proceeding.

Closes krustlet#403

Signed-off-by: Nitish Malhotra <nitish.malhotra@gmail.com>
Signed-off-by: Nitish Malhotra <nitish.malhotra@gmail.com>
Signed-off-by: Nitish Malhotra <nitish.malhotra@gmail.com>
Signed-off-by: Nitish Malhotra <nitish.malhotra@gmail.com>
@thomastaylor312 thomastaylor312 force-pushed the nitishm/refactor/403/watch-for-service-account-and-token branch 2 times, most recently from 64638b4 to f0042bc Compare October 22, 2021 20:37
Signed-off-by: Taylor Thomas <taylor@oftaylor.com>
@thomastaylor312 thomastaylor312 force-pushed the nitishm/refactor/403/watch-for-service-account-and-token branch from f0042bc to b656d58 Compare October 22, 2021 20:47

while let Some(event) = watcher.try_next().await? {
if let watcher::Event::Applied(o) = event {
let secret = o.secrets.unwrap_or_default().first().unwrap().clone();
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this is causing e2e test failures. Maybe this should retry for up to 10s before erroring

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.

Properly wait for namespace creation to stabilize in tests
3 participants