Alibaba Cloud Integration#
Alibaba Cloud (Aliyun) integration in cb-tumblebug operates on two layers:
- cb-spider adapter — the standard path used for most VM lifecycle operations.
- Direct ECS SDK layer (
src/core/csp/alibaba/) — bypasses cb-spider for spec discovery, pricing, availability checks, VM status polling, and image resolution. This layer was introduced because the cb-spider path for Alibaba has known gaps in these areas (e.g., pricing does a costly disk-category sweep; image IDs deprecate rapidly).
The direct layer is organized into four files under src/core/csp/alibaba/:
| File | Responsibility |
|---|---|
price.go | Spec discovery & ECS pricing via DescribePrice |
availability.go | Zone × disk-category stock checks via DescribeAvailableResource |
vmstatus.go | Batch VM status polling via DescribeInstances |
image.go | ImageFamily → latest image ID resolution via DescribeImageFromFamily |
All four files register themselves into the cb-tumblebug provider registry via init() hooks and call the shared getAlibabaCreds(ctx) helper to retrieve credentials from OpenBao.
Credentials & Connection Config#
Alibaba credentials use two fields mapped in src/core/csp/csp.go:
| CB-Spider field | OpenBao secret key |
|---|---|
AccessKeyId | ALIBABA_CLOUD_ACCESS_KEY_ID |
AccessKeySecret | ALIBABA_CLOUD_ACCESS_KEY_SECRET |
At runtime, all direct-SDK code calls getAlibabaCreds(ctx) which reads the secret from OpenBao via csp.BuildSecretPath(ctx, "alibaba"). The context may carry a CredentialHolder (set from connConfig.CredentialHolder) that scopes the secret path to a specific tenant .
Connection configs reference Alibaba via providerName = "alibaba" and carry RegionDetail.RegionName and RegionZoneInfo.AssignedZone, both of which are passed directly into the ECS SDK client on every direct API call.
Supported Regions#
The canonical multi-region reference is init/templates/infra-alibaba-global.json, which defines a "1 VM per region" test infra across 12 regions:
| Region | Location |
|---|---|
ap-northeast-1 | Japan |
ap-southeast-3 | Kuala Lumpur |
cn-huhehaote | Inner Mongolia (China) |
cn-wuhan-lr | Wuhan Local Region (China) |
cn-wulanchabu | Ulanqab (China) |
eu-central-1 | Frankfurt |
eu-west-1 | London |
me-central-1 | Central Middle East |
me-east-1 | Dubai |
na-south-1 | South Americas |
us-east-1 | Virginia |
us-west-1 | Silicon Valley |
Spec ID format: alibaba+{region}+{cspSpecName}, e.g. alibaba+ap-northeast-1+ecs.e-c4m1.large .
Note that cn-* China Mainland regions and cn-*-lr Local Regions may require separate Alibaba account activation and may have different instance type availability from global regions.
Direct API Integration (Bypassing CB-Spider)#
Spec Discovery#
For Alibaba connections, spec.go calls alibabaPricing.FetchAvailableSpecListByRegion(ctx, region, zone) instead of the standard LookupSpecList (cb-spider) path . This function (defined in price.go:356-455):
- Calls
DescribeAvailableResource(DestinationResource="InstanceType", Status=Available)to get the zone-specific available instance type list. - Calls
DescribeInstanceTypes(paginated, 100 per page) to enrich each available type with vCPU, memory, local disk, and GPU details. - Returns a
SpiderSpecListsorted by name.
Pricing#
FetchNodePricesByRegion (and its filtered variant FetchNodePricesByRegionFiltered) fetch on-demand ECS prices per instance type:
- Calls
DescribeInstanceTypesto enumerate types, then dispatches concurrent workers (default 5) each callingDescribePriceper type. - Extracts only the
instanceTypecomponent fromDetailInfosto get cost/hour; falls back toTradePriceif detail is absent . - When a region requires an explicit disk category (error
InvalidSystemDiskCategory.ValueNotSupported), retries withcloud_essdthencloud_efficiency. - Currency defaults to
CNYwhen the API response omits it .
Tuning env vars :
| Variable | Default | Purpose |
|---|---|---|
TB_ALIBABA_PRICE_WORKERS | 5 | Concurrent DescribePrice workers |
TB_ALIBABA_PRICE_INTERVAL_MS | 200 | Per-request pacing (ms) |
TB_ALIBABA_PRICE_MAX_RETRY | 3 | Max retries on throttle/network error |
TB_ALIBABA_PRICE_BACKOFF_MS | 1200 | Base backoff between retries (ms) |
TB_ALIBABA_REGION_CONCURRENCY | 10 | Regions fetched concurrently in fetchAlibabaPricesDirect |
Availability Checking#
availabilityChecker registers via init() and implements the csp.AvailabilityChecker interface. CheckInstance calls DescribeAvailableResource(DestinationResource="SystemDisk") to build a per-zone availability matrix showing which system-disk categories have stock .
A zone is considered available when its status is "Available" and it has at least one supported disk category. This proactively catches the most common Alibaba VM-creation failure: No AvailableSystemDisk for instance type in region (a zone+disk+instanceType stock issue that spec catalog lookups cannot detect) .
VM Status Polling#
BatchDescribeInstanceStatuses registered via init() :
- Accepts up to N instance IDs and batches them into groups of 100 for
DescribeInstances. - Maps Alibaba ECS states to TB status strings :
| Alibaba State | TB Status |
|---|---|
| Pending, Starting | Creating |
| Running | Running |
| Stopping | Suspending |
| Stopped | Suspended |
Image Family Resolution#
Alibaba date-stamped image IDs (e.g. ubuntu_22_04_x64_20G_alibase_20260615.vhd) are deprecated rapidly, causing stored image assets to break at VM-creation time. The solution: each Alibaba public image carries a stable ImageFamily tag (e.g. acs:ubuntu_22_04_x64).
ResolveLatestIdByFamily(ctx, region, family) in image.go:
- Calls
DescribeImageFromFamilyto get the current latest image ID for a family in a region. - Caches results for 10 minutes with
singleflightdeduplication to prevent API burst during parallel VM creation . - A "no image in family" result is a soft miss (returns empty ID, caller falls back to original) .
At VM-creation time, resolveLatestAlibabaImage in src/core/resource/image.go extracts the ImageFamily from stored imageInfo.Details and calls this resolver .
Infrastructure Template#
init/templates/infra-alibaba-global.json is the reference multi-region deployment template. It provisions one ECS instance per region across all 12 supported Alibaba regions , using:
- Image:
ubuntu_22_04_x64_20G_alibase_20260615.vhd(Ubuntu 22.04; at runtime the image family resolver replaces this with the latest build) - Spec: region-appropriate ECS types, e.g.
ecs.e-c4m1.largefor most global regions,ecs.t6-c4m1.largefor some China/ME regions, andecs.c9i.largefor newer regions likecn-wuhan-lrandna-south-1
Use this template as a starting point for global Alibaba test deployments or as a reference for spec/image IDs per region.