aliyun / terraform-provider-alicloud

Terraform AliCloud provider
https://www.terraform.io/docs/providers/alicloud/
Mozilla Public License 2.0
589 stars 553 forks source link

alicloud_logtail_config resource create success but update failed #3824

Open fatedier opened 3 years ago

fatedier commented 3 years ago

Terraform Version

v1.0.0

Affected Resource(s)

Please list the resources as a list, for example:

Terraform Configuration Files

resource "alicloud_logtail_config" "ingress_istio" {
  project      = alicloud_log_project.project.name
  logstore     = alicloud_log_store.ingress_istio.name
  input_type   = "plugin"
  name         = "ingress_istio"
  output_type  = "LogService"
  input_detail = <<DEFINITION
    {
        "plugin": {
            "inputs": [
                {
                    "detail": {
                        "Stderr": true,
                        "IncludeLabel": {
                            "io.kubernetes.container.name": "istio-proxy"
                        },
                        "Stdout": true
                    },
                    "type": "service_docker_stdout"
                }
            ],
            "processors": [
                {
                    "detail": {
                        "KeepSource": false,
                        "NoMatchError": false,
                        "Keys": [
                            "time_local",
                            "method",
                            "uri",
                            "protocol",
                            "response_code",
                            "response_flags",
                            "response_code_details",
                            "connect_termination_details",
                            "upstream_transport_fail_reason",
                            "bytes_received",
                            "bytes_sent",
                            "duration",
                            "upstream_service_time",
                            "x_forwarder_for",
                            "user_agent",
                            "x_request_id",
                            "host",
                            "upstream_addr",
                            "upstream_cluster",
                            "upstream_local_addr",
                            "downstream_local_addr",
                            "downstream_remote_addr",
                            "server_name",
                            "route_name",
                            "grpc_status"
                        ],
                        "SourceKey": "content",
                        "Regex": "\\[([^\\s]+)\\]\\s+\"([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\"\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+\"([^\"]+)\"\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+\"([^\"]+)\"\\s+\"([^\"]+)\"\\s+\"([^\"]+)\"\\s+\"([^\"]+)\"\\s+\"([^\"]+)\"\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s([^\\s]+)\\s+\"([^\"]+)\".*",
                        "NoKeyError": true
                    },
                    "type": "processor_regex"
                }
            ]
        }
    }
    DEFINITION
}

Expected Behavior

Update success.

Actual Behavior

Error: [31m[ERROR][0m terraform-provider-alicloud/alicloud/resource_alicloud_logtail_config.go:200: Resource tap-server-sh:ingress-istio:ingress_istio UpdateConfig Failed!!! [SDK aliyun-log-go-sdk ERROR]:
{
    "httpCode": 400,
    "errorCode": "PostBodyInvalid",
    "errorMessage": "inputDetail is of error type or lacking",
    "requestID": "61134CB85E09B87DB3428B3F"
}

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply to create a new alicloud_logtail_config.
  2. Update input_detail.processors.Regex
  3. terraform plan with no error.
  4. terraform apply return the 400 error.
tiankai66 commented 3 years ago

Your feedback has been received. We will process it as soon as possible. Thank you for your trust and support of Alibaba Cloud!

fatedier commented 3 years ago

@tiankai66 Could you confirm this is a bug?

tiankai66 commented 3 years ago

Hello, I make a test in my env. it works fine. You make some mistake in the json: "route_name" "route_name", two route_name here and missing "," in the format. Thanks and best regards,

fatedier commented 3 years ago

@tiankai66 It's just a copy mistake, not the root casuse. I will edit it to the correct one.

Any information i can provide to help you investigate this problem?

tiankai66 commented 3 years ago

Sample code(default setting and using your json, result: success): resource "alicloud_log_project" "example" { name = "test-tf" description = "create by terraform" }

resource "alicloud_log_store" "example" { project = alicloud_log_project.example.name name = "tf-test-logstore" retention_period = 3650 shard_count = 3 auto_split = true max_split_shard_count = 60 append_meta = true }

resource "alicloud_logtail_config" "example" { project = alicloud_log_project.example.name logstore = alicloud_log_store.example.name input_type = "plugin" name = "ingress_istio" output_type = "LogService" input_detail = file("config.json") }

fatedier commented 3 years ago

input_detail = file("config.json")

I'm not sure if this difference will affect the result?

Do you modify some content and update it? I also create success but update failed.

tiankai66 commented 3 years ago

hi. nothing changes. if you want to fill the json in the input, full code as follow, works fine: resource "alicloud_log_project" "example" { name = "test-tf" description = "create by terraform" }

resource "alicloud_log_store" "example" { project = alicloud_log_project.example.name name = "tf-test-logstore" retention_period = 3650 shard_count = 3 auto_split = true max_split_shard_count = 60 append_meta = true }

resource "alicloud_logtail_config" "example" { project = alicloud_log_project.example.name logstore = alicloud_log_store.example.name input_type = "plugin" name = "ingress_istio" output_type = "LogService" input_detail = " { "plugin": { "inputs": [ { "detail": { "Stderr": true, "IncludeLabel": { "io.kubernetes.container.name": "istio-proxy" }, "Stdout": true }, "type": "service_docker_stdout" } ], "processors": [ { "detail": { "KeepSource": false, "NoMatchError": false, "Keys": [ "time_local", "method", "uri", "protocol", "response_code", "response_flags", "response_code_details", "connect_termination_details", "upstream_transport_fail_reason", "bytes_received", "bytes_sent", "duration", "upstream_service_time", "x_forwarder_for", "user_agent", "x_request_id", "host", "upstream_addr", "upstream_cluster", "upstream_local_addr", "downstream_local_addr", "downstream_remote_addr", "server_name", "route_name", "grpc_status" ], "SourceKey": "content", "Regex": "\[([^\s]+)\]\s+\"([^\s]+)\s+([^\s]+)\s+([^\s]+)\"\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+\"([^\"]+)\"\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+\"([^\"]+)\"\s+\"([^\"]+)\"\s+\"([^\"]+)\"\s+\"([^\"]+)\"\s+\"([^\"]+)\"\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s([^\s]+)\s+\"([^\"]+)\".*", "NoKeyError": true }, "type": "processor_regex" } ] } } " }

fatedier commented 3 years ago

@tiankai66 Hi, i fixed this bug in https://github.com/aliyun/terraform-provider-alicloud/pull/3866, you can review it now.

HuiJing-C commented 3 years ago

@fatedier The input_detail format is wrong, the correct one should be { "inputs": [ { "detail": { "Stderr": true, "IncludeLabel": { "io.kubernetes.container.name": "istio-proxy" }, "Stdout": true }, "type": "service_docker_stdout" } ], "processors": [ { "detail": { "KeepSource": false, "NoMatchError": false, "Keys": [ "time_local", "method", "uri", "protocol", "response_code", "response_flags", "response_code_details", "connect_termination_details", "upstream_transport_fail_reason", "bytes_received", "bytes_sent", "duration", "upstream_service_time", "x_forwarder_for", "user_agent", "x_request_id", "host", "upstream_addr", "upstream_cluster", "upstream_local_addr", "downstream_local_addr", "downstream_remote_addr", "server_name", "route_name", "grpc_status" ], "SourceKey": "content", "Regex": "\\[([^\\s]+)\\]\\s+\"([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\"\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+\"([^\"]+)\"\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+\"([^\"]+)\"\\s+\"([^\"]+)\"\\s+\"([^\"]+)\"\\s+\"([^\"]+)\"\\s+\"([^\"]+)\"\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s([^\\s]+)\\s+\"([^\"]+)\".*", "NoKeyError": true }, "type": "processor_regex" } ] }

fatedier commented 3 years ago

@HuiJing-C I'm not sure if it's wrong since i can create it successfully.

We should focus on why creating success but updating failed. I fixed this problem in #3866 and test it in my environment, it works fine.

HuiJing-C commented 3 years ago

@fatedier Okay, we will help fix the bug

HuiJing-C commented 3 years ago

@fatedier we have fixed in 1.133.0

fatedier commented 3 years ago

@HuiJing-C Thanks for your feedback.

However, i'm really confused if this is an open source repo or just a place to store source codes. Why my fix PR hasn't been reviewed and you just fix it using same code as i write? This may be not polite.

Do you just keep your codes in an internal company repo and sync to github periodically. If so, you'd better describe it clearly in README, so other people won't misunderstand.