Skip to content

Conversation

Sita04
Copy link
Contributor

@Sita04 Sita04 commented Feb 22, 2023

Adding samples needed for this page.

@Sita04 Sita04 requested review from a team and yoshi-approver as code owners February 22, 2023 19:00
@snippet-bot
Copy link

snippet-bot bot commented Feb 22, 2023

Here is the summary of changes.

You are about to add 5 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added samples Issues that are directly related to samples. api: compute Issues related to the Compute Engine API. labels Feb 22, 2023
@Sita04 Sita04 changed the title docs(compute-samples): adding region disk samples docs(compute-samples): adding machine type change and region disk samples Feb 22, 2023
@Sita04 Sita04 changed the title docs(compute-samples): adding machine type change and region disk samples docs(compute-samples): adding machine type change and regional disk samples Feb 22, 2023
@Sita04 Sita04 changed the title docs(compute-samples): adding machine type change and regional disk samples docs(compute-samples): adding machine type update and regional disk samples Feb 22, 2023
@Sita04 Sita04 requested a review from savijatv February 23, 2023 18:57

Operation response = instancesClient
.setMachineTypeAsync(projectId, zone, instanceName, machineTypeRequest)
.get(3, TimeUnit.MINUTES);
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to set 3 minutes for the timeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Followed the same pattern from the other compute samples. No specific reason.

.get(3, TimeUnit.MINUTES);

if (response.hasError()) {
System.out.println("Machine type update failed! " + response);
Copy link
Contributor

Choose a reason for hiding this comment

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

What types of errors do we expect that wouldn't be thrown during the operation? Can we show users how to handle them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ditto, Followed the same pattern from the other compute samples.
Python Reference: https://github.com/GoogleCloudPlatform/python-docs-samples/pull/8992/files#diff-9dcee92af6eb54e1cd2c96bbdc292fc4857452f209215aa0204e461c7ee49d9bR62-R69

But AFAIK, I haven't encountered any errors that were not raised as exceptions.

.setDisksResizeRequestResource(DisksResizeRequest.newBuilder()
.setSizeGb(newSizeGb)
.build())
.setDisk(match[5])
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't take the full disk resource path? This seems unnecessarily hard. Is there another way to achieve this? If not You should add more comments to why you are using the matcher.

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, I believe this is due to multiple formats being accepted. See: https://github.com/GoogleCloudPlatform/python-docs-samples/pull/8992/files#diff-00f22f3a9fa3fb85b7b4340eaeb0aefece4b60556f7efd7e7bf58d684b496f2bR88-R91

I'll double check this and update the sample. Thanks for calling this out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the code to simplify. This will result in code discrepancy between the Java and Python versions. But using matcher is an over-kill for this situation and hence added additional params.

@Sita04 Sita04 requested a review from averikitsch February 28, 2023 17:05
@Sita04 Sita04 merged commit 78a94d6 into main Feb 28, 2023
@Sita04 Sita04 deleted the compute-sample-changing-machine-type branch February 28, 2023 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: compute Issues related to the Compute Engine API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants