Skip to content

CSPL-3675 Update Operator-SDK to v1.39 #1488

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

Merged
merged 79 commits into from
Jun 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
a963e2e
v1.33 migration
Apr 14, 2025
3690262
Upgrade bias language excl
Apr 14, 2025
9a33b9b
Upgrade bias language excl
Apr 14, 2025
6810b82
Merge remote-tracking branch 'origin/CSPL-3675-operator-sdk' into CSP…
Apr 14, 2025
452fc63
v.1.34.0 migration
Apr 14, 2025
d15891c
v.1.34.0 migration
Apr 14, 2025
9943654
fix docker-buildx
Apr 14, 2025
3029bbe
fix docker-buildx
Apr 14, 2025
a175dce
fix docker-buildx
Apr 14, 2025
0f32b96
v 1.3.6 migration
Apr 15, 2025
10bbfad
v 1.3.8 migration
Apr 15, 2025
04e2782
v 1.3.9 migration
Apr 16, 2025
c0adb8b
Merge branch 'develop' into CSPL-3675-operator-sdk
Apr 16, 2025
2b73278
Update controller.go
Apr 22, 2025
787eb60
Update ns watching
Apr 23, 2025
b71204f
Update ns watching
Apr 23, 2025
fababeb
fix tests
Apr 23, 2025
281162a
fix tests
Apr 23, 2025
c222936
fix test
Apr 23, 2025
98c8396
fixed test cases fo rfake client
Apr 29, 2025
24244ab
fixed test cases
Apr 29, 2025
559f255
fixed v3 test cases
Apr 29, 2025
2249a5f
fixed test cases
Apr 29, 2025
7fe764c
upgrade operator crd
Apr 30, 2025
68470f3
use WithAuthenticationAndAuthorization filter provider
Apr 30, 2025
2b0251b
fix gomod
Apr 30, 2025
2dfa07f
merge
May 6, 2025
5feaef9
Up the golang version
May 6, 2025
a1da4d7
Up the golang version
May 6, 2025
8b2819a
Up the golang version
May 6, 2025
737f0eb
Up the golang version
May 6, 2025
9d9a281
Up the golang version
May 6, 2025
68d8df5
Fix test command
May 6, 2025
e0a6c07
Fix test command
May 6, 2025
316b079
Fix controller path in coverage out
May 7, 2025
14c8a65
fix
May 7, 2025
9aa7d82
fix docker-buildx
May 7, 2025
203e2fa
fix docker-buildx
May 7, 2025
1d98d8d
Up goland version in dockerfile
May 7, 2025
78c309d
Rename package name
May 8, 2025
fdff2b5
change order of testing
May 8, 2025
f2f3067
only test splkcontroller package
May 12, 2025
6df2d60
remove goveralls
May 15, 2025
9b777b9
add --keep-separate-coverprofiles to unit tests
rlieberman-splunk May 20, 2025
d702fdd
comment out TestAddToManager
May 22, 2025
6dd18d0
add err message
May 22, 2025
6741fa3
add import
May 22, 2025
188e015
add test logging
May 23, 2025
fa82d7d
-
May 23, 2025
82da34d
-
May 23, 2025
6f6208c
-
May 23, 2025
e1094bf
Fix testaddtomanager
May 23, 2025
6614f17
fix test
May 27, 2025
881df34
Revert "remove goveralls"
May 27, 2025
cc6c5e1
Revert "add --keep-separate-coverprofiles to unit tests"
May 27, 2025
9dbd0f4
fix main.go
May 30, 2025
325d56f
Merge branch 'develop' into CSPL-3675-operator-sdk
Jun 2, 2025
d1134dd
rename
Jun 2, 2025
7cb5a92
fix typo
Jun 10, 2025
f2cb1f0
Merge branch 'develop' into CSPL-3675-operator-sdk
Jun 10, 2025
533e251
Add stabilization phase
Jun 11, 2025
6421ae9
Increase stabilization period
Jun 12, 2025
a99e52e
comment out verify
Jun 16, 2025
b06c029
run int tests
Jun 17, 2025
2e37489
Apply review suggestions
Jun 17, 2025
9e7b92e
Remove onlycontrollerowner
Jun 17, 2025
2f1c1b4
Remove comment
Jun 17, 2025
4653468
rename to intController
Jun 23, 2025
aabe029
test
kasiakoziol Jun 24, 2025
6512b4f
Add debug logs for appframeworksS1 test
Jun 25, 2025
b2d444a
test
kasiakoziol Jun 26, 2025
6547244
test
kasiakoziol Jun 26, 2025
0669f68
test
kasiakoziol Jun 26, 2025
ca7997e
test
kasiakoziol Jun 27, 2025
dbc490e
test
kasiakoziol Jun 27, 2025
e245363
fix
kasiakoziol Jun 27, 2025
e3b4312
test owner type in controller
kasiakoziol Jun 27, 2025
4a61c5d
cleanup
kasiakoziol Jun 27, 2025
c762723
Remove branch form int testing
Jun 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .biased_lang_exclude
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ api/v3/licensemaster_types.go
api/v3/zz_generated.deepcopy.go
api/v3/common_types.go
pkg/splunk/enterprise/licensemaster.go
controllers/licensemaster_controller.go
controller/licensemaster_controller.go
tools/k8s_collectors/k8s-systeminfo-collector.sh
controllers/common/predicate.go
controller/common/predicate.go
pkg/splunk/enterprise/finalizers.go
controllers/monitoringconsole_controller.go
controller/monitoringconsole_controller.go
pkg/splunk/enterprise/events.go
#Exceptions for dual support of cluster manager
api/v3/clustermaster_types.go
Expand All @@ -47,9 +47,9 @@ config/rbac/clustermaster_editor_role.yaml
config/rbac/clustermaster_viewer_role.yaml
config/rbac/clustermanager_editor_role.yaml
config/rbac/clustermanager_viewer_role.yaml
controllers/clustermaster_controller.go
controllers/clustermaster_controller_test.go
controllers/licensemaster_controller_test.go
controller/clustermaster_controller.go
controller/clustermaster_controller_test.go
controller/licensemaster_controller_test.go
kuttl/tests/smoke/clustered-master-deployment-c3/00-assert.yaml
kuttl/tests/smoke/clustered-master-deployment-c3/00-deploy-clustermanager.yaml
kuttl/tests/smoke/clustered-master-deployment-c3/01-deploy-indexercluster.yaml
Expand Down Expand Up @@ -82,7 +82,7 @@ main.go
PROJECT
pkg/
deploy/
controllers/
internal/controller/
test/
docs/
README.md
Expand Down
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
OPERATOR_SDK_VERSION=v1.31.0
OPERATOR_SDK_VERSION=v1.39.0
REVIEWERS=vivekr-splunk,rlieberman-splunk,patrykw-splunk,Igor-splunk,kasiakoziol
GO_VERSION=1.23.0
AWSCLI_URL=https://awscli.amazonaws.com/awscli-exe-linux-x86_64-2.8.6.zip
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ARG BASE_IMAGE=registry.access.redhat.com/ubi8/ubi-minimal@sha256
ARG BASE_IMAGE_VERSION=b2a1bec3dfbc7a14a1d84d98934dfe8fdde6eb822a211286601cf109cbccb075

# Build the manager binary
FROM golang:1.23.0 AS builder
FROM golang:1.24.2 AS builder

WORKDIR /workspace

Expand All @@ -19,16 +19,16 @@ COPY go.sum go.sum
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY controllers/ controllers/
COPY internal/controller/ internal/controller/
COPY pkg/ pkg/
COPY tools/ tools/
COPY hack hack/

# Build
# TARGETOS and TARGETARCH are provided(inferred) by buildx via the --platforms flag
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go

# Use BASE_IMAGE as the base image
FROM ${BASE_IMAGE}:${BASE_IMAGE_VERSION}
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile.distroless
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.23.0 AS builder
FROM golang:1.24.2 AS builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -9,16 +9,16 @@ COPY go.sum go.sum
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY controllers/ controllers/
COPY internal/controller/ internal/controller/
COPY pkg/ pkg/
COPY tools/ tools/
COPY hack hack/

# Build
# TARGETOS and TARGETARCH are provided(inferred) by buildx via the --platforms flag
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless
Expand Down
53 changes: 31 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ${ENVIRONMENT}:
VERSION ?= 2.8.0

# SPLUNK_ENTERPRISE_IMAGE defines the splunk docker tag that is used as default image.
SPLUNK_ENTERPRISE_IMAGE ?= "docker.io/splunk/splunk:edge"
SPLUNK_ENTERPRISE_IMAGE ?= "docker.io/splunk/splunk"

# WATCH_NAMESPACE defines if its clusterwide operator or namespace specific
# by default we leave it as clusterwide if it has to be namespace specific,
Expand Down Expand Up @@ -54,7 +54,7 @@ BUNDLE_IMG ?= ${IMAGE_TAG_BASE}-bundle:v${VERSION}
# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.26.0
ENVTEST_K8S_VERSION = 1.31.0

ignore-not-found ?= True

Expand Down Expand Up @@ -127,20 +127,20 @@ scheck: ## Run static check against code
go install honnef.co/go/tools/cmd/[email protected]
staticcheck ./...

vet: setup/ginkgo ## Run go vet against code.
vet: setup/ginkgo ## Run go vet against code.
go vet ./...

test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use ${ENVTEST_K8S_VERSION} --bin-dir $(LOCALBIN) -p path)" ginkgo --junit-report=unit_test.xml --output-dir=`pwd` -vv --trace --keep-going --timeout=3h --cover --covermode=count --coverprofile=coverage.out ./pkg/splunk/common ./pkg/splunk/enterprise ./pkg/splunk/controller ./pkg/splunk/client ./pkg/splunk/util ./controllers
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use ${ENVTEST_K8S_VERSION} --bin-dir $(LOCALBIN) -p path)" ginkgo --junit-report=unit_test.xml --output-dir=`pwd` -vv --trace --keep-going --timeout=3h --cover --covermode=count --coverprofile=coverage.out ./pkg/splunk/common ./pkg/splunk/enterprise ./pkg/splunk/client ./pkg/splunk/util ./internal/controller ./pkg/splunk/splkcontroller


##@ Build

build: setup/ginkgo manifests generate fmt vet ## Build manager binary.
go build -o bin/manager main.go
go build -o bin/manager cmd/main.go

run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go
go run ./cmd/main.go

docker-build: #test ## Build docker image with the manager.
docker build -t ${IMG} .
Expand All @@ -162,20 +162,23 @@ BASE_IMAGE_VERSION ?= b2a1bec3dfbc7a14a1d84d98934dfe8fdde6eb822a211286601cf109cb

docker-buildx:
@if [ -z "${IMG}" ]; then \
echo "Error: IMG is a mandatory argument. Usage: make docker-buildx IMG=<image_name> ...."; \
exit 1; \
fi; \
if echo "${BASE_IMAGE}" | grep -q "distroless"; then \
DOCKERFILE="Dockerfile.distroless"; \
BUILD_TAG="${IMG}-distroless"; \
else \
DOCKERFILE="Dockerfile"; \
BUILD_TAG="${IMG}"; \
fi; \
docker buildx build --push --platform="${PLATFORMS}" \
--build-arg BASE_IMAGE="${BASE_IMAGE}" \
--build-arg BASE_IMAGE_VERSION="${BASE_IMAGE_VERSION}" \
--tag "$$BUILD_TAG" -f "$$DOCKERFILE" .
echo "Error: IMG is a mandatory argument. Usage: make docker-buildx IMG=<image_name> ...."; \
exit 1; \
fi; \
docker buildx create --name project-v3-builder --use || true; \
docker buildx use project-v3-builder; \
if echo "${BASE_IMAGE}" | grep -q "distroless"; then \
DOCKERFILE="Dockerfile.distroless"; \
BUILD_TAG="${IMG}-distroless"; \
else \
DOCKERFILE="Dockerfile"; \
BUILD_TAG="${IMG}"; \
fi; \
docker buildx build --push --platform="${PLATFORMS}" \
--build-arg BASE_IMAGE="${BASE_IMAGE}" \
--build-arg BASE_IMAGE_VERSION="${BASE_IMAGE_VERSION}" \
--tag "$$BUILD_TAG" -f "$$DOCKERFILE" .; \
- docker buildx rm project-v3-builder || true



Expand Down Expand Up @@ -205,7 +208,7 @@ $(LOCALBIN):
mkdir -p $(LOCALBIN)

## Tool Versions
KUSTOMIZE_VERSION ?= v4.5.5
KUSTOMIZE_VERSION ?= v5.4.3
CONTROLLER_TOOLS_VERSION ?= v0.16.1

CONTROLLER_GEN = $(LOCALBIN)/controller-gen
Expand Down Expand Up @@ -255,7 +258,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.23.0/$${OS}-$${ARCH}-opm ;\
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.24.2/$${OS}-$${ARCH}-opm ;\
chmod +x $(OPM) ;\
}
else
Expand Down Expand Up @@ -400,3 +403,9 @@ setup/ginkgo:
@go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo@latest
@echo Installing gomega
@go get github.com/onsi/gomega/...

.PHONY: build-installer
build-installer: manifests generate kustomize
mkdir -p dist
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default > dist/install.yaml
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
domain: splunk.com
layout:
- go.kubebuilder.io/v3
- go.kubebuilder.io/v4
plugins:
manifests.sdk.operatorframework.io/v2: {}
scorecard.sdk.operatorframework.io/v2: {}
Expand Down
43 changes: 24 additions & 19 deletions main.go → cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ package main

import (
"flag"
"fmt"
intController "github.com/splunk/splunk-operator/internal/controller"
"github.com/splunk/splunk-operator/internal/controller/debug"
"os"
"sigs.k8s.io/controller-runtime/pkg/metrics/filters"
"time"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
Expand All @@ -36,12 +40,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/manager"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

enterpriseApiV3 "github.com/splunk/splunk-operator/api/v3"
enterpriseApi "github.com/splunk/splunk-operator/api/v4"
"github.com/splunk/splunk-operator/controllers"
debug "github.com/splunk/splunk-operator/controllers/debug"
"github.com/splunk/splunk-operator/pkg/config"
//+kubebuilder:scaffold:imports
//extapi "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
)
Expand Down Expand Up @@ -106,73 +108,76 @@ func main() {
// Logging setup
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

options := ctrl.Options{
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Metrics: metricsserver.Options{
BindAddress: metricsAddr,
FilterProvider: filters.WithAuthenticationAndAuthorization,
},
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "270bec8c.splunk.com",
LeaseDuration: &leaseDuration,
RenewDeadline: &renewDeadline,
}
})

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), config.ManagerOptionsWithNamespaces(setupLog, options))
if err != nil {
setupLog.Error(err, "unable to start manager")
os.Exit(1)
}

if err = (&controllers.ClusterMasterReconciler{
if err = (&intController.ClusterManagerReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ClusterMaster")
fmt.Printf(" error - %v", err)
setupLog.Error(err, "unable to create controller", "controller", "ClusterManager ")
os.Exit(1)
}
if err = (&controllers.ClusterManagerReconciler{
fmt.Printf("%v", err)
if err = (&intController.ClusterMasterReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ClusterManager")
setupLog.Error(err, "unable to create controller", "controller", "ClusterMaster")
os.Exit(1)
}
if err = (&controllers.IndexerClusterReconciler{
if err = (&intController.IndexerClusterReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "IndexerCluster")
os.Exit(1)
}
if err = (&controllers.LicenseMasterReconciler{
if err = (&intController.LicenseMasterReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "LicenseMaster")
os.Exit(1)
}
if err = (&controllers.LicenseManagerReconciler{
if err = (&intController.LicenseManagerReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "LicenseManager")
os.Exit(1)
}
if err = (&controllers.MonitoringConsoleReconciler{
if err = (&intController.MonitoringConsoleReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "MonitoringConsole")
os.Exit(1)
}
if err = (&controllers.SearchHeadClusterReconciler{
if err = (&intController.SearchHeadClusterReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "SearchHeadCluster")
os.Exit(1)
}
if err = (&controllers.StandaloneReconciler{
if err = (&intController.StandaloneReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
Expand Down Expand Up @@ -205,7 +210,7 @@ func main() {
// Note that these endpoints meant to be sensitive and shouldn't be exposed publicly.
func customSetupEndpoints(pprofActive bool, mgr manager.Manager) error {
if pprofActive {
if err := debug.RegisterEndpoint(mgr.AddMetricsExtraHandler, nil); err != nil {
if err := debug.RegisterEndpoint(mgr.AddMetricsServerExtraHandler, nil); err != nil {
setupLog.Error(err, "Unable to register pprof endpoint")
return err
}
Expand Down
Loading
Loading