Skip to content

Commit

Permalink
Idle Connection Timeout FIx
Browse files Browse the repository at this point in the history
  • Loading branch information
SunithaGudisagarIBM1 authored and hkantare committed Apr 11, 2023
1 parent 9bae8b9 commit bd42051
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
3 changes: 3 additions & 0 deletions ibm/service/vpc/data_source_ibm_is_lb_listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ func dataSourceLoadBalancerListenerCollectionListenersToMap(listenersItem vpcv1.
if listenersItem.ConnectionLimit != nil {
listenersMap["connection_limit"] = listenersItem.ConnectionLimit
}
if listenersItem.IdleConnectionTimeout != nil {
listenersMap[isLBListenerIdleConnectionTimeout] = listenersItem.IdleConnectionTimeout
}
if listenersItem.CreatedAt != nil {
listenersMap["created_at"] = listenersItem.CreatedAt.String()
}
Expand Down
19 changes: 8 additions & 11 deletions ibm/service/vpc/resource_ibm_is_lb_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,6 @@ func resourceIBMISLBListenerCreate(d *schema.ResourceData, meta interface{}) err
defPool = lbPool
}

var idleConnectionTimeout int64
if idleconnectiontimeout, ok := d.GetOk(isLBListenerIdleConnectionTimeout); ok {
idleConnectionTimeout = int64(idleconnectiontimeout.(int))
}
if crn, ok := d.GetOk(isLBListenerCertificateInstance); ok {
certificateCRN = crn.(string)
}
Expand Down Expand Up @@ -262,15 +258,15 @@ func resourceIBMISLBListenerCreate(d *schema.ResourceData, meta interface{}) err
conns.IbmMutexKV.Lock(isLBKey)
defer conns.IbmMutexKV.Unlock(isLBKey)

err := lbListenerCreate(d, meta, lbID, protocol, defPool, certificateCRN, listener, uri, port, portMin, portMax, connLimit, httpStatusCode, idleConnectionTimeout)
err := lbListenerCreate(d, meta, lbID, protocol, defPool, certificateCRN, listener, uri, port, portMin, portMax, connLimit, httpStatusCode)
if err != nil {
return err
}

return resourceIBMISLBListenerRead(d, meta)
}

func lbListenerCreate(d *schema.ResourceData, meta interface{}, lbID, protocol, defPool, certificateCRN, listener, uri string, port, portMin, portMax, connLimit, httpStatusCode, idleConnectionTimeout int64) error {
func lbListenerCreate(d *schema.ResourceData, meta interface{}, lbID, protocol, defPool, certificateCRN, listener, uri string, port, portMin, portMax, connLimit, httpStatusCode int64) error {
sess, err := vpcClient(meta)
if err != nil {
return err
Expand Down Expand Up @@ -322,10 +318,10 @@ func lbListenerCreate(d *schema.ResourceData, meta interface{}, lbID, protocol,
}
}
}
if strings.EqualFold(*lb.Profile.Family, "application") {
if idleconnectiontimeout, ok := d.GetOk(isLBListenerIdleConnectionTimeout); ok {
idleConnectionTimeout := int64(idleconnectiontimeout.(int))
options.IdleConnectionTimeout = &idleConnectionTimeout
}

if app, ok := d.GetOk(isLBListenerAcceptProxyProtocol); ok {
acceptProxyProtocol := app.(bool)
options.AcceptProxyProtocol = &acceptProxyProtocol
Expand Down Expand Up @@ -480,12 +476,13 @@ func lbListenerGet(d *schema.ResourceData, meta interface{}, lbID, lbListenerID
d.Set(isLBListenerConnectionLimit, *lbListener.ConnectionLimit)
}
d.Set(isLBListenerStatus, *lbListener.ProvisioningStatus)
getLoadBalancerOptions := &vpcv1.GetLoadBalancerOptions{
ID: &lbID,
}

if lbListener.IdleConnectionTimeout != nil {
d.Set(isLBListenerIdleConnectionTimeout, *lbListener.IdleConnectionTimeout)
}
getLoadBalancerOptions := &vpcv1.GetLoadBalancerOptions{
ID: &lbID,
}
lb, response, err := sess.GetLoadBalancer(getLoadBalancerOptions)
if err != nil {
return fmt.Errorf("[ERROR] Error Getting Load Balancer : %s\n%s", err, response)
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/is_lb_listener.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ In addition to all argument references listed, you can access the following attr
- `id` - (String) The unique identifier for this load balancer listener.
- `uri` - (String) The redirect relative target URI.

- `idle_connection_timeout` - The idle connection timeout of the listener in seconds. This property will be present for load balancers in the `application` family. Default value is `50`.
- `idle_connection_timeout` - (Integer) The idle connection timeout of the listener in seconds. This property will be present for load balancers in the `application` family. Default value is `50`.

- `policies` - (List) The policies for this listener.
Nested scheme for `policies`:
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/is_lb_listeners.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ In addition to all argument references listed, you can access the following attr
- `id` - (String) The unique identifier for this load balancer listener.
- `uri` - (String) The redirect relative target URI.
- `id` - (String) The unique identifier for this load balancer listener.
- `idle_connection_timeout` - The idle connection timeout of the listener in seconds. This property will be present for load balancers in the `application` family. Default value is `50`.
- `idle_connection_timeout` - (Integer) The idle connection timeout of the listener in seconds. This property will be present for load balancers in the `application` family. Default value is `50`.
- `policies` - (List) The policies for this listener.
Nested scheme for `policies`:
- `deleted` - (List) If present, this property indicates the referenced resource has been deleted and providessome supplementary information.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/is_lb_listener.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Review the argument references that you can specify for your resource.
- `https_redirect_listener` - (Optional, String) ID of the listener that will be set as http redirect target.
- `https_redirect_status_code` - (Optional, Integer) The HTTP status code to be returned in the redirect response, one of [301, 302, 303, 307, 308].
- `https_redirect_uri` - (Optional, String) Target URI where traffic will be redirected.
- `idle_connection_timeout` - (Optional, Integer) The idle connection timeout of the listener in seconds. This property will be present for load balancers in the `application` family. Default value is `50`.
- `idle_connection_timeout` - (Optional, Integer) The idle connection timeout of the listener in seconds. Supported for load balancers in the `application` family. Default value is `50`, allowed value is between `50` - `7200`.

## Attribute reference
In addition to all argument reference list, you can access the following attribute reference after your resource is created.
Expand Down

0 comments on commit bd42051

Please sign in to comment.