[arvados] created: 2.6.0-193-g45b46550e

git repository hosting git at public.arvados.org
Tue May 23 21:41:20 UTC 2023


        at  45b46550ecadf69a09390b4cefe3f16d5c1c7453 (commit)


commit 45b46550ecadf69a09390b4cefe3f16d5c1c7453
Author: Tom Clegg <tom at curii.com>
Date:   Tue May 23 17:40:06 2023 -0400

    20520: Add Containers.CloudVMs.InstanceInitCommand config.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/lib/cloud/cloudtest/cmd.go b/lib/cloud/cloudtest/cmd.go
index 0ec79e117..b3a262c7e 100644
--- a/lib/cloud/cloudtest/cmd.go
+++ b/lib/cloud/cloudtest/cmd.go
@@ -86,22 +86,23 @@ func (command) RunCommand(prog string, args []string, stdin io.Reader, stdout, s
 	tagKeyPrefix := cluster.Containers.CloudVMs.TagKeyPrefix
 	tags[tagKeyPrefix+"CloudTestPID"] = fmt.Sprintf("%d", os.Getpid())
 	if !(&tester{
-		Logger:           logger,
-		Tags:             tags,
-		TagKeyPrefix:     tagKeyPrefix,
-		SetID:            cloud.InstanceSetID(*instanceSetID),
-		DestroyExisting:  *destroyExisting,
-		ProbeInterval:    cluster.Containers.CloudVMs.ProbeInterval.Duration(),
-		SyncInterval:     cluster.Containers.CloudVMs.SyncInterval.Duration(),
-		TimeoutBooting:   cluster.Containers.CloudVMs.TimeoutBooting.Duration(),
-		Driver:           driver,
-		DriverParameters: cluster.Containers.CloudVMs.DriverParameters,
-		ImageID:          cloud.ImageID(*imageID),
-		InstanceType:     it,
-		SSHKey:           key,
-		SSHPort:          cluster.Containers.CloudVMs.SSHPort,
-		BootProbeCommand: cluster.Containers.CloudVMs.BootProbeCommand,
-		ShellCommand:     *shellCommand,
+		Logger:              logger,
+		Tags:                tags,
+		TagKeyPrefix:        tagKeyPrefix,
+		SetID:               cloud.InstanceSetID(*instanceSetID),
+		DestroyExisting:     *destroyExisting,
+		ProbeInterval:       cluster.Containers.CloudVMs.ProbeInterval.Duration(),
+		SyncInterval:        cluster.Containers.CloudVMs.SyncInterval.Duration(),
+		TimeoutBooting:      cluster.Containers.CloudVMs.TimeoutBooting.Duration(),
+		Driver:              driver,
+		DriverParameters:    cluster.Containers.CloudVMs.DriverParameters,
+		ImageID:             cloud.ImageID(*imageID),
+		InstanceType:        it,
+		SSHKey:              key,
+		SSHPort:             cluster.Containers.CloudVMs.SSHPort,
+		BootProbeCommand:    cluster.Containers.CloudVMs.BootProbeCommand,
+		InstanceInitCommand: cloud.InitCommand(cluster.Containers.CloudVMs.InstanceInitCommand),
+		ShellCommand:        *shellCommand,
 		PauseBeforeDestroy: func() {
 			if *pauseBeforeDestroy {
 				logger.Info("waiting for operator to press Enter")
diff --git a/lib/cloud/cloudtest/tester.go b/lib/cloud/cloudtest/tester.go
index 9fd7c9e74..41e8f658a 100644
--- a/lib/cloud/cloudtest/tester.go
+++ b/lib/cloud/cloudtest/tester.go
@@ -27,23 +27,24 @@ var (
 // configuration. Run() should be called only once, after assigning
 // suitable values to public fields.
 type tester struct {
-	Logger             logrus.FieldLogger
-	Tags               cloud.SharedResourceTags
-	TagKeyPrefix       string
-	SetID              cloud.InstanceSetID
-	DestroyExisting    bool
-	ProbeInterval      time.Duration
-	SyncInterval       time.Duration
-	TimeoutBooting     time.Duration
-	Driver             cloud.Driver
-	DriverParameters   json.RawMessage
-	InstanceType       arvados.InstanceType
-	ImageID            cloud.ImageID
-	SSHKey             ssh.Signer
-	SSHPort            string
-	BootProbeCommand   string
-	ShellCommand       string
-	PauseBeforeDestroy func()
+	Logger              logrus.FieldLogger
+	Tags                cloud.SharedResourceTags
+	TagKeyPrefix        string
+	SetID               cloud.InstanceSetID
+	DestroyExisting     bool
+	ProbeInterval       time.Duration
+	SyncInterval        time.Duration
+	TimeoutBooting      time.Duration
+	Driver              cloud.Driver
+	DriverParameters    json.RawMessage
+	InstanceType        arvados.InstanceType
+	ImageID             cloud.ImageID
+	SSHKey              ssh.Signer
+	SSHPort             string
+	BootProbeCommand    string
+	InstanceInitCommand cloud.InitCommand
+	ShellCommand        string
+	PauseBeforeDestroy  func()
 
 	is              cloud.InstanceSet
 	testInstance    *worker.TagVerifier
@@ -127,7 +128,7 @@ func (t *tester) Run() bool {
 	defer t.destroyTestInstance()
 
 	bootDeadline := time.Now().Add(t.TimeoutBooting)
-	initCommand := worker.TagVerifier{Instance: nil, Secret: t.secret, ReportVerified: nil}.InitCommand()
+	initCommand := worker.TagVerifier{Instance: nil, Secret: t.secret, ReportVerified: nil}.InitCommand() + "\n" + t.InstanceInitCommand
 
 	t.Logger.WithFields(logrus.Fields{
 		"InstanceType":         t.InstanceType.Name,
diff --git a/lib/config/config.default.yml b/lib/config/config.default.yml
index 8203a94de..06f4fb55e 100644
--- a/lib/config/config.default.yml
+++ b/lib/config/config.default.yml
@@ -1397,6 +1397,12 @@ Clusters:
         # https://xxxxx.blob.core.windows.net/system/Microsoft.Compute/Images/images/xxxxx.vhd
         ImageID: ""
 
+        # Shell script to run on new instances using the cloud
+        # provider's UserData (EC2) or CustomData (Azure) feature.
+        #
+        # It is not necessary to include a #!/bin/sh line.
+        InstanceInitCommand: ""
+
         # An executable file (located on the dispatcher host) to be
         # copied to cloud instances at runtime and used as the
         # container runner/supervisor. The default value is the
diff --git a/lib/dispatchcloud/worker/pool.go b/lib/dispatchcloud/worker/pool.go
index 4bf969358..3de207ffa 100644
--- a/lib/dispatchcloud/worker/pool.go
+++ b/lib/dispatchcloud/worker/pool.go
@@ -106,6 +106,7 @@ func NewPool(logger logrus.FieldLogger, arvClient *arvados.Client, reg *promethe
 		newExecutor:                    newExecutor,
 		cluster:                        cluster,
 		bootProbeCommand:               cluster.Containers.CloudVMs.BootProbeCommand,
+		instanceInitCommand:            cloud.InitCommand(cluster.Containers.CloudVMs.InstanceInitCommand),
 		runnerSource:                   cluster.Containers.CloudVMs.DeployRunnerBinary,
 		imageID:                        cloud.ImageID(cluster.Containers.CloudVMs.ImageID),
 		instanceTypes:                  cluster.InstanceTypes,
@@ -149,6 +150,7 @@ type Pool struct {
 	newExecutor                    func(cloud.Instance) Executor
 	cluster                        *arvados.Cluster
 	bootProbeCommand               string
+	instanceInitCommand            cloud.InitCommand
 	runnerSource                   string
 	imageID                        cloud.ImageID
 	instanceTypes                  map[string]arvados.InstanceType
@@ -347,7 +349,7 @@ func (wp *Pool) Create(it arvados.InstanceType) bool {
 			wp.tagKeyPrefix + tagKeyIdleBehavior:   string(IdleBehaviorRun),
 			wp.tagKeyPrefix + tagKeyInstanceSecret: secret,
 		}
-		initCmd := TagVerifier{nil, secret, nil}.InitCommand()
+		initCmd := TagVerifier{nil, secret, nil}.InitCommand() + "\n" + wp.instanceInitCommand
 		inst, err := wp.instanceSet.Create(it, wp.imageID, tags, initCmd, wp.installPublicKey)
 		wp.mtx.Lock()
 		defer wp.mtx.Unlock()
diff --git a/sdk/go/arvados/config.go b/sdk/go/arvados/config.go
index ee0e80513..1018a9f23 100644
--- a/sdk/go/arvados/config.go
+++ b/sdk/go/arvados/config.go
@@ -557,6 +557,7 @@ type CloudVMsConfig struct {
 	Enable bool
 
 	BootProbeCommand               string
+	InstanceInitCommand            string
 	DeployRunnerBinary             string
 	ImageID                        string
 	MaxCloudOpsPerSecond           int

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list