Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCPEDGE-1151: chore: k8s 1.30 / go1.22 #634

Merged
merged 8 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 2 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
exclude: ^vendor/
repos:
- repo: local
hooks:
Expand All @@ -15,22 +16,17 @@ repos:
- id: fix-byte-order-marker
- id: check-case-conflict
- id: check-executables-have-shebangs
exclude: ^vendor
- id: check-shebang-scripts-are-executable
exclude: ^vendor
- id: check-merge-conflict
- id: mixed-line-ending
- id: check-yaml
args: [-m]
exclude: ^test/e2e/testdata|^vendor
- id: check-json
- id: detect-private-key
exclude: ^vendor
- id: end-of-file-fixer
exclude: ^vendor
- id: no-commit-to-branch
- id: trailing-whitespace
exclude: ^vendor

- repo: https://github.com/openstack/bashate.git
rev: 2.1.1
Expand All @@ -47,10 +43,9 @@ repos:
# E011: Then keyword is not on same line as if or elif keyword
# E012: here doc didn't end before EOF
entry: bashate --error . --ignore=E006,E040,E020,E012,E011
exclude: ^vendor/

- repo: https://github.com/golangci/golangci-lint
rev: v1.56.0
rev: v1.59.1
hooks:
- id: golangci-lint
entry: golangci-lint run --fix
Expand All @@ -73,7 +68,6 @@ repos:
"-S",
"test/e2e/testdata/*,go.sum,go.mod",
]
exclude: ^vendor/
pass_filenames: true
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.5.0
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ARG TARGETOS
ARG TARGETARCH
ARG TARGETPLATFORM
# Build the manager binary
FROM golang:1.21 as builder
FROM golang:1.22 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
OPERATOR_VERSION ?= 0.0.1

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.29.0
ENVTEST_K8S_VERSION = 1.30.0

OPERATOR_SDK_VERSION ?= 1.34.1
CONTROLLER_TOOLS_VERSION := 0.14.0
CONTROLLER_TOOLS_VERSION := 0.15.0
CONTROLLER_RUNTIME_VERSION := $(shell awk '/sigs\.k8s\.io\/controller-runtime/ {print substr($$2, 2)}' $(SELF_DIR)/go.mod)
GINKGO_VERSION := $(shell awk '/github.com\/onsi\/ginkgo\/v2/ {print $$2}' $(SELF_DIR)/go.mod)
ENVTEST_BRANCH := release-$(shell echo $(CONTROLLER_RUNTIME_VERSION) | cut -d "." -f 1-2)
Expand Down Expand Up @@ -149,6 +149,7 @@ vet: ## Run go vet against code.

godeps-update: ## Run go mod tidy and go mod vendor.
go mod tidy && go mod vendor
patch -p1 -d $(SELF_DIR)vendor/github.com/kubernetes-csi/external-provisioner < $(SELF_DIR)hack/external-provisioner.patch

verify: ## Verify go formatting and generated files.
hack/verify-gofmt.sh
Expand Down Expand Up @@ -342,7 +343,7 @@ ginkgo: ## Download ginkgo and gomega locally if necessary.

MOCKERY = $(shell pwd)/bin/mockery
mockery: ## Download mockery and add locally if necessary
$(call go-get-tool,$(MOCKERY),github.com/vektra/mockery/v2@v2.40.3)
$(call go-get-tool,$(MOCKERY),github.com/vektra/mockery/v2@v2.43.2)

# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
Expand All @@ -359,7 +360,7 @@ ifeq (,$(shell which opm 2>/dev/null))
set -e ;\
mkdir -p $(dir $(OPM)) ;\
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.39.0/$${OS}-$${ARCH}-opm ;\
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.43.1/$${OS}-$${ARCH}-opm ;\
chmod +x $(OPM) ;\
}
else
Expand Down
7 changes: 6 additions & 1 deletion bundle/manifests/lvm.topolvm.io_lvmclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.15.0
creationTimestamp: null
name: lvmclusters.lvm.topolvm.io
spec:
Expand Down Expand Up @@ -138,11 +138,13 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchFields:
description: A list of node selector requirements
by node's fields.
Expand Down Expand Up @@ -170,14 +172,17 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
type: object
x-kubernetes-map-type: atomic
type: array
x-kubernetes-list-type: atomic
required:
- nodeSelectorTerms
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.15.0
creationTimestamp: null
name: lvmvolumegroupnodestatuses.lvm.topolvm.io
spec:
Expand Down
7 changes: 6 additions & 1 deletion bundle/manifests/lvm.topolvm.io_lvmvolumegroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.15.0
creationTimestamp: null
name: lvmvolumegroups.lvm.topolvm.io
spec:
Expand Down Expand Up @@ -103,11 +103,13 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchFields:
description: A list of node selector requirements by node's
fields.
Expand Down Expand Up @@ -135,14 +137,17 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
type: object
x-kubernetes-map-type: atomic
type: array
x-kubernetes-list-type: atomic
required:
- nodeSelectorTerms
type: object
Expand Down
6 changes: 3 additions & 3 deletions catalog/lvms-operator/v0.0.1.yaml

Large diffs are not rendered by default.

26 changes: 25 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import (
"os"

"github.com/go-logr/logr"
snapapi "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1"
"github.com/kubernetes-csi/csi-lib-utils/connection"
"github.com/kubernetes-csi/csi-lib-utils/metrics"
snapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
configv1 "github.com/openshift/api/config/v1"
secv1 "github.com/openshift/api/security/v1"
lvmv1alpha1 "github.com/openshift/lvm-operator/api/v1alpha1"
"github.com/openshift/lvm-operator/cmd/operator"
"github.com/openshift/lvm-operator/cmd/vgmanager"
"github.com/openshift/lvm-operator/internal/controllers/constants"
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/cobra"
topolvmv1 "github.com/topolvm/topolvm/api/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -19,6 +23,7 @@ import (
"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
ctrlRuntimeMetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
)

func main() {
Expand Down Expand Up @@ -69,6 +74,7 @@ func NewCmd(setupLog logr.Logger) *cobra.Command {
operator.NewCmd(&operator.Options{
Scheme: scheme,
SetupLog: setupLog,
Metrics: InitializeMetricsManager(),
}),
vgmanager.NewCmd(&vgmanager.Options{
Scheme: scheme,
Expand All @@ -78,3 +84,21 @@ func NewCmd(setupLog logr.Logger) *cobra.Command {

return cmd
}

// InitializeMetricsManager initializes the metrics manager for the operator
// and overwrites the controller runtime metrics registry with the metrics manager's registry of CSI libs
// This is needed to expose the metrics of the CSI libs to the operator's metrics endpoint.
func InitializeMetricsManager() *connection.ExtendedCSIMetricsManager {
metricsManager := &connection.ExtendedCSIMetricsManager{
CSIMetricsManager: metrics.NewCSIMetricsManagerForPlugin(constants.TopolvmCSIDriverName),
}
type managerCustom struct {
prometheus.Gatherer
prometheus.Registerer
}
ctrlRuntimeMetrics.Registry = managerCustom{
metricsManager.GetRegistry(),
metricsManager.GetRegistry().Registerer(),
}
return metricsManager
}
5 changes: 4 additions & 1 deletion cmd/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/go-logr/logr"
"github.com/kubernetes-csi/csi-lib-utils/connection"
"github.com/openshift/lvm-operator/internal/controllers/constants"
"github.com/openshift/lvm-operator/internal/controllers/lvmcluster"
"github.com/openshift/lvm-operator/internal/controllers/lvmcluster/logpassthrough"
Expand Down Expand Up @@ -59,7 +60,7 @@ import (
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"

snapapi "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1"
snapapi "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
lvmv1alpha1 "github.com/openshift/lvm-operator/api/v1alpha1"
"github.com/openshift/lvm-operator/internal/cluster"
//+kubebuilder:scaffold:imports
Expand All @@ -84,6 +85,7 @@ type Options struct {
LogPassthroughOptions *logpassthrough.Options

vgManagerCommand []string
Metrics *connection.ExtendedCSIMetricsManager
}

// NewCmd creates a new CLI command
Expand Down Expand Up @@ -285,6 +287,7 @@ func run(cmd *cobra.Command, _ []string, opts *Options) error {
DriverName: constants.TopolvmCSIDriverName,
CSIEndpoint: constants.DefaultCSISocket,
CSIOperationTimeout: 10 * time.Second,
Metrics: opts.Metrics,
})); err != nil {
return fmt.Errorf("unable to create CSI Provisioner: %w", err)
}
Expand Down
1 change: 0 additions & 1 deletion cmd/vgmanager/vgmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ func run(cmd *cobra.Command, _ []string, opts *Options) error {
if err := loadConfFile(ctx, lvmdConfig, lvmd.DefaultFileConfigPath); err != nil {
opts.SetupLog.Error(err, "lvmd config could not be loaded, starting without topolvm components and attempting bootstrap")
} else {
topoLVMD.Containerized(true)
lvclnt, vgclnt := topoLVMD.NewEmbeddedServiceClients(ctx, lvmdConfig.DeviceClasses, lvmdConfig.LvcreateOptionClasses)
suleymanakbas91 marked this conversation as resolved.
Show resolved Hide resolved

if err := controller.SetupLogicalVolumeReconcilerWithServices(mgr, mgr.GetClient(), nodeName, vgclnt, lvclnt); err != nil {
Expand Down
7 changes: 6 additions & 1 deletion config/crd/bases/lvm.topolvm.io_lvmclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.15.0
name: lvmclusters.lvm.topolvm.io
spec:
group: lvm.topolvm.io
Expand Down Expand Up @@ -134,11 +134,13 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchFields:
description: A list of node selector requirements
by node's fields.
Expand Down Expand Up @@ -166,14 +168,17 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
type: object
x-kubernetes-map-type: atomic
type: array
x-kubernetes-list-type: atomic
required:
- nodeSelectorTerms
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.15.0
name: lvmvolumegroupnodestatuses.lvm.topolvm.io
spec:
group: lvm.topolvm.io
Expand Down
7 changes: 6 additions & 1 deletion config/crd/bases/lvm.topolvm.io_lvmvolumegroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.15.0
name: lvmvolumegroups.lvm.topolvm.io
spec:
group: lvm.topolvm.io
Expand Down Expand Up @@ -103,11 +103,13 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchFields:
description: A list of node selector requirements by node's
fields.
Expand Down Expand Up @@ -135,14 +137,17 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
type: object
x-kubernetes-map-type: atomic
type: array
x-kubernetes-list-type: atomic
required:
- nodeSelectorTerms
type: object
Expand Down
Loading