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

Update Pager Duty integration fails with INTEGRATION_FIELDS_INVALID #1316

Closed
nikitaromm opened this issue Jul 13, 2023 · 10 comments
Closed

Update Pager Duty integration fails with INTEGRATION_FIELDS_INVALID #1316

nikitaromm opened this issue Jul 13, 2023 · 10 comments
Labels
not_stale Not stale issue or PR

Comments

@nikitaromm
Copy link

nikitaromm commented Jul 13, 2023

Terraform CLI and Terraform MongoDB Atlas Provider Version

Terraform v1.1.9
MongoDB Atlas provider 1.10.0

Terraform Configuration File

resource "mongodbatlas_third_party_integration" "default" {
  project_id  = mongodbatlas_project.default.id
  type        = "PAGER_DUTY"
  service_key = "${var.mongodb_pd_integration_key}"
}

Steps to Reproduce

  1. Create new integration with terraform apply
  2. Run terraform apply again

Expected Behavior

Pager Duty integration should update it's configuration

Actual Behavior

When I create an integration, it passes successfully. However, when I apply the same configuration, it fails and produces an error.
Error 400 received, Pager Duty integration haven't changed. Terraform apply failed.

Debug Output

---[ REQUEST ]---------------------------------------
GET /api/atlas/v1.0/groups/646e42de7ab4512086e6c7c2/integrations/PAGER_DUTY HTTP/1.1
Host: cloud.mongodb.com
User-Agent: terraform-provider-mongodbatlas/1.10.0 go-mongodbatlas/0.29.0 (linux;amd64)
Accept: application/json
Accept-Encoding: gzip


-----------------------------------------------------: timestamp=2023-07-13T12:53:31.563Z
2023-07-13T12:53:31.598Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2023-07-13T12:53:31.599Z [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/external/2.3.1/linux_amd64/terraform-provider-external_v2.3.1_x5 pid=2950
2023-07-13T12:53:31.599Z [DEBUG] provider: plugin exited
2023-07-13T12:53:31.600Z [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2023-07-13T12:53:31.611Z [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/aws/5.7.0/linux_amd64/terraform-provider-aws_v5.7.0_x5 pid=2918
2023-07-13T12:53:31.611Z [DEBUG] provider: plugin exited
2023-07-13T12:53:31.611Z [DEBUG] created provider logger: level=debug
2023-07-13T12:53:31.611Z [INFO]  provider: configuring client automatic mTLS
2023-07-13T12:53:31.621Z [DEBUG] provider: starting plugin: path=.terraform/providers/registry.terraform.io/hashicorp/aws/5.7.0/linux_amd64/terraform-provider-aws_v5.7.0_x5 args=[.terraform/providers/registry.terraform.io/hashicorp/aws/5.7.0/linux_amd64/terraform-provider-aws_v5.7.0_x5]
2023-07-13T12:53:31.621Z [DEBUG] provider: plugin started: path=.terraform/providers/registry.terraform.io/hashicorp/aws/5.7.0/linux_amd64/terraform-provider-aws_v5.7.0_x5 pid=3861
2023-07-13T12:53:31.621Z [DEBUG] provider: waiting for RPC address: path=.terraform/providers/registry.terraform.io/hashicorp/aws/5.7.0/linux_amd64/terraform-provider-aws_v5.7.0_x5
2023-07-13T12:53:31.655Z [INFO]  provider.terraform-provider-mongodbatlas_v1.10.0: 2023/07/13 12:53:31 [DEBUG] MongoDB Atlas API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/2.0 200 OK
Content-Type: application/json
Date: Thu, 13 Jul 2023 12:53:31 GMT
Referrer-Policy: strict-origin-when-cross-origin
Server: mdbws
Strict-Transport-Security: max-age=31536000; includeSubdomains;
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 17
X-Frame-Options: DENY
X-Mongodb-Service-Version: gitHash=5abc4d99deb17abdaa2b504d68b175f4338214b0; versionString=v20230712
X-Permitted-Cross-Domain-Policies: none

{
 "region": "US",
 "serviceKey": "****************************84c6",
 "type": "PAGER_DUTY"
}
-----------------------------------------------------: timestamp=2023-07-13T12:53:31.655Z
2023-07-13T12:53:31.656Z [INFO]  provider.terraform-provider-mongodbatlas_v1.10.0: 2023/07/13 12:53:31 [DEBUG] MongoDB Atlas API Request Details:
---[ REQUEST ]---------------------------------------
PUT /api/atlas/v1.0/groups/646e42de7ab4512086e6c7c2/integrations/PAGER_DUTY HTTP/1.1
Host: cloud.mongodb.com
User-Agent: terraform-provider-mongodbatlas/1.10.0 go-mongodbatlas/0.29.0 (linux;amd64)
Content-Length: 70
Accept: application/json
Content-Type: application/json
Accept-Encoding: gzip

{
 "type": "PAGER_DUTY",
 "serviceKey": "****************************84c6"
}

-----------------------------------------------------: timestamp=2023-07-13T12:53:31.656Z
2023-07-13T12:53:31.705Z [INFO]  provider.terraform-provider-mongodbatlas_v1.10.0: 2023/07/13 12:53:31 [DEBUG] MongoDB Atlas API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/2.0 400 Bad Request
Content-Length: 223
Content-Type: application/json
Date: Thu, 13 Jul 2023 12:53:31 GMT
Referrer-Policy: strict-origin-when-cross-origin
Server: mdbws
Strict-Transport-Security: max-age=31536000; includeSubdomains;
X-Content-Type-Options: nosniff
X-Envoy-Upstream-Service-Time: 18
X-Frame-Options: DENY
X-Mongodb-Service-Version: gitHash=5abc4d99deb17abdaa2b504d68b175f4338214b0; versionString=v20230712
X-Permitted-Cross-Domain-Policies: none

{
 "detail": "At least one integration field is invalid.",
 "error": 400,
 "errorCode": "INTEGRATION_FIELDS_INVALID",
 "parameters": [
  [
   "Service Key PagerDuty service key must consist of 32 hexadecimal digits."
  ]
 ],
 "reason": "Bad Request"
}
-----------------------------------------------------: timestamp=2023-07-13T12:53:31.705Z
2023-07-13T12:53:31.705Z [ERROR] provider.terraform-provider-mongodbatlas_v1.10.0: Response contains error diagnostic: @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:55 diagnostic_detail= tf_provider_addr=provider tf_rpc=ApplyResourceChange @module=sdk.proto diagnostic_severity=ERROR diagnostic_summary="error updating third party integration type `PAGER_DUTY` (cHJvamVjdF9pZA==:NjQ2ZTQyZGU3YWI0NTEyMDg2ZTZjN2My-dHlwZQ==:UEFHRVJfRFVUWQ==): PUT https://cloud.mongodb.com/api/atlas/v1.0/groups/646e42de7ab4512086e6c7c2/integrations/PAGER_DUTY: 400 (request "INTEGRATION_FIELDS_INVALID") At least one integration field is invalid." tf_proto_version=5.3 tf_req_id=ec80f308-f9bb-56a0-e687-a399c88fa359 tf_resource_type=mongodbatlas_third_party_integration timestamp=2023-07-13T12:53:31.705Z

Crash Output

Error: error updating third party integration type `PAGER_DUTY` PUT https://cloud.mongodb.com/api/atlas/v1.0/groups/646e42de7ab4512086e6c7c2/integrations/PAGER_DUTY: 400 (request "INTEGRATION_FIELDS_INVALID") At least one integration field is invalid.
  with module.atlas_mongodb[0].mongodbatlas_third_party_integration.default[0],
  on mongoAtlasDB/alerts.tf line 5, in resource "mongodbatlas_third_party_integration" "default":
   5: resource "mongodbatlas_third_party_integration" "default" {

@github-actions
Copy link
Contributor

Thanks for opening this issue. The ticket INTMDB-933 was created for internal tracking.

@maastha
Copy link
Collaborator

maastha commented Jul 19, 2023

Hi @nikitaromm
We are currently looking into this and I need to confirm that the expectation here is that there shouldn't be any changes detected that ultimately trigger an update for the integration, is that correct?

Based on your steps to reproduce it looks like you're not changing anything in the config, hence there should be no update expected. This conflicts with the "Expected Behavior" you have mentioned.

Could you please confirm the expected behavior and your steps to reproduce?

@nikitaromm
Copy link
Author

nikitaromm commented Jul 20, 2023

Hi @maastha,
You are right. We haven't made any intentional changes to the configuration, but it seems that terraform is still attempting to update it. I've attached the logs of the tfplan for your reference. To protect sensitive information, I replaced occurrences of project_id and id with "-----".

Here is what happened during the first apply:

# module.atlas_mongodb[0].mongodbatlas_third_party_integration.default[0] will be created
+ resource "mongodbatlas_third_party_integration" "default" {
    + id          = (known after apply)
    + project_id  = "-----"
    + service_key = (sensitive value)
    + type        = "PAGER_DUTY"
}

And during the second apply with the same configuration:

# module.atlas_mongodb[0].mongodbatlas_third_party_integration.default[0] will be updated in-place
~ resource "mongodbatlas_third_party_integration" "default" {
    id          = "-----"
    - region      = "US" -> null
    # (4 unchanged attributes hidden)
}

As you can see, the mongodbatlas_third_party_integration.default[0] resource is being updated in-place, specifically the region attribute is changing from "US" to null, and this is happening even though we don't have control over it.

I hope this clarifies the situation. Let me know if you have any further questions or need more information.

@maastha
Copy link
Collaborator

maastha commented Jul 20, 2023

Thanks @nikitaromm
We have merged the fix for this today, and would be available in the next release.

@nikitaromm
Copy link
Author

Great news, @maastha! Do you have any ETA on when the release will be available?

@maastha
Copy link
Collaborator

maastha commented Jul 20, 2023

Great news, @maastha! Do you have any ETA on when the release will be available?

Tagging @Zuhairahmed for release ETA for this fix.

@Zuhairahmed Zuhairahmed added the not_stale Not stale issue or PR label Jul 20, 2023
@Zuhairahmed
Copy link
Collaborator

Thanks @nikitaromm, should be out over next few weeks. Stay tuned

@maastha maastha closed this as completed Jul 21, 2023
@yaringalmor
Copy link

Hey @maastha and @Zuhairahmed , Could you tell if the fix has already been released?
@nikitaromm FYI

@maastha
Copy link
Collaborator

maastha commented Aug 28, 2023

Hi @yaringalmor @nikitaromm yes, the fix for this was released in v1.11.0.

@yaringalmor
Copy link

Thanks @maastha!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not_stale Not stale issue or PR
Projects
None yet
Development

No branches or pull requests

4 participants