Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disk: support running provisioner without ECS metadata #973

Merged
merged 3 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/cloud/metadata/ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (f *EcsFetcher) FetchFor(key MetadataKey) (MetadataProvider, error) {
if err != nil {
if errors.Is(err, context.DeadlineExceeded) {
logrus.Warnf("Hint: ECS metadata is only available when running on Alibaba Cloud ECS. "+
"Set %s environment variable to disable ECS metadata.", DISABLE_ECS_ENV)
"Set %s environment variable to disable ECS metadata for faster initialization.", DISABLE_ECS_ENV)
}
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions pkg/cloud/metadata/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ func (m *Metadata) Get(key MetadataKey) (string, error) {
func MustGet(m MetadataProvider, key MetadataKey) string {
value, err := m.Get(key)
if err != nil {
err = fmt.Errorf("failed to get metadata %s: %w", key, err)
panic(err)
}
return value
Expand Down
8 changes: 5 additions & 3 deletions pkg/disk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ type GlobalConfig struct {
EcsClient *ecs.Client
Region string
NodeID string
ZoneID string
DiskTagEnable bool
AttachDetachSlots AttachDetachSlots
ADControllerEnable bool
Expand Down Expand Up @@ -234,15 +233,18 @@ func GlobalConfigSet(m metadata.MetadataProvider) *restclient.Config {
clustID := os.Getenv("CLUSTER_ID")

controllerServerType := false
nodeID := ""
if os.Getenv(utils.ServiceType) == utils.ProvisionerService {
controllerServerType = true
nodeID = "controller" // make csi-common happy
} else {
nodeID = metadata.MustGet(m, metadata.InstanceID)
}

// Global Config Set
GlobalConfigVar = GlobalConfig{
Region: metadata.MustGet(m, metadata.RegionID),
NodeID: metadata.MustGet(m, metadata.InstanceID),
ZoneID: metadata.MustGet(m, metadata.ZoneID),
NodeID: nodeID,
ADControllerEnable: csiCfg.GetBool("disk-adcontroller-enable", "DISK_AD_CONTROLLER", false),
DiskTagEnable: csiCfg.GetBool("disk-tag-by-plugin", "DISK_TAGED_BY_PLUGIN", false),
DiskBdfEnable: csiCfg.GetBool("disk-bdf-enable", "DISK_BDF_ENABLE", false),
Expand Down