diff --git a/management/server/account.go b/management/server/account.go index 2cb0be3ed..5adfa9820 100644 --- a/management/server/account.go +++ b/management/server/account.go @@ -384,12 +384,6 @@ func BuildManager(store Store, peersUpdateManager *PeersUpdateManager, idpManage shouldSave = true } - existingLabels := account.getPeerDNSLabels() - if len(existingLabels) != len(account.Peers) { - addPeerLabelsToAccount(account, existingLabels) - shouldSave = true - } - if shouldSave { err = store.SaveAccount(account) if err != nil { diff --git a/management/server/file_store.go b/management/server/file_store.go index d16b4325c..9cf3750e3 100644 --- a/management/server/file_store.go +++ b/management/server/file_store.go @@ -101,6 +101,12 @@ func restore(file string) (*FileStore, error) { account.IsDomainPrimaryAccount { store.PrivateDomain2AccountID[account.Domain] = accountID } + + // for data migration. Can be removed once most base will be with labels + existingLabels := account.getPeerDNSLabels() + if len(existingLabels) != len(account.Peers) { + addPeerLabelsToAccount(account, existingLabels) + } } // we need this persist to apply changes we made to account.Peers (we set them to Disconnected)