-
Notifications
You must be signed in to change notification settings - Fork 260
Allow cns to register node if no NCs are present #1232
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
Allow cns to register node if no NCs are present #1232
Conversation
|
What do you think @rbtr about these go-lint failures? and then this one is because I'm trying to do just in-line structs: Do you think I could just merge it in as is 😅 ? |
|
yeah, it's mad because you're not supposed to copy a mutex and you're making a local copy of that tt struct which has the restservice which has a mutex. should be fine to throw a |
|
Does the |
cns/restserver/util.go
Outdated
| if len(service.state.ContainerStatus) == 0 { | ||
| if len(service.state.ContainerIDByOrchestratorContext) == 0 { |
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.
can you one-line this with an ||? or maybe it should be a switch?
| if len(service.state.ContainerStatus) == 0 { | |
| if len(service.state.ContainerIDByOrchestratorContext) == 0 { | |
| if len(service.state.ContainerStatus) == 0 || len(service.state.ContainerIDByOrchestratorContext) == 0 { |
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.
I would probably && it instead, so that both things need to be empty for it to say it's empty
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.
I put an && @rbtr so it's one line now
end of line. ex:
|
Thanks @rbtr, linter seems happy now |
rbtr
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.
lgtm, but left a couple comments that for things you could improve if you feel like it
| if len(service.state.ContainerStatus) == 0 && len(service.state.ContainerIDByOrchestratorContext) == 0 { | ||
| return false | ||
| } | ||
| return true |
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.
just a thought, this pattern is fundamentally
if (bool) { return false }
return truewhich is really
return !boolThere 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.
Ah I didn't think about that
| if nodeID == "" || nodeID == req.NodeID { | ||
| if nodeID == "" || nodeID == req.NodeID || !service.areNCsPresent() { | ||
| switch req.OrchestratorType { | ||
| case cns.ServiceFabric: |
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.
i know you didn't change this, but this fallthrough pattern is very unusual in go. if all of these switch tests should actually execute the same case, it's better to do:
case cns.ServiceFabric, cns.Kubernetes, cns.KubernetesCRD, [... other tests ...]:
// the caseThere 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.
Good point
Reason for Change:
Allow CNS to register the node if no NCs are present
Issue Fixed:
Livesite issue 13242071
Validation




#unitTests and,
When NCs are not present, CNS allows re-registration of node:
When NCs are present, CNS denies re-registration of node:



