in src/go/pkg/cachewarmer/warmpathmanager.go [325:404]
func (m *WarmPathManager) EnsureVmssRunning(ctx context.Context) {
vmssExists, err := VmssExists(ctx, m.AzureClients, VmssName)
if err != nil {
log.Error.Printf("checking VMSS existence failed with error %v", err)
return
}
if vmssExists {
log.Debug.Printf("vmss is already running")
return
}
// get the controller subnet id
localVMSubnetId, err := GetSubnetId(ctx, m.AzureClients)
if err != nil {
log.Error.Printf("ERROR: failed to initialize Azure Clients: %s", err)
return
}
vmssSubnetId := localVMSubnetId
if len(m.vmssSubnet) > 0 {
// swap the subnet if the customer requested an alternative subnet
vmssSubnetId = SwapResourceName(localVMSubnetId, m.vmssSubnet)
}
// get proxy information and pass on to worker
httpProxyStr := ""
if e := os.Getenv("http_proxy"); len(e) > 0 {
httpProxyStr = fmt.Sprintf("http_proxy=%s", e)
}
httpsProxyStr := ""
if e := os.Getenv("https_proxy"); len(e) > 0 {
httpProxyStr = fmt.Sprintf("https_proxy=%s", e)
}
noProxyStr := ""
if e := os.Getenv("no_proxy"); len(e) > 0 {
noProxyStr = fmt.Sprintf("no_proxy=%s", e)
}
cacheWarmerCloudInit := InitializeCloutInit(
httpProxyStr, // httpProxyStr string,
httpsProxyStr, // httpsProxyStr string,
noProxyStr, // noProxyStr string,
m.bootstrapMountAddress, // bootstrapAddress string,
m.bootstrapExportPath, // exportPath string,
m.bootstrapScriptPath, // bootstrapScriptPath string,
m.storageAccount, // storageAccount string,
m.storageKey, // storageKey string,
m.queueNamePrefix, // queueNamePrefix string
)
customData, err := cacheWarmerCloudInit.GetCacheWarmerCloudInit()
if err != nil {
log.Error.Printf("BUG BUG: customData retrieval hits the following error: %v", err)
return
}
cacheWarmerVmss := createCacheWarmerVmssModel(
VmssName, // vmssName string,
m.AzureClients.LocalMetadata.Location, // location string,
VMSSNodeSize, // vmssSKU string,
m.WorkerCount, // nodeCount int64,
m.vmssUserName, // userName string,
m.vmssPassword, // password string,
m.vmssSshPublicKey, // sshKeyData string,
MarketPlacePublisher, // publisher string,
MarketPlaceOffer, // offer string,
MarketPlaceSku, // sku string,
PlanName, // planName string,
PlanPublisherName, // planPublisherName string,
PlanProductName, // planProductName string,
compute.Spot, // priority compute.VirtualMachinePriorityTypes,
compute.Delete, // evictionPolicy compute.VirtualMachineEvictionPolicyTypes
vmssSubnetId, // subnetId string
customData,
)
log.Info.Printf("create VMSS with %d workers", m.WorkerCount)
if _, err := CreateVmss(ctx, m.AzureClients, cacheWarmerVmss); err != nil {
log.Error.Printf("error creating vmss: %v", err)
return
}
}