-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Moved check for op name out of create*Waiter #4648
Moved check for op name out of create*Waiter #4648
Conversation
If there is a nested response but the operation is synchronous, there will not be a name - but we still need to run the rest of the logic in order to properly extract the response data.
I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=180178" |
I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccComputeNetworkPeeringRoutesConfig_networkPeeringRoutesConfigGkeExample|TestAccContainerCluster_withILBSubsetting|TestAccContainerCluster_withAuthenticatorGroupsConfig|TestAccContainerCluster_regionalWithNodePool|TestAccContainerCluster_withTpu|TestAccContainerCluster_withPrivateClusterConfig|TestAccContainerCluster_withIntraNodeVisibility|TestAccContainerNodePool_nodeLocations|TestAccContainerNodePool_maxPodsPerNode|TestAccContainerNodePool_withGPU|TestAccContainerNodePool_regionalAutoscaling|TestAccContainerNodePool_resize|TestAccContainerNodePool_012_ConfigModeAttr|TestAccContainerNodePool_EmptyGuestAccelerator|TestAccDataprocClusterIamBinding|TestAccDataprocClusterIamMember|TestAccDataprocClusterIamPolicy|TestAccDataprocCluster_updatable|TestAccDataprocCluster_withStagingBucket|TestAccDataprocCluster_withTempBucket|TestAccDataprocCluster_withInitAction|TestAccDataprocCluster_withConfigOverrides|TestAccDataprocJobIamBinding|TestAccDataprocJobIamMember|TestAccDataprocCluster_withServiceAcc|TestAccDataprocJobIamPolicy|TestAccDataprocJob_PySpark|TestAccDataprocJob_updatable|TestAccDataprocJob_Spark|TestAccDataprocJob_Pig|TestAccDataprocJob_Hadoop|TestAccDataprocJob_Hive|TestAccDataprocJob_SparkSql|TestAccStorageHmacKey_update You can view the result here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=180190" |
Tests failed during RECORDING mode: TestAccContainerCluster_withPrivateClusterConfigMissingCidrBlock|TestAccDataprocCluster_withConfigOverrides Please fix these to complete your PR |
|
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.
Hmm- I guess the API isn't breaking the definition at https://github.com/googleapis/api-common-protos/blob/master/google/longrunning/operations.proto#L129-L132 or https://google.aip.dev/151 but returning an operation without a name is surprising.
Can you post a debug log snippet including an operation response? In a similar vein to #1396 (comment), it can help capture context in case things change.
@@ -69,8 +61,12 @@ func <%= product_name.camelize(:lower) -%>OperationWaitTimeWithResponse(config * | |||
<% end -%> | |||
|
|||
func <%= product_name.camelize(:lower) -%>OperationWaitTime(config *Config, op map[string]interface{}, <% if has_project -%> project,<% end -%> activity, userAgent string, timeout time.Duration) error { | |||
if val, ok := op["name"]; !ok || val == "" { |
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.
I think there are two checks we want to make. First we can see if done: true
is set and return immediately if so. Next, we can check for a name
and return as well, but debug logging a message- because we've probably misclassified an empty response (indicating a synchronous call) as an operation. If neither of those cases is true, we can wait on the operation.
I forget if MMv1 allows individual endpoints on a resource to have operations- I'd guess it does now, but didn't when we added #1396
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.
So, this PR does not represent a net change to OperationWaitTime - it just moves the check for "name" out of create*Waiter
. (It also removes the check for "metadata" – but that was originally added to improve the behavior of OperationWaitTimeWithResponse, which this PR improves even further by removing checks for OperationWaitTimeWithResponse altogether.)
I'm not clear on the behavior of Operations that use OperationWaitTime, so I am hesitant to make more changes here. I agree we could check if done
is true and short-circuit (assuming that done: True
is set on this kind of operation) but I think there wouldn't be much benefit, since OperationWait
already short-circuits immediately if the Operation is already done.
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.
SGTM- we don't need to add the done check. It'd be fine to do here if we wanted to, since it's already a dedicated change to this kind of behaviour (and only +- 16 LOC)
@rileykarson I've added debug logs to the PR description. |
If there is a nested response but the operation is synchronous, there will not be a name - but we still need to run the rest of the logic in order to properly extract the response data.
This is an update to the change made in https://github.com/GoogleCloudPlatform/magic-modules/pull/4368/files#diff-0a9e906091ae6539868494efebdb18f41d945ac77f9dbf6d9be664f71f506028R33. At the time, I thought that the issue was that the operation wasn't being detected. However, the code comment was correct: the operation was synchronous:
Synchronous operation response with metadata (UserAccessBinding)
The impetus for this PR was that TagBindings also return a synchronous operation, but don't include a name for it, and also don't include a
metadata
key.Synchronous operation response without metadata (TagBinding)
The problem is that for
*WaitResponse
, we need to process synchronous operations, even if they don't havename
ormetadata
fields. I assume that checking for an operation name is necessary for non-*WaitResponse
operation handling.I ran into this while working on hashicorp/terraform-provider-google#8428. TagBinding resources also return a synchronous operation on creation but the operation doesn't contain a "metadata" key, just "done" and "response".
If this PR is for Terraform, I acknowledge that I have:
make test
andmake lint
to ensure it passes unit and linter tests.Release Note Template for Downstream PRs (will be copied)