Repository navigation
feat(compute): instance group managers, resize requests, accelerator types and regional bulkInsert - #115
Open
Joey Lin (jlinpw) wants to merge 6 commits into
Conversation
…uspend and resume acceleratorTypes answers aggregatedList, list and get from a per-zone catalog that WithAcceleratorTypes sets. regionInstances.bulkInsert places instances in the region's zones by its locationPolicy and shares the zonal bulkInsert's naming, conflict and minCount rules. instances.suspend and resume move a running instance through SUSPENDING to SUSPENDED and back.
Zonal instance group managers: insert, get, list, aggregatedList, delete, createInstances, deleteInstances, listManagedInstances and setInstanceTemplate. A group creates real instances from its template, which instances.get and list see, and reports them with their instanceStatus and currentAction; deleting a group deletes its instances, and a template a group uses cannot be deleted. Resize requests: insert, get, list, cancel and delete, moving from ACCEPTED through CREATING to SUCCEEDED as WithSettleAfter and Settle allow, with the 412 the API gives a cancel or delete in the wrong state. Server.FailResizeRequest and Server.FailResizeAttempt end a request in FAILED or record a failed attempt on one still waiting, as want of quota or capacity does.
# Conflicts: # gcp/compute/instances.go # gcp/compute/server.go
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends the
gcp/computestand-in so code that manages groups of VMs, GPU nodes and failed resources can be tested through the official Go client instead of a hand-written fake. Five additions, plus one tofault:Fault messages (
fault).Fault.MessageandFault.WithMessage(...)set the human-readable message of the error a fault answers with, so a test can reproduce the exact wording a caller tells failures apart by (for example"pd-ssd disk type cannot be used by g4-standard-6 machine type."). Every stand-in uses it throughFault.ErrorMessage(); without a message the error still readssquall: injected fault (...).Zonal instance group managers.
list,aggregatedList(previously always empty),get,insert,delete,createInstances,deleteInstances,listManagedInstances,setInstanceTemplate.resourceInUseByAnotherResource.createInstancesmakes real instances from the template, visible toinstances.get/list, withcreated-byandinstance-templatemetadata. Its operation finishes at once while the instances are created in the background, soWithSettleAfterholds them in progress andlistManagedInstancesreports themCREATING(orDELETINGafterdeleteInstances).CREATINGwith no instance and the error inlastAttempt. Naming an instance or member that exists fails with 409alreadyExists.targetSizeis the number of members. Deleting a group deletes its instances and resize requests.Instance group manager resize requests.
list,get,insert,cancel,delete.WithSettleAfterholds it (with a negative count it stays ACCEPTED untilSettle).conditionNotMet, saying the request "has reached a final state" when it has.Server.FailResizeRequestends a request FAILED and removes what it made, andServer.FailResizeAttemptrecords a failed attempt inlastAttemptwhile it waits.Accelerator types and regional bulkInsert.
acceleratorTypes:aggregatedList,list,get. Every zone offersnvidia-l4andnvidia-tesla-t4unlessWithAcceleratorTypes(zone, names...)says otherwise.regionInstances.bulkInsertshares the zonal handler, so name patterns, conflicts,minCountandperLocationStatusbehave the same. It places instances in the first zone, in name order, thatlocationPolicydoesn't deny, or spreads them withtargetShape: BALANCED.Instance suspend and resume. RUNNING to SUSPENDING to SUSPENDED, and back through STAGING to RUNNING. Calling either on an instance already in the target state does nothing; from any other state the operation fails with
RESOURCE_NOT_READY.FAILED disks.
Server.PutDisksets up a disk, READY or FAILED, as Compute Engine leaves one whose creation failed (a fault that fails an insert's operation creates nothing, so this can't be reached through the API). A FAILED disk can be read, listed and deleted but not attached or snapshotted.PutDiskrejects what an insert would.All new methods have permissions under
WithPolicy, and their faultResources are documented. The package documentation lists where the stand-in differs from the real API, including:instanceLifecyclePolicy,resourcePolicies,updatePolicy,targetSizePolicyandnamedPortsare recorded unchecked.requestedRunDurationis recorded, not enforced.locationPolicy.createInstancesconflict and the 412 wording for cancelling a CREATING request or deleting an active one are inferred.Testing
sdktest/gcp/compute:groups_test.go,accelerators_test.go,region_instances_test.go,suspend_test.goanddisks_test.gogo throughcloud.google.com/go/compute/apiv1(instance group managers, resize requests, accelerator types, region instances, instances and disks clients).addresses_test.gochecks a fault's message reaches the caller both when a call is rejected and when its operation fails.fault/fault_test.gocoversErrorMessageandStringwith a message.make checkpasses (on Go 1.27.4; 1.27.3's standard library has GO-2026-6859, which govulncheck reports regardless of this change).make benchagainst canary,benchstatover 10 runs each:Bytes and allocations per op are unchanged.
Checklist
make checkpasses