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

Adding autodefer parameter to automatically defer any maintenance #499

Merged
merged 1 commit into from
Jul 29, 2021
Merged

Adding autodefer parameter to automatically defer any maintenance #499

merged 1 commit into from
Jul 29, 2021

Conversation

vicgp-te
Copy link
Contributor

Description

This PR adds the parameter autodefer to automatically defer any maintenance for a given project as explained here https://docs.atlas.mongodb.com/reference/api/maintenance-window-auto-defer/

Type of change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the Terraform contribution guidelines
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code

Further comments

@themantissa
Copy link
Collaborator

Hi @vgarcia-te, thank you for the submission and for signing the CLA. We'll get this reviewed by the team.

Copy link

@threebee threebee left a comment

Choose a reason for hiding this comment

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

Looking good, I have added a nit.

@@ -90,6 +96,13 @@ func resourceMongoDBAtlasMaintenanceWindowCreate(ctx context.Context, d *schema.
}
}

if autoDeferValue := d.Get("auto_defer").(bool); autoDeferValue {
_, err := conn.MaintenanceWindows.AutoDefer(context.Background(), projectID)

Choose a reason for hiding this comment

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

[nit] conn.MaintenanceWindows.Defer(ctx, projectID) -> I see that we are using ctx as parameter for defer.

So just to be consistent, could you use ctx as parameter to AutoDefer instead of context.Background()

Suggested change
_, err := conn.MaintenanceWindows.AutoDefer(context.Background(), projectID)
_, err := conn.MaintenanceWindows.AutoDefer(ctx, projectID)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, wrong copy paste from a previous version i was working on. Fixed

@@ -166,6 +179,13 @@ func resourceMongoDBAtlasMaintenanceWindowUpdate(ctx context.Context, d *schema.
}
}

if d.HasChange("auto_defer") {
_, err := conn.MaintenanceWindows.AutoDefer(context.Background(), d.Id())

Choose a reason for hiding this comment

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

[nit] Same suggestion as previous one

Suggested change
_, err := conn.MaintenanceWindows.AutoDefer(context.Background(), d.Id())
_, err := conn.MaintenanceWindows.AutoDefer(ctx, d.Id())

Copy link

@threebee threebee left a comment

Choose a reason for hiding this comment

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

LGTM, I'm not sure if we need tests for this change or not.

@coderGo93 wdyt? Please help me out here.

@vicgp-te
Copy link
Contributor Author

I didn't include tests given that there were no tests for the defer parameter

Copy link
Contributor

@coderGo93 coderGo93 left a comment

Choose a reason for hiding this comment

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

I don't see major changes and the behavior it's similar to parameter defer so LGTM

Yes @threebee , it would be nice to have tests but like @vgarcia-te said, it doesn't have a test for parameter defer.

Copy link
Collaborator

@themantissa themantissa left a comment

Choose a reason for hiding this comment

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

Added internal ticket to update maintenance window data source in next release: INTMDB-230. Approving work that is here. Thank you @vgarcia-te !

@themantissa themantissa merged commit 7f6ab7c into mongodb:master Jul 29, 2021
@vicgp-te
Copy link
Contributor Author

@themantissa do you know when the next will happen approximately? I would like to know when we can use this auto_defer parameter in our Terraform infrastructure (without having to install the development version)

@themantissa
Copy link
Collaborator

@vgarcia-te We are working on the final major piece (cloud backup) so other than that just final testing. Within the next week or two is reasonable, baring any major issues surfacing.

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.

4 participants