-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
Support setting azure LB idle timeout #66045
Conversation
/assign @khenidak |
@@ -1280,7 +1304,8 @@ func equalLoadBalancingRulePropertiesFormat(s, t *network.LoadBalancingRulePrope | |||
reflect.DeepEqual(s.LoadDistribution, t.LoadDistribution) && | |||
reflect.DeepEqual(s.FrontendPort, t.FrontendPort) && | |||
reflect.DeepEqual(s.BackendPort, t.BackendPort) && | |||
reflect.DeepEqual(s.EnableFloatingIP, t.EnableFloatingIP) | |||
reflect.DeepEqual(s.EnableFloatingIP, t.EnableFloatingIP) && | |||
s.IdleTimeoutInMinutes == t.IdleTimeoutInMinutes |
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.
Of course this doesn't work as expected because it's a pointer.
/ok-to-test |
@@ -74,6 +74,10 @@ const ( | |||
// ServiceAnnotationAllowedServiceTag is the annotation used on the service | |||
// to specify a list of allowed service tags separated by comma | |||
ServiceAnnotationAllowedServiceTag = "service.beta.kubernetes.io/azure-allowed-service-tags" | |||
|
|||
// ServiceAnnotationLoadBalancerIdleTimeout is the annotation used on the service | |||
// to specify the idle timeout for connections on the load balancer. |
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.
The timeout is in minutes?
nit: s/the idle timeout/the idle timeout in minutes/
LGTM in general. @cpuguy83 Could you document the timeout unit clearly? |
@@ -487,6 +505,11 @@ func (az *Cloud) reconcileLoadBalancer(clusterName string, service *v1.Service, | |||
lbBackendPoolName := getBackendPoolName(clusterName) | |||
lbBackendPoolID := az.getBackendPoolID(lbName, lbBackendPoolName) | |||
|
|||
lbIdleTimeout, err := getIdleTimeout(service) |
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.
so what if there is no service.beta.kubernetes.io/azure-load-balancer-idle-timeout
setting, it will return nil, nil
, are we going to handle that? And what if it's a negative?
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.
We want nil, nil
in this case as this will set the LB timeout to the default value. I will add a check here to see if the key even exists and only return nil when it does not, and a separate error case for when it does exist but the value is 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.
For validation of the value beyond if it converts to an int... I didn't want to do too much validation here as I expect the backend to deal with this, but I do see value in validating here since they are fairly hard values that are well documented (or at least were easy for me to find), which saves us a failed request.
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.
This is all updated
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.
Thanks. The range is [4,30]
/test pull-kubernetes-integration |
@@ -74,6 +74,10 @@ const ( | |||
// ServiceAnnotationAllowedServiceTag is the annotation used on the service | |||
// to specify a list of allowed service tags separated by comma | |||
ServiceAnnotationAllowedServiceTag = "service.beta.kubernetes.io/azure-allowed-service-tags" | |||
|
|||
// ServiceAnnotationLoadBalancerIdleTimeout is the annotation used on the service | |||
// to specify the idle timeout for connections on the load balancer in miutes. |
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.
typo miutes
FrontendPort: to.Int32Ptr(port.Port), | ||
BackendPort: to.Int32Ptr(port.Port), | ||
EnableFloatingIP: to.BoolPtr(true), | ||
IdleTimeoutInMinutes: lbIdleTimeout, |
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.
IdleTimeoutInMinutes only applies to TCP protocol. Could you also add a check and only set it when transportProto is TCP?
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.
Yep, also updated annotation name to clarify that.
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.
@cpuguy83
could you also write a unit test for getIdleTimeout
func?
min = 4 | ||
max = 30 | ||
) | ||
errInvalidTimeout := fmt.Errorf("idle timeout value must be a whole number representing minutes between %d and %d", min, max) |
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.
no need to define a var here, put it under
return nil, fmt.Errorf("idle timeout value must be a whole number representing minutes between %d and %d", min, max)
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'm using this multiple times.
// Return a nil here as this will set the value to the azure default | ||
return nil, nil | ||
} | ||
if val == "" { |
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 it necessary to check here since below code would still parse val
:
to, err := strconv.Atoi(val)
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.
Not necessary, removing this explicit check.
8cbf2ca
to
8000342
Compare
/test pull-kubernetes-e2e-gce-100-performance |
Adds a new annotation to allow users to configure the idle timeout of the Azure LB.
/test pull-kubernetes-integration |
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
would you take a another look @feiskyer ?
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andyzhangx, cpuguy83, feiskyer 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 |
Automatic merge from submit-queue (batch tested with PRs 66121, 66140, 66045). If you want to cherry-pick this change to another branch, please follow the instructions here. |
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.
Thanks, lgtm
@cpuguy83 PR got merged. Could you also file a PR to cloud-provider-azure and add docs for the new annotation? |
/sig azure |
…45-upstream-release-1.11 Automated cherry pick of #66045: Support setting azure LB idle timeout
What this PR does / why we need it:
Adds a new annotation to allow users to configure the idle timeout of
the Azure LB.
Release note: