DocumentsCloud-Barista's Space
Alibaba Cloud Integration
Alibaba Cloud Integration
Type
Topic
Status
Published
Created
Jul 13, 2026
Updated
Jul 13, 2026
Created by
Dosu Bot
Updated by
Dosu Bot

Alibaba Cloud Integration#

Alibaba Cloud (Aliyun) integration in cb-tumblebug operates on two layers:

  1. cb-spider adapter — the standard path used for most VM lifecycle operations.
  2. 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/:

FileResponsibility
price.goSpec discovery & ECS pricing via DescribePrice
availability.goZone × disk-category stock checks via DescribeAvailableResource
vmstatus.goBatch VM status polling via DescribeInstances
image.goImageFamily → 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 fieldOpenBao secret key
AccessKeyIdALIBABA_CLOUD_ACCESS_KEY_ID
AccessKeySecretALIBABA_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:

RegionLocation
ap-northeast-1Japan
ap-southeast-3Kuala Lumpur
cn-huhehaoteInner Mongolia (China)
cn-wuhan-lrWuhan Local Region (China)
cn-wulanchabuUlanqab (China)
eu-central-1Frankfurt
eu-west-1London
me-central-1Central Middle East
me-east-1Dubai
na-south-1South Americas
us-east-1Virginia
us-west-1Silicon 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):

  1. Calls DescribeAvailableResource(DestinationResource="InstanceType", Status=Available) to get the zone-specific available instance type list.
  2. Calls DescribeInstanceTypes (paginated, 100 per page) to enrich each available type with vCPU, memory, local disk, and GPU details.
  3. Returns a SpiderSpecList sorted by name.

Pricing#

FetchNodePricesByRegion (and its filtered variant FetchNodePricesByRegionFiltered) fetch on-demand ECS prices per instance type:

  • Calls DescribeInstanceTypes to enumerate types, then dispatches concurrent workers (default 5) each calling DescribePrice per type.
  • Extracts only the instanceType component from DetailInfos to get cost/hour; falls back to TradePrice if detail is absent .
  • When a region requires an explicit disk category (error InvalidSystemDiskCategory.ValueNotSupported), retries with cloud_essd then cloud_efficiency .
  • Currency defaults to CNY when the API response omits it .

Tuning env vars :

VariableDefaultPurpose
TB_ALIBABA_PRICE_WORKERS5Concurrent DescribePrice workers
TB_ALIBABA_PRICE_INTERVAL_MS200Per-request pacing (ms)
TB_ALIBABA_PRICE_MAX_RETRY3Max retries on throttle/network error
TB_ALIBABA_PRICE_BACKOFF_MS1200Base backoff between retries (ms)
TB_ALIBABA_REGION_CONCURRENCY10Regions 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 StateTB Status
Pending, StartingCreating
RunningRunning
StoppingSuspending
StoppedSuspended

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 DescribeImageFromFamily to get the current latest image ID for a family in a region.
  • Caches results for 10 minutes with singleflight deduplication 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.large for most global regions, ecs.t6-c4m1.large for some China/ME regions, and ecs.c9i.large for newer regions like cn-wuhan-lr and na-south-1

Use this template as a starting point for global Alibaba test deployments or as a reference for spec/image IDs per region.