-
Notifications
You must be signed in to change notification settings - Fork 389
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
Make it possible to configure individual PD service objects independently #237
Make it possible to configure individual PD service objects independently #237
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we have some more documentation around these fields and methods?
datadog/resource_datadog_integration_pagerduty_service_object.go
Outdated
Show resolved
Hide resolved
So the code and docs are finished and reviewable from my PoV. While writing the tests, I've discovered a race condition on the API side, so I'll need to wait for it to get fixed before this PR can be finalized. |
…ble on API side ATM)
So I was advised to workaround the race condition by serializing all operations that change individual service objects - I did that by using a mutex. I also added tests, so this PR is now complete from my side and ready to be fully reviewed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 👏 Great Job!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks great 🚀 Left a couple of small comments.
Just want to confirm the terraform plan that will happen as people migrate over. If you currently use this pagerduty resource, you'll have the service attributes in the state. The plan is to switch to this new mechanism, and on the next apply, the READ call will see nil
services and report the diff. BUT the Update call will send nil
to the API.
Would this do nothing, or temporarily delete the services until the new service_object attribute calls its Create mechanism?
|
||
if err := client.CreateIntegrationPDService(so); err != nil { | ||
// TODO: warn user that PD integration must be enabled to be able to create service objects | ||
return fmt.Errorf("Failed to create integration pagerduty using Datadog API: %s", err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we link to the documentation here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And say that you need to install the tile first? (And/or show the TF page about enabling the integration globally?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error returned from API says Pagerduty Integration not found
(which is printed with the error message) is IMO sufficient. I think this is self-explanatory enough. Do you need it needs to be improved? Because if we wanted to provide the docs just in this case, we'd need to scan precisely for the Pagerduty Integration not found
string and that can be error-prone if that string changes a bit in the future...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah thats totally valid. Lets keep as is then 🙂
Thanks for the review @nmuesch. I admit I haven't fully investigated the migration path, so that's something I need to look into and it will likely take some time to make sure it's done right. I'll update this issue when I figure out the best approach here. |
…bject when defined inline
All right, I figured out a migration path, documented it and wrote an integration test for it. Ready for re-review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 LGTM Thanks especially for figuring out and documenting this migration path!
💜 for the update bug fix as well!
Any plans to release this? Since this fixes https://github.com/terraform-providers/terraform-provider-datadog/issues/160 it enables datadog pagerduty integration to work unlike current stable version. |
@jvitkauskas hey, this will be part of the next release. We're hoping to get it released either this Thursday/Friday or in the first half of next week (not guaranteed at this point, we may hold the release if we find some issues during pre-release testing). |
This PR uses newly added Datadog API features (undocumented ATM, unfortunately) to make it possible to configure individual PD integration service objects independently.
The idea is to be able to use the current
datadog_integration_pagerduty
resource and allow adding number of independent service objects viadatadog_integration_pagerduty_service_object
resources.Some notes:
datadog_integration_pagerduty
and the way it works with services. To that end, I addedindividual_services
attribute to it, which is mutually exclusive withservices
. Ifservices
is present, everything will work as it used to up until now. Ifindividual_services
is present, then this resource will not be storing list of service object into its state, meaning that creatingdatadog_integration_pagerduty_service_object
resources won't cause TF to produce non-empty plans for it - it will pretty much remain as a configuration object for the whole integration.datadog_integration_pagerduty_service_object
have to havedepends_on = ["datadog_integration_pagerduty.foo"]
, since they can't be created if the integration is deactivated.datadog_integration_pagerduty.services
is now marked as deprecated because of this new functionality.TODO:
terraform taint
, which I documented.service_key
, so import wouldn't work well.This supersedes https://github.com/terraform-providers/terraform-provider-datadog/pull/164, implements https://github.com/terraform-providers/terraform-provider-datadog/issues/75 and also fixes https://github.com/terraform-providers/terraform-provider-datadog/issues/160 thanks to updating the go-datadog-api dependency to latest master, which contains the fix for it: zorkian/go-datadog-api@ddd27c7