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

Add support for auto_healing_policies to google_compute_instance_group_manager #198

Closed
wants to merge 12 commits into from

Conversation

rileykarson
Copy link
Collaborator

Add support for auto_healing_policies to google_compute_instance_group_manager; Fixes #48
Add support for a beta GCP feature to a Google Provider resource; part of #93

Terraform manages v0beta and v0alpha Compute resources by using non-v1 APIs to create and manage resources when necessary, automatically using the most restrictive API it can. Users don't need to think about what version they are using, or perform complicated operations to manage their state files.

For reviewing, the best way to view the merge changes is by filtering for only the last two commits in the change view; Github is able to show just those changes and hides the merged commits.

@rileykarson rileykarson requested a review from danawillow July 14, 2017 20:54
@danawillow
Copy link
Contributor

Assuming this is just merging that branch into master with all the different changes I've reviewed, I'm ok with this. However, since it's a pretty big infrastructure change, it may be worth it to check in slack whether anyone from HashiCorp wants to review it first or whether they're ok with our judgment.

case ComputeBetaOperationWaitZone:
op, err = w.Service.ZoneOperations.Get(
w.Project, w.Zone, w.Op.Name).Do()
default:
Copy link
Contributor

Choose a reason for hiding this comment

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

In the default case, should we consider the operation type "unknown" rather than "invalid"? And then update the error message to something like "Unknown wait condition %#v encountered. ComputeBetaOperationWaiter should be updated by maintainers to include this new operation type." or something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ComputeBetaOperation is a copy of the existing ComputeOperation where we sub compute/v0beta's Operation type for compute/v1's Operation type. These changes would also need to be applied to compute_operation.go as well as compute_beta_operation.go. and I don't think that kind of change makes sense in the context of this PR.

Improving Operations is something that I've been thinking about with #187, which would introduce a standard Operation type for all versioned compute resources (such as storing them all as v1 Operations), and a refactoring of compute_operation.go that was pulled into #191.

func (e ComputeBetaOperationError) Error() string {
var buf bytes.Buffer

for _, err := range e.Errors {
Copy link
Contributor

Choose a reason for hiding this comment

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

If the ComputeBetaOperationError has multiple errors, and any of the errors have a newline in the message, it will be hard to differentiate them. Maybe take the index of the range and prefix it to the buffer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See above. If it's something you think would be valuable for compute_operation.go as well, feel free to comment with it on #191.

@@ -0,0 +1,99 @@
package google
Copy link
Contributor

Choose a reason for hiding this comment

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

Need license header

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are license headers something that we include in any of these files? Looking over provider.go, config.go, and a few resources, I can't see one included elsewhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, I guess not. But we should. I'll file an issue.

return fmt.Errorf("Error waiting for %s: %s", activity, err)
}

op = opRaw.(*computeBeta.Operation)
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth checking that the type assertion succeeds here? Like op, ok := opRaw.(...)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See above.

}

func computeBetaOperationWaitZone(config *Config, op *computeBeta.Operation, project string, zone, activity string) error {
return computeBetaOperationWaitZoneTime(config, op, project, zone, 4, activity)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we make the time vars more configurable/obvious?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See above. If we want to expose a better interface, that's something we should consider for #191.

return nil
}

func computeBetaOperationWaitZone(config *Config, op *computeBeta.Operation, project string, zone, activity string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

project, zone, activity string (remove the string after project)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See above/changes made in #191.

Type: ComputeBetaOperationWaitZone,
}
state := w.Conf()
state.Delay = 10 * time.Second
Copy link
Contributor

Choose a reason for hiding this comment

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

See previous about configuring timeouts in one place.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

}

func computeSharedOperationWaitZoneTime(config *Config, op interface{}, project string, zone string, minutes int, activity string) error {
if op == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

nil check shouldn't be necessary as the type switch's default will catch it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a nil check as a case in #234 instead of having it at the top.

@rileykarson
Copy link
Collaborator Author

Closing this PR in favour of splitting it in 2, adding Beta support to google_compute_instance_group_manager in #234 followed by adding auto_healing_policies in a later PR.

@ghost
Copy link

ghost commented Nov 16, 2018

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants