Skip to content

Commit a03c42d

Browse files
committed
Upgrade to operator-sdk 1.41.1
Rescaffold the watcher-operator to operator-sdk 1.41.1, which includes: - Reorganize project structure (pkg/ -> internal/) - Move webhook implementations to internal/webhook/v1beta1/ - Add new cmd/main.go entrypoint with updated controller initialization - Update RBAC, certmanager, and prometheus configurations - Enhance network policies for metrics and webhook traffic - Set watcher as defaulting resource in PROJECT file - Remove auto-generated test suite scaffolding - Update build workflow and Dockerfile to version 1.41.1 This upgrade modernizes the operator structure and aligns with the latest operator-sdk best practices. Jira: OSPRH-22014 Depends-On: openstack-k8s-operators/openstack-operator#1683
1 parent 35dcc7e commit a03c42d

File tree

183 files changed

+1625
-784
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

183 files changed

+1625
-784
lines changed

.ci-operator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
build_root_image:
22
name: tools
33
namespace: openstack-k8s-operators
4-
tag: ci-build-root-golang-1.24-sdk-1.31
4+
tag: ci-build-root-golang-1.24-sdk-1.41.1

.github/workflows/build-watcher-operator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
with:
1717
operator_name: watcher
1818
go_version: 1.24.x
19-
operator_sdk_version: 1.31.0
19+
operator_sdk_version: 1.41.1
2020
secrets:
2121
IMAGENAMESPACE: ${{ secrets.IMAGENAMESPACE }}
2222
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}

.github/workflows/force-bump-pr-manual.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ jobs:
99
with:
1010
operator_name: watcher
1111
branch_name: ${{ github.ref_name }}
12-
custom_image: quay.io/openstack-k8s-operators/openstack-k8s-operators-ci-build-tools:golang-1.24-sdk-1.31
12+
custom_image: quay.io/openstack-k8s-operators/openstack-k8s-operators-ci-build-tools:golang-1.24-sdk-1.41.1
1313
secrets:
1414
FORCE_BUMP_PULL_REQUEST_PAT: ${{ secrets.FORCE_BUMP_PULL_REQUEST_PAT }}

.github/workflows/force-bump-pr-scheduled.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ jobs:
1010
uses: openstack-k8s-operators/openstack-k8s-operators-ci/.github/workflows/force-bump-branches.yaml@main
1111
with:
1212
operator_name: watcher
13-
custom_image: quay.io/openstack-k8s-operators/openstack-k8s-operators-ci-build-tools:golang-1.24-sdk-1.31
13+
custom_image: quay.io/openstack-k8s-operators/openstack-k8s-operators-ci-build-tools:golang-1.24-sdk-1.41.1
1414
secrets:
1515
FORCE_BUMP_PULL_REQUEST_PAT: ${{ secrets.FORCE_BUMP_PULL_REQUEST_PAT }}

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ repos:
7979
# E012: here doc didn't end before EOF
8080

8181
- repo: https://github.com/golangci/golangci-lint
82-
rev: v2.4.0
82+
rev: v2.6.1
8383
hooks:
8484
- id: golangci-lint-full
8585
args: ["-v"]

.zuul.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
A zuul job building content from OpenDev epoxy release.
139139
parent: openstack-meta-content-provider
140140
vars:
141+
cifmw_install_yamls_sdk_version: v1.41.1
141142
cifmw_bop_openstack_release: epoxy
142143
cifmw_bop_dlrn_baseurl: "https://trunk.rdoproject.org/centos9-epoxy"
143144
cifmw_repo_setup_branch: epoxy
@@ -208,6 +209,7 @@
208209
nodeset: centos-stream-10-vexxhost
209210
parent: openstack-meta-content-provider
210211
vars:
212+
cifmw_install_yamls_sdk_version: v1.41.1
211213
cifmw_bop_openstack_release: master
212214
cifmw_bop_dlrn_baseurl: "https://trunk.rdoproject.org/centos10-master"
213215
cifmw_repo_setup_branch: master

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ RUN mkdir -p ${DEST_ROOT}/usr/local/bin/
2525
RUN if [ ! -f $CACHITO_ENV_FILE ]; then go mod download ; fi
2626

2727
# Build manager
28-
RUN if [ -f $CACHITO_ENV_FILE ] ; then source $CACHITO_ENV_FILE ; fi ; env ${GO_BUILD_EXTRA_ENV_ARGS} go build ${GO_BUILD_EXTRA_ARGS} -a -o ${DEST_ROOT}/manager main.go
28+
RUN if [ -f $CACHITO_ENV_FILE ] ; then source $CACHITO_ENV_FILE ; fi ; env ${GO_BUILD_EXTRA_ENV_ARGS} go build ${GO_BUILD_EXTRA_ARGS} -a -o ${DEST_ROOT}/manager cmd/main.go
2929

3030

3131
RUN cp -r templates ${DEST_ROOT}/templates

Makefile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ endif
4848

4949
# Set the Operator SDK version to use. By default, what is installed on the system is used.
5050
# This is useful for CI or a project to utilize a specific version of the operator-sdk toolkit.
51-
OPERATOR_SDK_VERSION ?= v1.31.0
51+
OPERATOR_SDK_VERSION ?= v1.41.1
5252

5353
# Image URL to use all building/pushing image targets
5454
DEFAULT_IMG ?= quay.io/openstack-k8s-operators/watcher-operator:latest
@@ -146,22 +146,22 @@ PROC_CMD = --procs ${PROCS}
146146
.PHONY: test
147147
test: manifests generate fmt vet envtest ginkgo ## Run tests.
148148
OPERATOR_TEMPLATES="$(PWD)/templates" \
149-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" $(GINKGO) --trace --cover --coverpkg=../../pkg/watcher,../../controllers,../../api/v1beta1 --coverprofile cover.out --covermode=atomic ${PROC_CMD} $(GINKGO_ARGS) ./tests/...
149+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" $(GINKGO) --trace --cover --coverpkg=../../internal/watcher,../../internal/controller,../../api/v1beta1 --coverprofile cover.out --covermode=atomic ${PROC_CMD} $(GINKGO_ARGS) ./test/...
150150

151151

152152
##@ Build
153153

154154
.PHONY: build
155155
build: generate fmt vet ## Build manager binary.
156-
go build -o bin/manager main.go
156+
go build -o bin/manager cmd/main.go
157157

158158
.PHONY: run
159159
run: export METRICS_PORT?=24604
160160
run: export HEALTH_PORT?=24605
161161
run: export PPROF_PORT?=8082
162162
run: export ENABLE_WEBHOOKS?=false
163163
run: manifests generate fmt vet ## Run a controller from your host.
164-
go run ./main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)"
164+
go run ./cmd/main.go -metrics-bind-address ":$(METRICS_PORT)" -health-probe-bind-address ":$(HEALTH_PORT)" -pprof-bind-address ":$(PPROF_PORT)"
165165

166166

167167
# Extra vars which will be passed to the Docker-build
@@ -212,7 +212,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest
212212
GINKGO ?= $(LOCALBIN)/ginkgo
213213

214214
## Tool Versions
215-
KUSTOMIZE_VERSION ?= v3.8.7
215+
KUSTOMIZE_VERSION ?= v5.6.0
216216
CONTROLLER_TOOLS_VERSION ?= v0.18.0
217217
SETUP_ENVTEST_VERSION ?= release-0.22
218218

@@ -391,6 +391,10 @@ watcher: export WATCHER_DECISION_ENGINE_IMAGE=${WATCHER_DECISION_ENGINE_CI_IMAGE
391391
watcher: export WATCHER_APPLIER_IMAGE=${WATCHER_APPLIER_CI_IMAGE}
392392
watcher: export CATALOG_IMG=${CATALOG_IMAGE}
393393
watcher: ## Install watcher operator via olm
394+
# explicitly to delete any running watcher-operator deployments from openstack-operator here as
395+
# label selectors can change and installing a service catalog/index like this alongside
396+
# openstack-operator (what CI appears to do?) is not recommended
397+
oc delete deployment watcher-operator-controller-manager -n openstack-operators --ignore-not-found=true
394398
bash ci/olm.sh
395399
oc apply -f ci/olm.yaml
396400
timeout 300s bash -c "while ! (oc get csv -n openshift-operators -l operators.coreos.com/cluster-observability-operator.openshift-operators -o jsonpath='{.items[*].status.phase}' | grep Succeeded); do sleep 10; done"
@@ -424,7 +428,7 @@ watcher_cleanup: ## Cleaning watcher operator via olm
424428

425429
KUTTL_SUITE ?= default
426430
KUTTL_NAMESPACE ?= watcher-kuttl-$(KUTTL_SUITE)
427-
KUTTL_SUITE_DIR ?= tests/kuttl/test-suites/$(KUTTL_SUITE)
431+
KUTTL_SUITE_DIR ?= test/kuttl/test-suites/$(KUTTL_SUITE)
428432

429433
.PHONY: stop_watcher_integrated
430434
stop_watcher_integrated:

PROJECT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# More info: https://book.kubebuilder.io/reference/project-config.html
55
domain: openstack.org
66
layout:
7-
- go.kubebuilder.io/v3
7+
- go.kubebuilder.io/v4
88
plugins:
99
manifests.sdk.operatorframework.io/v2: {}
1010
scorecard.sdk.operatorframework.io/v2: {}

api/v1beta1/common_types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ type PasswordSelector struct {
147147
Service *string `json:"service"`
148148
}
149149

150-
// WatcherSubCrsCommon
150+
// WatcherSubCrsCommon defines the common fields for Watcher sub-CRs
151151
type WatcherSubCrsCommon struct {
152152
// +kubebuilder:validation:Optional
153153
// The service specific Container Image URL (will be set to environmental default if empty)
@@ -189,6 +189,7 @@ type WatcherSubCrsTemplate struct {
189189
TopologyRef *topologyv1.TopoRef `json:"topologyRef,omitempty"`
190190
}
191191

192+
// WatcherImages defines the container images for all Watcher services
192193
type WatcherImages struct {
193194
// +kubebuilder:validation:Required
194195
// APIContainerImageURL
@@ -203,6 +204,7 @@ type WatcherImages struct {
203204
ApplierContainerImageURL string `json:"applierContainerImageURL"`
204205
}
205206

207+
// Default sets default values for WatcherImages based on the provided defaults
206208
func (r *WatcherImages) Default(defaults WatcherDefaults) {
207209
if r.APIContainerImageURL == "" {
208210
r.APIContainerImageURL = defaults.APIContainerImageURL
@@ -215,8 +217,7 @@ func (r *WatcherImages) Default(defaults WatcherDefaults) {
215217
}
216218
}
217219

218-
// SetupDefaults - initializes any CRD field defaults based on environment variables (the defaulting mechanism itself is implemented via webhooks)
219-
220+
// SetupDefaults initializes any CRD field defaults based on environment variables (the defaulting mechanism itself is implemented via webhooks)
220221
func SetupDefaults() {
221222
// Acquire environmental defaults and initialize Watcher defaults with them
222223
watcherDefaults := WatcherDefaults{

0 commit comments

Comments
 (0)