Skip to content

fix(monitor): [122656438] modify read return #3249

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

Merged
merged 4 commits into from
Mar 28, 2025
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
43 changes: 43 additions & 0 deletions .changelog/3249.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
```release-note:enhancement
resource/tencentcloud_monitor_tmp_alert_rule: Modify the query to be empty without error.
```

```release-note:enhancement
resource/tencentcloud_monitor_tmpCvmAgent: Modify the query to be empty without error.
```

```release-note:enhancement
resource/tencentcloud_monitor_tmp_exporter_integration: Modify the query to be empty without error.
```

```release-note:enhancement
resource/tencentcloud_tmp_monitor_recording_rule: Modify the query to be empty without error.
```

```release-note:enhancement
resource/tencentcloud_monitor_tmpScrapeJob: Modify the query to be empty without error.
```

```release-note:enhancement
resource/tencentcloud_tke_tmp_alert_policy: Modify the query to be empty without error.
```

```release-note:enhancement
resource/tencentcloud_monitor_tmp_tke_cluster_agent: Modify the query to be empty without error.
```

```release-note:enhancement
resource/tencentcloud_tke_tmp_config: Modify the query to be empty without error.
```

```release-note:enhancement
resource/tencentcloud_monitor_tmp_tke_global_notification: Modify the query to be empty without error.
```

```release-note:enhancement
resource/tencentcloud_monitor_tmp_tke_template: Modify the query to be empty without error.
```

```release-note:enhancement
resource/tencentcloud_monitor_tmp_tke_template_attachment: Modify the query to be empty without error.
```
10 changes: 5 additions & 5 deletions tencentcloud/acctest/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,14 @@ variable "international_subnet_id" {
// Tke Exclusive Network Environment
const (
TkeExclusiveVpcName = "keep_tke_exclusive_vpc"
DefaultTkeClusterId = "cls-r8gqwjw6"
DefaultTkeClusterId = "cls-2weetaxi"
DefaultTkeClusterName = "keep-tke-cluster"
DefaultTkeClusterType = "tke"
DefaultPrometheusId = "prom-1lspn8sw"
DefaultPrometheusId = "prom-9ywsz034"
DefaultTemplateId = "temp-gqunlvo1"
ClusterPrometheusId = "prom-g261hacc"
TkeClusterIdAgent = "cls-9ae9qo9k"
TkeClusterTypeAgent = "eks"
ClusterPrometheusId = "prom-9ywsz034"
TkeClusterIdAgent = "cls-2weetaxi"
TkeClusterTypeAgent = "tke"
DefaultAgentId = "agent-q3zy8gt8"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ resource "tencentcloud_monitor_tmp_alert_group" "tmp_alert_group" {
"notice-om017kc2",
]
group_name = "tf-test"
instance_id = tencentcloud_monitor_tmp_instance.basic.id
instance_id = tencentcloud_monitor_tmp_instance.example.id
repeat_interval = "5m"

custom_receiver {
Expand Down Expand Up @@ -145,7 +145,7 @@ resource "tencentcloud_monitor_tmp_alert_group" "tmp_alert_group" {
"notice-om017kc2",
]
group_name = "tf-test-up"
instance_id = tencentcloud_monitor_tmp_instance.basic.id
instance_id = tencentcloud_monitor_tmp_instance.example.id
repeat_interval = "1h"

custom_receiver {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ func resourceTencentCloudMonitorTmpAlertRuleRead(d *schema.ResourceData, meta in

if tmpAlertRule == nil {
d.SetId("")
return fmt.Errorf("resource `tmpAlertRule` %s does not exist", ids[1])
log.Printf("[WARN]%s resource `tmpAlertRule` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
return nil
}

_ = d.Set("instance_id", ids[0])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func testAccCheckAlertRuleExists(r string) resource.TestCheckFunc {

const testAlertRule_basic = testInstance_basic + `
resource "tencentcloud_monitor_tmp_alert_rule" "basic" {
instance_id = tencentcloud_monitor_tmp_instance.basic.id
instance_id = tencentcloud_monitor_tmp_instance.example.id
rule_name = "test-rule_name"
receivers = ["notice-tj75hgqj"]
expr = "increase(mysql_global_status_slow_queries[1m]) > 0"
Expand All @@ -143,7 +143,7 @@ resource "tencentcloud_monitor_tmp_alert_rule" "basic" {

const testAlertRule_update = testInstance_basic + `
resource "tencentcloud_monitor_tmp_alert_rule" "basic" {
instance_id = tencentcloud_monitor_tmp_instance.basic.id
instance_id = tencentcloud_monitor_tmp_instance.example.id
rule_name = "test-rule_name_update"
receivers = ["notice-tj75hgqj"]
expr = "increase(mysql_global_status_slow_queries[1m]) > 1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ func resourceTencentCloudMonitorTmpCvmAgentRead(d *schema.ResourceData, meta int

if tmpCvmAgent == nil {
d.SetId("")
return fmt.Errorf("resource `tmpCvmAgent` %s does not exist", ids[1])
log.Printf("[WARN]%s resource `tmpCvmAgent` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
return nil
}

if tmpCvmAgent.InstanceId != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ func resourceTencentCloudMonitorTmpExporterIntegrationRead(d *schema.ResourceDat

if tmpExporterIntegration == nil {
d.SetId("")
return fmt.Errorf("resource `tmpExporterIntegration` %s does not exist", tmpExporterIntegrationId)
log.Printf("[WARN]%s resource `tmpExporterIntegration` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
return nil
}

if tmpExporterIntegration.Kind != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ func resourceTencentCloudMonitorTmpRecordingRuleRead(d *schema.ResourceData, met

if recordingRule == nil {
d.SetId("")
return fmt.Errorf("resource `recordingRule` %s does not exist", ids[1])
log.Printf("[WARN]%s resource `recordingRule` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
return nil
}

_ = d.Set("instance_id", ids[0])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ func resourceTencentCloudMonitorTmpScrapeJobRead(d *schema.ResourceData, meta in

if tmpScrapeJob == nil {
d.SetId("")
return fmt.Errorf("resource `tmpScrapeJob` %s does not exist", tmpScrapeJobId)
log.Printf("[WARN]%s resource `tmpScrapeJob` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
return nil
}

_ = d.Set("instance_id", strings.Split(tmpScrapeJobId, tccommon.FILED_SP)[1])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@ func resourceTencentCloudTkeTmpAlertPolicyRead(d *schema.ResourceData, meta inte
log.Printf("[DEBUG] tmpAlertPolicy[%v]\n", tmpAlertPolicy)
if tmpAlertPolicy == nil {
d.SetId("")
return fmt.Errorf("resource `AlertPolicy` %s does not exist", tmpAlertPolicyId)
log.Printf("[WARN]%s resource `AlertPolicy` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
return nil
}

rules := make([]map[string]interface{}, 0, len(tmpAlertPolicy.Rules))
Expand Down Expand Up @@ -490,13 +491,15 @@ func resourceTencentCloudTkeTmpAlertPolicyRead(d *schema.ResourceData, meta inte
}

notify := tmpAlertPolicy.Notification
alertManager := map[string]interface{}{
"url": notify.AlertManager.Url,
"cluster_type": notify.AlertManager.ClusterType,
"cluster_id": notify.AlertManager.ClusterId,
}
var alertManagers []map[string]interface{}
alertManagers = append(alertManagers, alertManager)
if notify.AlertManager != nil {
alertManager := map[string]interface{}{
"url": notify.AlertManager.Url,
"cluster_type": notify.AlertManager.ClusterType,
"cluster_id": notify.AlertManager.ClusterId,
}
alertManagers = append(alertManagers, alertManager)
}

var notifyWay []string
if len(notify.NotifyWay) > 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ func resourceTencentCloudMonitorTmpTkeClusterAgentRead(d *schema.ResourceData, m

if clusterAgent == nil {
d.SetId("")
return fmt.Errorf("resource `global_notification` %s does not exist", instanceId)
log.Printf("[WARN]%s resource `cluster_agent` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
return nil
}

var agents []map[string]interface{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package tmp

import (
"context"
"fmt"
"log"
"strings"

Expand Down Expand Up @@ -141,7 +140,8 @@ func resourceTencentCloudTkeTmpConfigRead(d *schema.ResourceData, meta interface

if params == nil {
d.SetId("")
return fmt.Errorf("resource `prometheus_config` %s does not exist", configId)
log.Printf("[WARN]%s resource `prometheus_config` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
return nil
}

if e := d.Set("config", params.Config); e != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package tmp

import (
"context"
"fmt"
"log"

tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
svcmonitor "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/services/monitor"
Expand Down Expand Up @@ -176,7 +176,8 @@ func resourceTencentCloudMonitorTmpTkeGlobalNotificationRead(d *schema.ResourceD

if globalNotification == nil {
d.SetId("")
return fmt.Errorf("resource `global_notification` %s does not exist", instanceId)
log.Printf("[WARN]%s resource `global_notification` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
return nil
}

if *globalNotification.Enabled {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package tmp

import (
"context"
"fmt"
"log"

tccommon "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/common"
Expand Down Expand Up @@ -332,7 +331,8 @@ func resourceTencentCloudMonitorTmpTkeTemplateRead(d *schema.ResourceData, meta

if template == nil {
d.SetId("")
return fmt.Errorf("resource `template` %s does not exist", templateId)
log.Printf("[WARN]%s resource `template` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
return nil
}

templates := make([]map[string]interface{}, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ func resourceTencentCloudMonitorTmpTkeTemplateAttachmentRead(d *schema.ResourceD

if targets == nil || len(targets) < 1 {
d.SetId("")
return fmt.Errorf("resource `targets` %s does not exist", templateId)
log.Printf("[WARN]%s resource `targets` [%s] not found, please check if it has been deleted.\n", logId, d.Id())
return nil
}

tempTargets := make([]map[string]interface{}, 0)
Expand Down
Loading