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

#259 Support for node labels to set eniConfig #260

Closed
wants to merge 1 commit into from

Conversation

etopeter
Copy link
Contributor

@etopeter etopeter commented Dec 6, 2018

#259

Added support for node labels and unit tests.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@md2k
Copy link

md2k commented Dec 19, 2018

Tested this PR with my EKS and it is awesome. probably for a while we going to use custom build for aws-node to ensure that we able to do automated cni configuration.


val, ok := label[eniConfigLabelDef]
if ok {
h.controller.eniLock.Lock()
Copy link
Contributor

Choose a reason for hiding this comment

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

There are three duplicated Lock, Unlock lines around this block. Would you like to refactor them?

For example, you can write under L106 as:

        case *corev1.Node:

                log.Infof("Handle corev1.Node: %s, %v, %v", o.GetName(), o.GetAnnotations(), o.GetLabels())
                if h.controller.myNodeName == o.GetName() {
                        val, ok := o.GetAnnotations()[eniConfigAnnotationDef]
                        if !ok {
                                val, ok = o.GetLabels()[eniConfigLabelDef]
                                if !ok {
                                        val = eniConfigDefault
                                }
                        }

                        h.controller.eniLock.Lock()
                        defer h.controller.eniLock.Unlock()
                        h.controller.myENI = val
                        log.Infof(" Setting myENI to: %s", val)
                }
        }
        return nil

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @nak3, the code above is easier to read and less duplicated code.

@@ -68,6 +68,33 @@ func updateNodeAnnotation(hdlr sdk.Handler, nodeName string, configName string,
hdlr.Handle(nil, event)
}

func updateNodeLabel(hdlr sdk.Handler, nodeName string, configName string, toDelete bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is almost same with updateNodeAnnotation(). It is better to combine them?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we extract the strictly duplicate code. I think two methods is fine, if we remove the code that is the same toa createEvent function.

@@ -144,3 +171,44 @@ func TestNodeENIConfig(t *testing.T) {
assert.Equal(t, defaultCfg, *outputCfg)

}

func TestNodeENIConfigLabel(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same with above comment. Is it not possible to merge this test into TestNodeENIConfig()?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm planning a bigger refactor of the test code so I am OK with this.

@nak3
Copy link
Contributor

nak3 commented Dec 23, 2018

I am not an official reviewer so please disregard my comments if you disagree.

Copy link
Contributor

@liwenwu-amazon liwenwu-amazon left a comment

Choose a reason for hiding this comment

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

LGTM

@md2k
Copy link

md2k commented Jan 11, 2019

when this can be merged?

@etopeter
Copy link
Contributor Author

etopeter commented Jan 11, 2019

There is another PR with same functionality, more features and cleaner logic here 280. Hoping to see that one gets merged and you will also be able to set custom annotations and labels.

@mogren
Copy link
Contributor

mogren commented Jan 11, 2019

Can we cancel this PR since #280 has been merged?

@etopeter etopeter closed this Jan 11, 2019
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.

6 participants