-
Notifications
You must be signed in to change notification settings - Fork 814
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
Refactor metadata.go to test that k8s client is initialized iff ec2 metadata is unavailable #902
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: wongma7 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 |
Pull Request Test Coverage Report for Build 1991
💛 - Coveralls |
if m.GetInstanceID() != tc.identityDocument.InstanceID { | ||
t.Fatalf("GetInstanceID() failed: expected %v, got %v", tc.identityDocument.InstanceID, m.GetInstanceID()) | ||
if clientsetInitialized == true { | ||
t.Errorf("kubernetes client was unexpectedly initialized when metadata is available!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is the relevant part where we test that clientset initialization func did not get called.
rest of changes in this test file are mainly renaming and simplifying/collapsing some branching
…etadata is unavailable
actually instead of manually testing I want #907 to test it. existing kops job will check box 1 |
close in favor of #907 |
Is this a bug fix or adding new feature? /kind cleanup
What is this PR about? / Why do we need it? found in #897 that it's hard to test whether the k8s client has been initialized or not. in part because NewMetadataService accepts a kubernetes.Interface and you can't check if it's nil.
Refactored NewMetadataService to accept a func that returns a kubernetes.Interface... it's not pretty but should work.
(Also, I removed NewMetadata. Some of this code is hella confusing since we kept the naming of Metadata even though it can be constructed from k8s api now, not just ec2 instance metadata. I stopped short of renaming it, maybe to InstanceInfo or NodeInfo, because I already got a bit carried away with what is supposed to be a simple refactor, may do it later.)
What testing is done? TODO: e2e test on my eks cluster