From: Tom Clegg Date: Fri, 15 Feb 2019 20:28:34 +0000 (-0500) Subject: 14807: Don't delete existing tags when updating. X-Git-Tag: 1.4.0~142^2~16 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/3d662ef38da0395af4e477acd6c3a20de9280084?hp=f6d551a68e30f533676bcf7ed17b199b21990c7b 14807: Don't delete existing tags when updating. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- diff --git a/lib/dispatchcloud/worker/worker.go b/lib/dispatchcloud/worker/worker.go index 7cf4bd72f5..f70e209984 100644 --- a/lib/dispatchcloud/worker/worker.go +++ b/lib/dispatchcloud/worker/worker.go @@ -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 - - } - }() + }() + } }