-
Notifications
You must be signed in to change notification settings - Fork 260
chore: tidy up the wireserver client and usage #1065
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
Conversation
Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
Signed-off-by: Evan Baker <rbtr@users.noreply.github.com>
ramiro-gamarra
left a comment
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.
few comments/questions
| // queries the IMDS to get the primary interface info and caches it in the server state | ||
| // before returning the result. | ||
| func (service *HTTPRestService) getPrimaryHostInterface(ctx context.Context) (*wireserver.InterfaceInfo, error) { | ||
| if service.state.primaryInterface == nil { |
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.
- does lock need to be taken?
- flip condition and return early?
| break | ||
| } | ||
|
|
||
| if !found { |
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.
is the flag necessary? could just build the InterfaceInfo in the loop and return from there. If the loop is done, there was no primary interface
|
|
||
| ifInfo, err := service.imdsClient.GetPrimaryInterfaceInfoFromMemory() | ||
| var ifInfo *wireserver.InterfaceInfo | ||
| ifInfo, err = service.getPrimaryHostInterface(context.TODO()) |
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.
curious about this change
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.
least effort fix to the linter complaining about err shadowing
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.
erm... something is off if the linter will favor this style over the previous one
| // HostPrimaryIP 10.0.0.4 | ||
| HostPrimaryIP = "10.0.0.4" | ||
| // HostSubnet 10.0.0.0/24 | ||
| HostSubnet = "10.0.0.0/24" |
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.
consts? otherwise, if they need to be mutated for tests, make them part of the fake?
| // Create CNS object. | ||
| httpRestService, err := restserver.NewHTTPRestService(&config, new(imdsclient.ImdsClient), nmaclient) | ||
|
|
||
| httpRestService, err := restserver.NewHTTPRestService(&config, &wireserver.Client{HTTPClient: &http.Client{}}, nmaclient) |
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.
http.DefaultClient
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.
DefaultClient can be mutated - I don't want a custom client, I explicitly want a default client
Reason for Change:
Strips the
cns/imdsclientpackage of dead code, adds tests, and turns what is left in to a better client.Issue Fixed:
Requirements:
Notes: