Skip to content

Commit

Permalink
Allow unseting session persistence and healthmonitor on lb pool
Browse files Browse the repository at this point in the history
  • Loading branch information
lapson97 committed Jan 16, 2024
1 parent a7f9d10 commit 959d27f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
17 changes: 17 additions & 0 deletions gcore/resource_gcore_lbpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,28 @@ func resourceLBPoolUpdate(ctx context.Context, d *schema.ResourceData, m interfa
if d.HasChange("health_monitor") {
opts.HealthMonitor = extractHealthMonitorMap(d)
change = true
if opts.HealthMonitor == nil {
lbpools.DeleteHealthMonitor(client, d.Id())
}
}

if d.HasChange("session_persistence") {
opts.SessionPersistence = extractSessionPersistenceMap(d)
change = true
if opts.SessionPersistence == nil {
results, err := lbpools.Unset(client, d.Id(), lbpools.UnsetOpts{SessionPersistence: true}).Extract()
if err != nil {
return diag.FromErr(err)
}
taskID := results.Tasks[0]
_, err = tasks.WaitTaskAndReturnResult(client, taskID, true, LBPoolsCreateTimeout, func(task tasks.TaskID) (interface{}, error) {
_, err := tasks.Get(client, string(task)).Extract()
if err != nil {
return nil, fmt.Errorf("cannot get task with ID: %s. Error: %w", task, err)
}
return nil, nil
})
}
}

if !change {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/G-Core/gcore-dns-sdk-go v0.2.7-0.20230801110428-99ef24b50d4d
github.com/G-Core/gcore-storage-sdk-go v0.1.34
github.com/G-Core/gcorelabscdn-go v1.0.3
github.com/G-Core/gcorelabscloud-go v0.6.27
github.com/G-Core/gcorelabscloud-go v0.6.28
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk/v2 v2.27.0
github.com/mitchellh/mapstructure v1.5.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ github.com/G-Core/gcorelabscdn-go v1.0.1 h1:BsGnLIiH7nhvSwDLgnsaXIPIJZG6hpTsqeYP
github.com/G-Core/gcorelabscdn-go v1.0.1/go.mod h1:iSGXaTvZBzDHQW+rKFS918BgFVpONcyLEijwh8WsXpE=
github.com/G-Core/gcorelabscdn-go v1.0.3 h1:fBIhDNLqfKVQV7ycqhgNeyg4Pzn5LIl5yah556lAlj4=
github.com/G-Core/gcorelabscdn-go v1.0.3/go.mod h1:iSGXaTvZBzDHQW+rKFS918BgFVpONcyLEijwh8WsXpE=
github.com/G-Core/gcorelabscloud-go v0.6.27 h1:yB92rTEXqXC0oc/0UcqBlQbWUV1PbqP/EhDImBq7CQ8=
github.com/G-Core/gcorelabscloud-go v0.6.27/go.mod h1:13Z1USxlxPbDFuYQyWqfNexlk4kUvOYTXbnvV/Z1lZo=
github.com/G-Core/gcorelabscloud-go v0.6.28 h1:o6rdeRNUr/k8ggJuMU/Fm7ZkO2k01TSdtXsjQtJqJZQ=
github.com/G-Core/gcorelabscloud-go v0.6.28/go.mod h1:13Z1USxlxPbDFuYQyWqfNexlk4kUvOYTXbnvV/Z1lZo=
github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI=
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8=
Expand Down

0 comments on commit 959d27f

Please sign in to comment.