Merge branch '21535-multi-wf-delete'
[arvados.git] / lib / cloud / cloudtest / tester.go
index 24a80da38dbaa6fc6f8e095269f6810efbbe4879..a335278ed6b15a91794bc8927697dec3a6aef1ec 100644 (file)
@@ -41,6 +41,7 @@ type tester struct {
        ImageID             cloud.ImageID
        SSHKey              ssh.Signer
        SSHPort             string
+       DeployPublicKey     bool
        BootProbeCommand    string
        InstanceInitCommand cloud.InitCommand
        ShellCommand        string
@@ -61,10 +62,12 @@ type tester struct {
 // Currently this means run once for each configured SubnetID.
 func (t *tester) Run() bool {
        var dp map[string]interface{}
-       err := json.Unmarshal(t.DriverParameters, &dp)
-       if err != nil {
-               t.Logger.WithError(err).Error("error decoding configured CloudVMs.DriverParameters")
-               return false
+       if len(t.DriverParameters) > 0 {
+               err := json.Unmarshal(t.DriverParameters, &dp)
+               if err != nil {
+                       t.Logger.WithError(err).Error("error decoding configured CloudVMs.DriverParameters")
+                       return false
+               }
        }
        subnets, ok := dp["SubnetID"].([]interface{})
        if !ok || len(subnets) <= 1 {
@@ -172,15 +175,21 @@ func (t *tester) runWithDriverParameters(driverParameters json.RawMessage) bool
        bootDeadline := time.Now().Add(t.TimeoutBooting)
        initCommand := worker.TagVerifier{Instance: nil, Secret: t.secret, ReportVerified: nil}.InitCommand() + "\n" + t.InstanceInitCommand
 
+       installPublicKey := t.SSHKey.PublicKey()
+       if !t.DeployPublicKey {
+               installPublicKey = nil
+       }
+
        t.Logger.WithFields(logrus.Fields{
                "InstanceType":         t.InstanceType.Name,
                "ProviderInstanceType": t.InstanceType.ProviderType,
                "ImageID":              t.ImageID,
                "Tags":                 tags,
                "InitCommand":          initCommand,
+               "DeployPublicKey":      installPublicKey != nil,
        }).Info("creating instance")
        t0 := time.Now()
-       inst, err := t.is.Create(t.InstanceType, t.ImageID, tags, initCommand, t.SSHKey.PublicKey())
+       inst, err := t.is.Create(t.InstanceType, t.ImageID, tags, initCommand, installPublicKey)
        lgrC := t.Logger.WithField("Duration", time.Since(t0))
        if err != nil {
                // Create() might have failed due to a bug or network