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

Add wait for master ready before cluster integrations #3035

Merged
merged 1 commit into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/IBM-Cloud/terraform-provider-ibm
go 1.16

require (
github.com/IBM-Cloud/bluemix-go v0.0.0-20210811114147-998a1dd20356
github.com/IBM-Cloud/bluemix-go v0.0.0-20210903091337-e7648c203ed5
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20210705152127-41ca00fc9a62
github.com/IBM-Cloud/power-go-client v1.0.55
github.com/IBM/apigateway-go-sdk v0.0.0-20210714141226-a5d5d49caaca
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/IBM-Cloud/bluemix-go v0.0.0-20210811114147-998a1dd20356 h1:/pq4mzvjZ4c7gGX+EIcjt6WOt8eNWXZjemDxcwFipn4=
github.com/IBM-Cloud/bluemix-go v0.0.0-20210811114147-998a1dd20356/go.mod h1:xhNmnCQsgsDBOyqlfUuIQH6zFomHsqtJYmAmXFkQUwI=
github.com/IBM-Cloud/bluemix-go v0.0.0-20210902134055-e9cf0f844b53 h1:H5AFZHVfV5xD+RthlYhgl+fgN6t7qkJ7diJHsFBbEhY=
github.com/IBM-Cloud/bluemix-go v0.0.0-20210902134055-e9cf0f844b53/go.mod h1:q0fXFSbum/16D8Mgn1ROSfSyX4BmvBCm/hHdcXz0wCU=
github.com/IBM-Cloud/bluemix-go v0.0.0-20210903091337-e7648c203ed5 h1:bqcjvy0tnQjaNxFpg84aJiGF+jBnlEjC9zc2rmy8z+c=
github.com/IBM-Cloud/bluemix-go v0.0.0-20210903091337-e7648c203ed5/go.mod h1:q0fXFSbum/16D8Mgn1ROSfSyX4BmvBCm/hHdcXz0wCU=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20210705152127-41ca00fc9a62 h1:MOkcr6qQGk4tY542ZJ1DggVh2WUP72EEyLB79llFVH8=
github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20210705152127-41ca00fc9a62/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY=
github.com/IBM-Cloud/ibm-cloud-cli-sdk v0.5.3/go.mod h1:RiUvKuHKTBmBApDMUQzBL14pQUGKcx/IioKQPIcRQjs=
Expand Down Expand Up @@ -612,6 +616,7 @@ github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je4
github.com/onsi/gomega v1.14.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0=
github.com/onsi/gomega v1.15.0 h1:WjP/FQ/sk43MRmnEcT+MlDw2TFvkrXlprrPST/IudjU=
github.com/onsi/gomega v1.15.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0=
github.com/onsi/gomega v1.16.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo=
github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys=
Expand Down
2 changes: 1 addition & 1 deletion ibm/resource_ibm_container_vpc_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ func waitForVpcClusterMasterAvailable(d *schema.ResourceData, meta interface{})
clusterInfo, clusterInfoErr := csClient.Clusters().GetCluster(clusterID, targetEnv)

if err != nil || clusterInfoErr != nil {
return clusterInfo, deployInProgress, err
return clusterInfo, deployInProgress, clusterInfoErr
}

if clusterInfo.Lifecycle.MasterStatus == ready {
Expand Down
36 changes: 35 additions & 1 deletion ibm/resource_ibm_ob_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func resourceIBMObLogging() *schema.Resource {
Importer: &schema.ResourceImporter{},

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Create: schema.DefaultTimeout(45 * time.Minute),
Update: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
},
Expand Down Expand Up @@ -116,6 +116,35 @@ func resourceIBMObLogging() *schema.Resource {
},
}
}
func waitForClusterIntegration(d *schema.ResourceData, meta interface{}, clusterID string) (interface{}, error) {
targetEnv, err := getVpcClusterTargetHeader(d, meta)
if err != nil {
return nil, err
}
csClient, err := meta.(ClientSession).VpcContainerAPI()
if err != nil {
return nil, err
}

stateConf := &resource.StateChangeConf{
Pending: []string{deployRequested, deployInProgress},
Target: []string{ready},
Refresh: func() (interface{}, string, error) {
clusterFields, err := csClient.Clusters().GetCluster(clusterID, targetEnv)
if err != nil {
return nil, "", fmt.Errorf("[ERROR] Error retrieving cluster: %s", err)
}
if clusterFields.Lifecycle.MasterStatus == ready || clusterFields.MasterStatus == ready {
return clusterFields, ready, nil
}
return clusterFields, deployInProgress, nil
},
Timeout: d.Timeout(schema.TimeoutCreate),
Delay: 10 * time.Second,
MinTimeout: 10 * time.Second,
}
return stateConf.WaitForState()
}

func resourceIBMLoggingCreate(d *schema.ResourceData, meta interface{}) error {
client, err := meta.(ClientSession).VpcContainerAPI()
Expand All @@ -128,6 +157,11 @@ func resourceIBMLoggingCreate(d *schema.ResourceData, meta interface{}) error {

//Read cluster ID and logging instanceID
clusterName := d.Get(obLoggingCluster).(string)
_, err = waitForClusterIntegration(d, meta, clusterName)
if err != nil {
return fmt.Errorf("[ERROR] Error waiting for master node to be availabe before integrating Logging Instance: %s", err)
}

loggingInstanceID := d.Get(obLoggingInstanceID).(string)

//Read Ingestionkey
Expand Down
6 changes: 5 additions & 1 deletion ibm/resource_ibm_ob_monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func resourceIBMObMonitoring() *schema.Resource {
Importer: &schema.ResourceImporter{},

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Create: schema.DefaultTimeout(45 * time.Minute),
Update: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
},
Expand Down Expand Up @@ -129,6 +129,10 @@ func resourceIBMMonitoringCreate(d *schema.ResourceData, meta interface{}) error

//Read cluster ID and sysdif instanceID
clusterName := d.Get(obMonitoringCluster).(string)
_, err = waitForClusterIntegration(d, meta, clusterName)
if err != nil {
return fmt.Errorf("[ERROR] Error waiting for master node to be availabe before integrating Monitoring Instance: %s", err)
}
sysdigInstanceID := d.Get(obMonitoringInstanceID).(string)

//Read Ingestionkey
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/ob_logging.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ resource "ibm_ob_logging" "test2" {

The `ibm_ob_logging` provides the following [Timeouts](https://www.terraform.io/docs/language/resources/syntax.html) configuration options:

- **create**: The enablement of the feature is considered `failed` if no response is received for 10 minutes.
- **create**: The enablement of the feature is considered `failed` if no response is received for 45 minutes.
- **delete**: The delete of the feature is considered `failed` if no response is received for 10 minutes.
- **update**: The update of the feature is considered `failed` if no response is received for 10 minutes.

Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/ob_monitoring.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ resource "ibm_ob_monitoring" "test2" {

ibm_ob_monitoring provides the following [Timeouts](https://www.terraform.io/docs/language/resources/syntax.html) configuration options:

- **create**: The enablement of the feature is considered `failed` if no response is received for 10 minutes.
- **create**: The enablement of the feature is considered `failed` if no response is received for 45 minutes.
- **delete**: The delete of the feature is considered `failed` if no response is received for 10 minutes.
- **update**: The update of the feature is considered `failed` if no response is received for 10 minutes.

Expand Down