From faa5c061765fe7735cceee2e8d26869452bc0b1a Mon Sep 17 00:00:00 2001 From: Jeff Roche Date: Wed, 28 Jun 2023 10:15:37 -0400 Subject: [PATCH 1/2] feat: rhel 9 and accompanying changes --- Dockerfile | 2 +- Makefile | 4 ++-- pkg/internal/block_device.go | 19 ++----------------- pkg/vgmanager/devices_test.go | 34 +++++++++++++++++----------------- pkg/vgmanager/filter.go | 3 +-- pkg/vgmanager/filter_test.go | 8 ++------ 6 files changed, 25 insertions(+), 45 deletions(-) diff --git a/Dockerfile b/Dockerfile index 885ebec96..4e76569b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build --ldflags "-s -w" -a -o vgman RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build --ldflags "-s -w" -a -o metricsexporter cmd/metricsexporter/exporter.go # vgmanager needs 'nsenter' and other basic linux utils to correctly function -FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7 +FROM registry.access.redhat.com/ubi9/ubi-minimal:9.2 # Update the image to get the latest CVE updates RUN microdnf update -y && \ diff --git a/Makefile b/Makefile index 08d552f3c..8ac211cee 100644 --- a/Makefile +++ b/Makefile @@ -180,7 +180,7 @@ build-prometheus-alert-rules: jsonnet monitoring/mixin.libsonnet monitoring/aler $(JSONNET) -S monitoring/alerts/alerts.jsonnet > config/prometheus/prometheus_rules.yaml docker-build: ## Build docker image with the manager. - $(IMAGE_BUILD_CMD) build -t ${IMG} . + $(IMAGE_BUILD_CMD) build --platform linux/amd64 -t ${IMG} . docker-push: ## Push docker image with the manager. $(IMAGE_BUILD_CMD) push ${IMG} @@ -244,7 +244,7 @@ bundle: update-mgr-env manifests kustomize operator-sdk rename-csv build-prometh .PHONY: bundle-build bundle-build: ## Build the bundle image. - $(IMAGE_BUILD_CMD) build -f bundle.Dockerfile -t $(BUNDLE_IMG) . + $(IMAGE_BUILD_CMD) build --platform linux/amd64 -f bundle.Dockerfile -t $(BUNDLE_IMG) . .PHONY: bundle-push bundle-push: ## Push the bundle image. diff --git a/pkg/internal/block_device.go b/pkg/internal/block_device.go index 327521c2f..73c514121 100644 --- a/pkg/internal/block_device.go +++ b/pkg/internal/block_device.go @@ -57,8 +57,8 @@ type BlockDevice struct { FSType string `json:"fstype"` Size string `json:"size"` Children []BlockDevice `json:"children,omitempty"` - Rotational string `json:"rota"` - ReadOnly string `json:"ro,omitempty"` + Rotational bool `json:"rota"` + ReadOnly bool `json:"ro,omitempty"` Serial string `json:"serial,omitempty"` PartLabel string `json:"partLabel,omitempty"` @@ -118,11 +118,6 @@ func (b BlockDevice) IsUsableLoopDev(exec Executor) (bool, error) { return usable, nil } -// IsReadOnly checks is disk is read only -func (b BlockDevice) IsReadOnly() (bool, error) { - return parseBitBool(b.ReadOnly) -} - // HasChildren checks if the disk has partitions func (b BlockDevice) HasChildren() bool { return len(b.Children) > 0 @@ -151,13 +146,3 @@ func (b BlockDevice) HasBindMounts() (bool, string, error) { return false, "", nil } - -func parseBitBool(s string) (bool, error) { - switch s { - case "0", "false", "": - return false, nil - case "1", "true": - return true, nil - } - return false, fmt.Errorf("invalid value: %q", s) -} diff --git a/pkg/vgmanager/devices_test.go b/pkg/vgmanager/devices_test.go index aecd2fee9..52506e10b 100644 --- a/pkg/vgmanager/devices_test.go +++ b/pkg/vgmanager/devices_test.go @@ -55,7 +55,7 @@ func TestAvailableDevicesForVG(t *testing.T) { Name: "/dev/nvme1n1", Type: "disk", Size: "279.4G", - ReadOnly: "false", + ReadOnly: false, State: "live", KName: "/dev/nvme1n1", }, @@ -74,7 +74,7 @@ func TestAvailableDevicesForVG(t *testing.T) { Name: "/dev/nvme1n1", Type: "disk", Size: "279.4G", - ReadOnly: "true", + ReadOnly: true, State: "live", KName: "/dev/nvme1n1", }, @@ -93,7 +93,7 @@ func TestAvailableDevicesForVG(t *testing.T) { Name: "/dev/nvme1n1", Type: "disk", Size: "279.4G", - ReadOnly: "false", + ReadOnly: false, State: "suspended", KName: "/dev/nvme1n1", }, @@ -112,7 +112,7 @@ func TestAvailableDevicesForVG(t *testing.T) { Name: "/dev/nvme1n1", Type: "disk", Size: "279.4G", - ReadOnly: "false", + ReadOnly: false, State: "live", KName: "/dev/nvme1n1", PartLabel: "BIOS-BOOT", @@ -132,7 +132,7 @@ func TestAvailableDevicesForVG(t *testing.T) { Name: "/dev/nvme1n1", Type: "disk", Size: "279.4G", - ReadOnly: "false", + ReadOnly: false, State: "live", KName: "/dev/nvme1n1", PartLabel: "reserved", @@ -152,7 +152,7 @@ func TestAvailableDevicesForVG(t *testing.T) { Name: "/dev/nvme1n1", Type: "disk", Size: "279.4G", - ReadOnly: "false", + ReadOnly: false, State: "live", KName: "/dev/nvme1n1", FSType: "ext4", @@ -172,13 +172,13 @@ func TestAvailableDevicesForVG(t *testing.T) { Name: "/dev/nvme1n1", Type: "disk", Size: "279.4G", - ReadOnly: "false", + ReadOnly: false, State: "live", KName: "/dev/nvme1n1", Children: []internal.BlockDevice{ { Name: "/dev/nvme1n1p1", - ReadOnly: "true", + ReadOnly: true, }, }, }, @@ -197,7 +197,7 @@ func TestAvailableDevicesForVG(t *testing.T) { Name: "/dev/nvme1n1", Type: "disk", Size: "279.4G", - ReadOnly: "false", + ReadOnly: false, State: "live", KName: "/dev/nvme1n1", Children: []internal.BlockDevice{ @@ -205,7 +205,7 @@ func TestAvailableDevicesForVG(t *testing.T) { Name: "/dev/nvme1n1p1", Type: "disk", Size: "50G", - ReadOnly: "false", + ReadOnly: false, State: "live", KName: "/dev/nvme1n1p1", }, @@ -213,7 +213,7 @@ func TestAvailableDevicesForVG(t *testing.T) { Name: "/dev/nvme1n1p2", Type: "disk", Size: "50G", - ReadOnly: "false", + ReadOnly: false, State: "live", KName: "/dev/nvme1n1p2", }, @@ -242,7 +242,7 @@ func TestAvailableDevicesForVG(t *testing.T) { KName: calculateDevicePath(t, "nvme1n1p1"), Type: "disk", Size: "279.4G", - ReadOnly: "false", + ReadOnly: false, State: "live", }, }, @@ -286,7 +286,7 @@ func TestAvailableDevicesForVG(t *testing.T) { KName: calculateDevicePath(t, "nvme1n1p1"), Type: "disk", Size: "279.4G", - ReadOnly: "true", + ReadOnly: true, State: "live", }, }, @@ -320,7 +320,7 @@ func TestAvailableDevicesForVG(t *testing.T) { KName: calculateDevicePath(t, "nvme1n1p1"), Type: "disk", Size: "279.4G", - ReadOnly: "false", + ReadOnly: false, State: "live", }, }, @@ -352,7 +352,7 @@ func TestAvailableDevicesForVG(t *testing.T) { KName: calculateDevicePath(t, "nvme1n1p1"), Type: "disk", Size: "279.4G", - ReadOnly: "false", + ReadOnly: false, State: "live", }, }, @@ -384,7 +384,7 @@ func TestAvailableDevicesForVG(t *testing.T) { KName: calculateDevicePath(t, "nvme1n1p1"), Type: "disk", Size: "279.4G", - ReadOnly: "false", + ReadOnly: false, State: "live", Children: []internal.BlockDevice{ { @@ -392,7 +392,7 @@ func TestAvailableDevicesForVG(t *testing.T) { KName: calculateDevicePath(t, "nvme1n1p2"), Type: "disk", Size: "4G", - ReadOnly: "false", + ReadOnly: false, State: "live", }, }, diff --git a/pkg/vgmanager/filter.go b/pkg/vgmanager/filter.go index 0d93add55..c0991f79a 100644 --- a/pkg/vgmanager/filter.go +++ b/pkg/vgmanager/filter.go @@ -40,8 +40,7 @@ const ( // they verify that the device itself is good to use var FilterMap = map[string]func(internal.BlockDevice, internal.Executor) (bool, error){ notReadOnly: func(dev internal.BlockDevice, _ internal.Executor) (bool, error) { - readOnly, err := dev.IsReadOnly() - return !readOnly, err + return !dev.ReadOnly, nil }, notSuspended: func(dev internal.BlockDevice, _ internal.Executor) (bool, error) { diff --git a/pkg/vgmanager/filter_test.go b/pkg/vgmanager/filter_test.go index df6d10553..f6af872d2 100644 --- a/pkg/vgmanager/filter_test.go +++ b/pkg/vgmanager/filter_test.go @@ -16,12 +16,8 @@ type filterTestCase struct { func TestNotReadOnly(t *testing.T) { testcases := []filterTestCase{ - {label: "tc empty string", device: internal.BlockDevice{ReadOnly: ""}, expected: true, expectErr: false}, - {label: "tc false", device: internal.BlockDevice{ReadOnly: "false"}, expected: true, expectErr: false}, - {label: "tc true", device: internal.BlockDevice{ReadOnly: "true"}, expected: false, expectErr: false}, - {label: "tc 0", device: internal.BlockDevice{ReadOnly: "0"}, expected: true, expectErr: false}, - {label: "tc 1", device: internal.BlockDevice{ReadOnly: "1"}, expected: false, expectErr: false}, - {label: "tc invalid string", device: internal.BlockDevice{ReadOnly: "test"}, expected: true, expectErr: true}, + {label: "tc false", device: internal.BlockDevice{ReadOnly: false}, expected: true, expectErr: false}, + {label: "tc true", device: internal.BlockDevice{ReadOnly: true}, expected: false, expectErr: false}, } for _, tc := range testcases { result, err := FilterMap[notReadOnly](tc.device, nil) From 7937eb43d5cef0ef514a6868434bc7497e789a50 Mon Sep 17 00:00:00 2001 From: Jeff Roche Date: Thu, 29 Jun 2023 08:48:06 -0400 Subject: [PATCH 2/2] fix: removing the m1 mac changes --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8ac211cee..08d552f3c 100644 --- a/Makefile +++ b/Makefile @@ -180,7 +180,7 @@ build-prometheus-alert-rules: jsonnet monitoring/mixin.libsonnet monitoring/aler $(JSONNET) -S monitoring/alerts/alerts.jsonnet > config/prometheus/prometheus_rules.yaml docker-build: ## Build docker image with the manager. - $(IMAGE_BUILD_CMD) build --platform linux/amd64 -t ${IMG} . + $(IMAGE_BUILD_CMD) build -t ${IMG} . docker-push: ## Push docker image with the manager. $(IMAGE_BUILD_CMD) push ${IMG} @@ -244,7 +244,7 @@ bundle: update-mgr-env manifests kustomize operator-sdk rename-csv build-prometh .PHONY: bundle-build bundle-build: ## Build the bundle image. - $(IMAGE_BUILD_CMD) build --platform linux/amd64 -f bundle.Dockerfile -t $(BUNDLE_IMG) . + $(IMAGE_BUILD_CMD) build -f bundle.Dockerfile -t $(BUNDLE_IMG) . .PHONY: bundle-push bundle-push: ## Push the bundle image.