X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/674630a6f461527f5b26e917814736b444cb4f51..5b0d61f40100d50a53b460e397667d1ac85e174d:/lib/cloud/azure/azure.go diff --git a/lib/cloud/azure/azure.go b/lib/cloud/azure/azure.go index 7b170958b6..71f2a23dc9 100644 --- a/lib/cloud/azure/azure.go +++ b/lib/cloud/azure/azure.go @@ -28,6 +28,7 @@ import ( "github.com/Azure/go-autorest/autorest/azure/auth" "github.com/Azure/go-autorest/autorest/to" "github.com/jmcvetta/randutil" + "github.com/prometheus/client_golang/prometheus" "github.com/sirupsen/logrus" "golang.org/x/crypto/ssh" ) @@ -238,7 +239,7 @@ type azureInstanceSet struct { logger logrus.FieldLogger } -func newAzureInstanceSet(config json.RawMessage, dispatcherID cloud.InstanceSetID, _ cloud.SharedResourceTags, logger logrus.FieldLogger) (prv cloud.InstanceSet, err error) { +func newAzureInstanceSet(config json.RawMessage, dispatcherID cloud.InstanceSetID, _ cloud.SharedResourceTags, logger logrus.FieldLogger, reg *prometheus.Registry) (prv cloud.InstanceSet, err error) { azcfg := azureInstanceSetConfig{} err = json.Unmarshal(config, &azcfg) if err != nil { @@ -514,20 +515,23 @@ func (az *azureInstanceSet) Create( AdminUsername: to.StringPtr(az.azconfig.AdminUsername), LinuxConfiguration: &compute.LinuxConfiguration{ DisablePasswordAuthentication: to.BoolPtr(true), - SSH: &compute.SSHConfiguration{ - PublicKeys: &[]compute.SSHPublicKey{ - { - Path: to.StringPtr("/home/" + az.azconfig.AdminUsername + "/.ssh/authorized_keys"), - KeyData: to.StringPtr(string(ssh.MarshalAuthorizedKey(publicKey))), - }, - }, - }, }, CustomData: &customData, }, }, } + if publicKey != nil { + vmParameters.VirtualMachineProperties.OsProfile.LinuxConfiguration.SSH = &compute.SSHConfiguration{ + PublicKeys: &[]compute.SSHPublicKey{ + { + Path: to.StringPtr("/home/" + az.azconfig.AdminUsername + "/.ssh/authorized_keys"), + KeyData: to.StringPtr(string(ssh.MarshalAuthorizedKey(publicKey))), + }, + }, + } + } + if instanceType.Preemptible { // Setting maxPrice to -1 is the equivalent of paying spot price, up to the // normal price. This means the node will not be pre-empted for price