Skip to content

Commit 4a58f3a

Browse files
committed
add
1 parent 79525ad commit 4a58f3a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tencentcloud/services/tmp/resource_tc_monitor_tmp_exporter_integration.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ func resourceTencentCloudMonitorTmpExporterIntegrationCreate(d *schema.ResourceD
145145
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
146146
logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
147147
}
148+
149+
if result == nil || result.Response == nil || response.Response.Names == nil {
150+
return resource.NonRetryableError(fmt.Errorf("Create monitor tmpExporterIntegration failed, Response is nil."))
151+
}
152+
148153
response = result
149154
return nil
150155
})
@@ -154,10 +159,37 @@ func resourceTencentCloudMonitorTmpExporterIntegrationCreate(d *schema.ResourceD
154159
return err
155160
}
156161

162+
if len(response.Response.Names) < 1 {
163+
return fmt.Errorf("Names is nil.")
164+
}
165+
157166
tmpExporterIntegrationId := *response.Response.Names[0]
158167

159168
d.SetId(strings.Join([]string{tmpExporterIntegrationId, instanceId, strconv.Itoa(kubeType), clusterId, kind}, tccommon.FILED_SP))
160169

170+
// wait
171+
err = resource.Retry(8*tccommon.ReadRetryTimeout, func() *resource.RetryError {
172+
results, errRet := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseMonitorClient().DescribePrometheusInstanceInitStatus(initStatus)
173+
if errRet != nil {
174+
return tccommon.RetryError(errRet, tccommon.InternalError)
175+
}
176+
177+
status := results.Response.Status
178+
if status == nil {
179+
return resource.NonRetryableError(fmt.Errorf("prometheusInstanceInit status is nil, operate failed"))
180+
}
181+
182+
if *status == "running" {
183+
return nil
184+
}
185+
186+
return resource.RetryableError(fmt.Errorf("prometheusInstanceInit status is %s", *status))
187+
})
188+
189+
if err != nil {
190+
return err
191+
}
192+
161193
return resourceTencentCloudMonitorTmpExporterIntegrationRead(d, meta)
162194
}
163195

0 commit comments

Comments
 (0)