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

Downtime improvements #204

Merged
merged 3 commits into from
Jun 3, 2019
Merged

Conversation

platinummonkey
Copy link
Contributor

  1. Adds the timezone parameter
  2. Adds descriptions to parameters
  3. Adds validation to monitor_tags
  4. Ensures that the updated downtime id is correctly handled for future immutable downtimes

Adds the timezone parameter

Adds descriptions to parameters

Adds validation to monitor_tags

Ensures that the updated downtime id is correctly handled for future immutable downtimes
@ghost ghost added the size/M label May 15, 2019
@platinummonkey
Copy link
Contributor Author

cc @bkabrda

Copy link
Contributor

@nmuesch nmuesch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, thanks for this. Left two quick comments/questions.

Can you also add the new information to the docs - https://github.com/terraform-providers/terraform-provider-datadog/blob/master/website/docs/r/monitor.html.markdown#argument-reference 🙇

Optional: true,
Type: schema.TypeInt,
Optional: true,
ConflictsWith: []string{"monitor_tags"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is setting both not an available option here? Would the API return an error previously if both were being sent?

Copy link
Contributor Author

@platinummonkey platinummonkey Jun 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while technically it works, it's one of those, it's broken if the tags also don't match the monitor and won't apply it'll be an API validation in the future.

The matching logic today is: (pseudo-python): if (downtime.monitor_id is None or downtime.monitor_id == monitor.id) and monitor.tags.issuperset(downtime.monitor_tags)

in the case of no downtime.monitor_tags it's an empty set, so it'll always match. the downtime.monitor_tags was meant to match multiple monitors that have those tags.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok makes sense, thanks for the explanation :)

@@ -305,6 +326,8 @@ func resourceDatadogDowntimeUpdate(d *schema.ResourceData, meta interface{}) err
if err = client.UpdateDowntime(dt); err != nil {
return fmt.Errorf("error updating downtime: %s", err.Error())
}
// handle the case when a downtime is replaced
d.SetId(strconv.Itoa(dt.GetId()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm, the idea here being that we would be updating the current downtime on each subsequent apply, rather than creating a new one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just ensures the downtime ID is set. In the future when downtimes are immutable this ID can change on updates

@ghost ghost added the documentation label Jun 3, 2019
Copy link
Contributor

@nmuesch nmuesch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

@nmuesch nmuesch merged commit 9052db2 into DataDog:master Jun 3, 2019
@platinummonkey platinummonkey deleted the downtime-improvements branch June 3, 2019 16:34
jbenais pushed a commit to jbenais/terraform-provider-datadog that referenced this pull request Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants