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

Created a controller to manage ALB attributes #650

Merged
merged 15 commits into from
Sep 28, 2018

Conversation

bigkraig
Copy link

No description provided.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 27, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bigkraig

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 27, 2018
@coveralls
Copy link

coveralls commented Sep 27, 2018

Coverage Status

Coverage increased (+1.6%) to 30.557% when pulling 3ac4e19 on AttributesController into b2ff2d6 on master.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 27, 2018
@M00nF1sh
Copy link
Collaborator

nice work! it's much cleaner and readable now! 👍

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 27, 2018
@bigkraig bigkraig changed the title WIP: Created a controller to manage ALB attributes Created a controller to manage ALB attributes Sep 27, 2018
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 27, 2018
)

const (
DeletionProtectionEnabledString = "deletion_protection.enabled"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe like DeletionProtectionEnabledKey and DefaultDeletionProtectionEnabled ?
but current workings for me too 😸 , just nitpicking...

RoutingHTTP2Enabled: RoutingHTTP2Enabled,
}
for _, attr := range attrs {
switch aws.StringValue(attr.Key) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could be switch attrKey := aws.StringValue(attr.Key); attrKey{...

so avoids lot's of aws.StringValue(attr.Key) in the error report...
nitpicking too 😸

return a, fmt.Errorf("invalid load balancer attribute value %s=%s", aws.StringValue(attr.Key), aws.StringValue(attr.Value))
}
default:
return a, fmt.Errorf("invalid load balancer attribute %s", aws.StringValue(attr.Key))
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think it should be a warning via log here. Or add another params to the NewAttribute to indicate whether we are build from user's annotation or elbv2's response.

Since AWS elbv2 might adds new default attributes to lb, and our controller will error. We should be forward compatible too

Copy link
Author

Choose a reason for hiding this comment

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

either way the error should be pushed up to fail the reconcile and it will be added with an event and error log there

return fmt.Errorf("failed to retrieve attributes from ELBV2 in AWS: %s", err.Error())
}

current, _ := NewAttributes(raw.Attributes)
Copy link
Collaborator

Choose a reason for hiding this comment

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

ignored error isn't good enough
suppose a default new attribute get added in aws and appears first in attribute list.
All the attributes we get in current will be default inited, and will cause we always modify attributes over and over...


// attributesChangeSet returns a list of elbv2.LoadBalancerAttribute required to change a into b
func attributesChangeSet(a, b *Attributes) (changeSet []*elbv2.LoadBalancerAttribute, ok bool) {
if a.DeletionProtectionEnabled != b.DeletionProtectionEnabled && b.DeletionProtectionEnabled != DeletionProtectionEnabled {
Copy link
Collaborator

Choose a reason for hiding this comment

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

is the default compare desired?
I mean if user changed b.DeletionProtectionEnabled to true(via anno), and then change it back to false.
The a. DeletionProtectionEnabled(on alb) will always stays in true.

If we want to model the concept of optional attribute(like unset), we should use pointers to better model it. e.g. DeletionProtectionEnabled: *bool, which is why aws using *string instead of string. Hope golang got optional[bool] :D

})
}

if len(changeSet) > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

i think we don't need the ok here, we can test for len(changeSet) that used the result of attributesChangeSet.
which is more clear to express the logic ("if changeSet is not empty, then..")
😸

@M00nF1sh
Copy link
Collaborator

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 28, 2018
@k8s-ci-robot k8s-ci-robot merged commit 5a948e5 into master Sep 28, 2018
@bigkraig bigkraig deleted the AttributesController branch October 1, 2018 15:18
bigkraig pushed a commit that referenced this pull request Oct 1, 2018
Created a controller to manage ALB attributes
Shreya027 pushed a commit to Shreya027/aws-load-balancer-controller that referenced this pull request Dec 17, 2021
k8s-ci-robot pushed a commit that referenced this pull request Dec 18, 2021
* Enable setting custom objectSelector for webhook #650

* Add formatting changes

* Add webhook changes to README

* Read update suggestion

* Update READ table header to original
Timothy-Dougherty pushed a commit to adammw/aws-load-balancer-controller that referenced this pull request Nov 9, 2023
* Enable setting custom objectSelector for webhook kubernetes-sigs#650

* Add formatting changes

* Add webhook changes to README

* Read update suggestion

* Update READ table header to original
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants