@@ -145,6 +145,11 @@ func resourceTencentCloudMonitorTmpExporterIntegrationCreate(d *schema.ResourceD
145
145
log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " ,
146
146
logId , request .GetAction (), request .ToJsonString (), result .ToJsonString ())
147
147
}
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
+
148
153
response = result
149
154
return nil
150
155
})
@@ -154,10 +159,37 @@ func resourceTencentCloudMonitorTmpExporterIntegrationCreate(d *schema.ResourceD
154
159
return err
155
160
}
156
161
162
+ if len (response .Response .Names ) < 1 {
163
+ return fmt .Errorf ("Names is nil." )
164
+ }
165
+
157
166
tmpExporterIntegrationId := * response .Response .Names [0 ]
158
167
159
168
d .SetId (strings .Join ([]string {tmpExporterIntegrationId , instanceId , strconv .Itoa (kubeType ), clusterId , kind }, tccommon .FILED_SP ))
160
169
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
+
161
193
return resourceTencentCloudMonitorTmpExporterIntegrationRead (d , meta )
162
194
}
163
195
0 commit comments