14807: Don't delete existing tags when updating.
authorTom Clegg <tclegg@veritasgenetics.com>
Fri, 15 Feb 2019 20:28:34 +0000 (15:28 -0500)
committerTom Clegg <tclegg@veritasgenetics.com>
Fri, 15 Feb 2019 21:13:19 +0000 (16:13 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

lib/dispatchcloud/worker/worker.go

index 7cf4bd72f52bfa33b1bafcd0ae261e8fe0d49bf8..f70e2099843fdb0fdb2f511f49b8ea58fb05c6e8 100644 (file)
@@ -443,22 +443,24 @@ func (wkr *worker) shutdown() {
 // match. Caller must have lock.
 func (wkr *worker) saveTags() {
        instance := wkr.instance
-       have := instance.Tags()
-       want := cloud.InstanceTags{
+       tags := instance.Tags()
+       update := cloud.InstanceTags{
                tagKeyInstanceType: wkr.instType.Name,
                tagKeyIdleBehavior: string(wkr.idleBehavior),
        }
-       go func() {
-               for k, v := range want {
-                       if v == have[k] {
-                               continue
-                       }
-                       err := instance.SetTags(want)
+       save := false
+       for k, v := range update {
+               if tags[k] != v {
+                       tags[k] = v
+                       save = true
+               }
+       }
+       if save {
+               go func() {
+                       err := instance.SetTags(tags)
                        if err != nil {
                                wkr.wp.logger.WithField("Instance", instance.ID()).WithError(err).Warnf("error updating tags")
                        }
-                       break
-
-               }
-       }()
+               }()
+       }
 }