Documentation
¶
Overview ¶
Package alibaba provides direct-SDK helpers for Alibaba Cloud that complement the cb-spider based flow of cb-tumblebug.
This file implements image-family based resolution for Alibaba ECS images. Rationale:
- Alibaba deprecates/removes individual public image IDs relatively fast (date-stamped builds), which makes long-lived image assets stored in the cb-tumblebug DB break when used to launch a VM.
- Each Alibaba public image is tagged with an "ImageFamily" (e.g. "acs:ubuntu_22_04_x64") that is stable across builds. Calling DescribeImageFromFamily returns the latest available image in that family.
- Resolving "latest id by family" at VM-creation time sidesteps the deprecation issue entirely, without requiring changes to cb-spider.
Index ¶
- func BatchDescribeInstanceStatuses(ctx context.Context, region string, instanceIds []string) (map[string]string, error)
- func FetchAvailableSpecListByRegion(ctx context.Context, region string, zoneID string) (model.SpiderSpecList, error)
- func FetchNodePricesByRegion(ctx context.Context, region string) (model.SpiderCloudPrice, error)
- func FetchNodePricesByRegionFiltered(ctx context.Context, region string, targetInstanceTypes map[string]struct{}) (model.SpiderCloudPrice, error)
- func ResolveLatestIdByFamily(ctx context.Context, region, family string) (imageId string, creationTime string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BatchDescribeInstanceStatuses ¶ added in v0.12.9
func BatchDescribeInstanceStatuses(ctx context.Context, region string, instanceIds []string) (map[string]string, error)
BatchDescribeInstanceStatuses queries Alibaba ECS DescribeInstances for the given instance IDs and returns a map of instanceId → TB status string. Requests are batched in groups of 100.
func FetchAvailableSpecListByRegion ¶
func FetchAvailableSpecListByRegion(ctx context.Context, region string, zoneID string) (model.SpiderSpecList, error)
FetchAvailableSpecListByRegion fetches Alibaba VM specs available in the given region using DescribeAvailableResource(Status=Available), then enriches them with spec details from DescribeInstanceTypes.
func FetchNodePricesByRegion ¶
FetchNodePricesByRegion fetches Alibaba ECS instance prices directly from Alibaba APIs.
Optimization focus for TB spec cost/hour use-case: - Uses DescribeInstanceTypes once to get candidate specs. - Calls DescribePrice per instanceType WITHOUT systemDiskCategory sweep. - Extracts only the instanceType component price (cost/hour). - Treats PriceNotFound as data-gap (skip), not hard failure.
func FetchNodePricesByRegionFiltered ¶
func FetchNodePricesByRegionFiltered(ctx context.Context, region string, targetInstanceTypes map[string]struct{}) (model.SpiderCloudPrice, error)
FetchNodePricesByRegionFiltered fetches Alibaba ECS instance prices with optional instance-type filtering. When targetInstanceTypes is non-empty, only those instance types are queried via DescribePrice.
func ResolveLatestIdByFamily ¶ added in v0.12.7
func ResolveLatestIdByFamily(ctx context.Context, region, family string) (imageId string, creationTime string, err error)
ResolveLatestIdByFamily returns the image ID of the most recent available image within the given Alibaba ImageFamily in the given region.
The family argument must be a non-empty Alibaba ImageFamily identifier (e.g. "acs:ubuntu_22_04_x64"). The caller is responsible for extracting the family from stored metadata (e.g. image_infos.details) before calling this function.
Returns:
- imageId: resolved latest image ID, empty if not found
- creationTime: ISO8601 creation time of the resolved image (as returned by ECS)
- err: non-nil only on transport/credential/API errors; a legitimate "family has no available image" result is returned as (imageId="", creationTime="", err=nil) so the caller can fall back to the original image ID.
Types ¶
This section is empty.