ensure ingress-nginx node label is applied#377
Merged
nimakaviani merged 2 commits intocnoe-io:mainfrom Aug 29, 2024
Merged
Conversation
Signed-off-by: Manabu McCloskey <manabu.mccloskey@gmail.com>
nimakaviani
requested changes
Aug 29, 2024
Contributor
nimakaviani
left a comment
There was a problem hiding this comment.
just a minor typo and a comment
Comment on lines
+258
to
+279
|
|
||
| nodes: | ||
| for i := range parsedCluster.Nodes { | ||
| node := parsedCluster.Nodes[i] | ||
| for _, pm := range node.ExtraPortMappings { | ||
| if strconv.Itoa(int(pm.HostPort)) == c.cfg.Port { | ||
| appendNecessaryPort = false | ||
| nodePosition = i | ||
| if node.Labels != nil { | ||
| v, ok := node.Labels[ingressNginxNodeLabelKey] | ||
| if ok && v == ingressNginxNodeLabelValue { | ||
| appendIngresNodeLabel = false | ||
| } | ||
| } | ||
| break nodes | ||
| } | ||
| } | ||
| if node.Labels != nil { | ||
| v, ok := node.Labels[ingressNginxNodeLabelKey] | ||
| if ok && v == ingressNginxNodeLabelValue { | ||
| appendIngresNodeLabel = false | ||
| nodePosition = i |
Contributor
There was a problem hiding this comment.
I wonder if this can be further simplified. I am not fond of label breaks in go, but leave it up to you.
Collaborator
Author
There was a problem hiding this comment.
It's really just comes down to last one winning or the first one winning. I chose first one winning. If we do last one wins, we can avoid using label breaks.
Contributor
There was a problem hiding this comment.
i like first one winning too.
Here is an alternative way of writing it (thanks ChatGPT). I dont think it is any easier tho. let's leave it.
for i, node := range parsedCluster.Nodes {
checkNodeLabels := func() {
if node.Labels != nil {
if v, ok := node.Labels[ingressNginxNodeLabelKey]; ok && v == ingressNginxNodeLabelValue {
appendIngresNodeLabel = false
}
}
}
for _, pm := range node.ExtraPortMappings {
if strconv.Itoa(int(pm.HostPort)) == c.cfg.Port {
appendNecessaryPort = false
nodePosition = i
checkNodeLabels()
break
}
}
if appendNecessaryPort { // If the port was not matched, check labels
checkNodeLabels()
if !appendIngresNodeLabel {
nodePosition = i
break
}
}
}
tapas4java
pushed a commit
to tapas4java/idpbuilder
that referenced
this pull request
Sep 3, 2024
Signed-off-by: Manabu McCloskey <manabu.mccloskey@gmail.com> Signed-off-by: Tapas Jena <tapas.friends@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes: #366
fixes: #367