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

Improve consistency by using response from POST/PUT requests directly to save state #901

Merged
merged 5 commits into from
Feb 12, 2021

Conversation

zippolyte
Copy link
Contributor

@zippolyte zippolyte commented Feb 8, 2021

Avoid consistency issues, due to replication delays, caused by calling the GET endpoint right after POST/PUT

Also fixes some linting warnings, and reads error returned by d.Set

@zippolyte zippolyte requested review from a team as code owners February 8, 2021 14:46
@zippolyte
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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 LGTM, left a few inline questions. Thanks!

@@ -559,41 +559,8 @@ func resourceDatadogMonitorCreate(d *schema.ResourceData, meta interface{}) erro
return resourceDatadogMonitorRead(d, meta)
}

func resourceDatadogMonitorRead(d *schema.ResourceData, meta interface{}) error {
func updateMonitorState(d *schema.ResourceData, meta interface{}, m *datadogV1.Monitor) error {
providerConf := meta.(*ProviderConfiguration)
Copy link
Contributor

Choose a reason for hiding this comment

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

is providerConf still used in this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, to get the time near the end

d.Set("type", m.GetType())
d.Set("priority", m.GetPriority())
d.Set("restricted_roles", m.GetRestrictedRoles())
if err := d.Set("name", m.GetName()); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this error if the value being set is empty, or is it just if an internal TF SDK piece fails?

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 errors if an internal SDK piece fails, like wrong type or something

if err := d.Set("tags", tags); err != nil {
return err
}
// TODO Is this one of those options that we neeed to check?
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we know what this TODO is for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

absolutely not

@@ -771,12 +822,13 @@ func resourceDatadogMonitorUpdate(d *schema.ResourceData, meta interface{}) erro
delete(silencedList, scope)
}
}
if _, _, err = datadogClientV1.MonitorsApi.UpdateMonitor(authV1, i).Body(*m).Execute(); err != nil {
monitorResp, _, err = datadogClientV1.MonitorsApi.UpdateMonitor(authV1, i).Body(*m).Execute()
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps you have already (not sure if we have an explicit test for this) but can you confirm we get the full monitor back here when we unmute scopes?

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's still the same update call, so I'd say yes, and monitors team said I could rely on output of PUT request

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(also yeah we have a specific unmute test)

@zippolyte zippolyte enabled auto-merge (squash) February 11, 2021 08:51
@nmuesch
Copy link
Contributor

nmuesch commented Feb 12, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@zippolyte zippolyte merged commit 5b9b3b4 into master Feb 12, 2021
@zippolyte zippolyte deleted the hippo/monitorredo branch February 12, 2021 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants