From 5152523ade68334fe9fc0805e4cfb22f4b28e837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Sat, 27 Jan 2024 14:02:59 -0500 Subject: [PATCH 1/3] incusd/db/warningtype: gofmt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- .../server/db/warningtype/warning_type.go | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/internal/server/db/warningtype/warning_type.go b/internal/server/db/warningtype/warning_type.go index 6f7ab073ea3..d177127dc7c 100644 --- a/internal/server/db/warningtype/warning_type.go +++ b/internal/server/db/warningtype/warning_type.go @@ -60,30 +60,30 @@ const ( // TypeNames associates a warning code to its name. var TypeNames = map[Type]string{ - Undefined: "Undefined warning", - MissingCGroupBlkio: "Couldn't find the CGroup blkio", - MissingCGroupBlkioWeight: "Couldn't find the CGroup blkio.weight", - MissingCGroupCPUController: "Couldn't find the CGroup CPU controller", - MissingCGroupCPUsetController: "Couldn't find the CGroup CPUset controller", - MissingCGroupCPUacctController: "Couldn't find the CGroup CPUacct controller", - MissingCGroupDevicesController: "Couldn't find the CGroup devices controller", - MissingCGroupFreezerController: "Couldn't find the CGroup freezer controller", - MissingCGroupHugetlbController: "Couldn't find the CGroup hugetlb controller", - MissingCGroupMemoryController: "Couldn't find the CGroup memory controller", - MissingCGroupPidsController: "Couldn't find the CGroup pids controller", - MissingCGroupMemorySwapAccounting: "Couldn't find the CGroup memory swap accounting", - ClusterTimeSkew: "Time skew detected between leader and local", - AppArmorNotAvailable: "AppArmor support has been disabled", - MissingVirtiofsd: "Missing virtiofsd", - AppArmorDisabledDueToRawDnsmasq: "Skipping AppArmor for dnsmasq due to raw.dnsmasq being set", - LargerIPv6PrefixThanSupported: "IPv6 networks with a prefix larger than 64 aren't properly supported by dnsmasq", - ProxyBridgeNetfilterNotEnabled: "Proxy bridge netfilter not enabled", - NetworkUnvailable: "Network unavailable", - OfflineClusterMember: "Offline cluster member", - InstanceAutostartFailure: "Failed to autostart instance", - InstanceTypeNotOperational: "Instance type not operational", - StoragePoolUnvailable: "Storage pool unavailable", - UnableToUpdateClusterCertificate: "Unable to update cluster certificate", + Undefined: "Undefined warning", + MissingCGroupBlkio: "Couldn't find the CGroup blkio", + MissingCGroupBlkioWeight: "Couldn't find the CGroup blkio.weight", + MissingCGroupCPUController: "Couldn't find the CGroup CPU controller", + MissingCGroupCPUsetController: "Couldn't find the CGroup CPUset controller", + MissingCGroupCPUacctController: "Couldn't find the CGroup CPUacct controller", + MissingCGroupDevicesController: "Couldn't find the CGroup devices controller", + MissingCGroupFreezerController: "Couldn't find the CGroup freezer controller", + MissingCGroupHugetlbController: "Couldn't find the CGroup hugetlb controller", + MissingCGroupMemoryController: "Couldn't find the CGroup memory controller", + MissingCGroupPidsController: "Couldn't find the CGroup pids controller", + MissingCGroupMemorySwapAccounting: "Couldn't find the CGroup memory swap accounting", + ClusterTimeSkew: "Time skew detected between leader and local", + AppArmorNotAvailable: "AppArmor support has been disabled", + MissingVirtiofsd: "Missing virtiofsd", + AppArmorDisabledDueToRawDnsmasq: "Skipping AppArmor for dnsmasq due to raw.dnsmasq being set", + LargerIPv6PrefixThanSupported: "IPv6 networks with a prefix larger than 64 aren't properly supported by dnsmasq", + ProxyBridgeNetfilterNotEnabled: "Proxy bridge netfilter not enabled", + NetworkUnvailable: "Network unavailable", + OfflineClusterMember: "Offline cluster member", + InstanceAutostartFailure: "Failed to autostart instance", + InstanceTypeNotOperational: "Instance type not operational", + StoragePoolUnvailable: "Storage pool unavailable", + UnableToUpdateClusterCertificate: "Unable to update cluster certificate", } // Severity returns the severity of the warning type. From 243ee1939c959bd7f3f615b4b8273b9ed1307b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Sat, 27 Jan 2024 23:27:34 -0500 Subject: [PATCH 2/3] incusd/loki: Sort lifecycle context keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- internal/server/loki/loki.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/server/loki/loki.go b/internal/server/loki/loki.go index bfa02c55f2d..7a2b2e06777 100644 --- a/internal/server/loki/loki.go +++ b/internal/server/loki/loki.go @@ -273,8 +273,19 @@ func (c *Client) HandleEvent(event api.Event) { context["requester-username"] = lifecycleEvent.Requestor.Username } + // Get a sorted list of context keys. + keys := make([]string, 0, len(context)) + + for k := range context { + keys = append(keys, k) + } + + sort.Strings(keys) + // Add key-value pairs as labels but don't override any labels. - for k, v := range context { + for _, k := range keys { + v := context[k] + if util.ValueInSlice(k, c.cfg.labels) { _, ok := entry.labels[k] if !ok { From 48920a1c8cd0958459130d76b9afbd0dab5a6506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Sun, 28 Jan 2024 01:05:56 -0500 Subject: [PATCH 3/3] incusd/cluster: Fix evacuation of stopped instances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- cmd/incusd/api_cluster.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cmd/incusd/api_cluster.go b/cmd/incusd/api_cluster.go index ece33225fbf..5de9fa83cb8 100644 --- a/cmd/incusd/api_cluster.go +++ b/cmd/incusd/api_cluster.go @@ -3316,13 +3316,15 @@ func evacuateInstances(ctx context.Context, opts evacuateOpts) error { // Stop the instance if needed. isRunning := inst.IsRunning() - if opts.stopInstance != nil && isRunning && action != "live-migrate" { - metadata["evacuation_progress"] = fmt.Sprintf("Stopping %q in project %q", inst.Name(), instProject.Name) - _ = opts.op.UpdateMetadata(metadata) + if action != "live-migrate" { + if opts.stopInstance != nil && isRunning { + metadata["evacuation_progress"] = fmt.Sprintf("Stopping %q in project %q", inst.Name(), instProject.Name) + _ = opts.op.UpdateMetadata(metadata) - err := opts.stopInstance(inst, action) - if err != nil { - return err + err := opts.stopInstance(inst, action) + if err != nil { + return err + } } if action != "migrate" {