Skip to content
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ci-operator.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build_root_image:
name: tools
namespace: openstack-k8s-operators
tag: ci-build-root-golang-1.21-sdk-1.31
tag: ci-build-root-golang-1.23-sdk-1.31
2 changes: 1 addition & 1 deletion .github/workflows/build-openstack-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: openstack-k8s-operators/openstack-k8s-operators-ci/.github/workflows/reusable-build-operator.yaml@main
with:
operator_name: openstack
go_version: 1.21.x
go_version: 1.23.x
operator_sdk_version: 1.31.0
bundle_dockerfile: ./bundle.Dockerfile
secrets:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.21.x
go-version: 1.23.x
- uses: actions/checkout@v4
with:
# this fetches all branches. Needed because we need gh-pages branch for deploy to work
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/force-bump-pr-manual.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ jobs:
with:
operator_name: openstack
branch_name: ${{ github.ref_name }}
custom_image: quay.io/openstack-k8s-operators/openstack-k8s-operators-ci-build-tools:golang-1.23
secrets:
FORCE_BUMP_PULL_REQUEST_PAT: ${{ secrets.FORCE_BUMP_PULL_REQUEST_PAT }}
1 change: 1 addition & 0 deletions .github/workflows/force-bump-pr-scheduled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ jobs:
uses: openstack-k8s-operators/openstack-k8s-operators-ci/.github/workflows/force-bump-branches.yaml@main
with:
operator_name: openstack
custom_image: quay.io/openstack-k8s-operators/openstack-k8s-operators-ci-build-tools:golang-1.23
secrets:
FORCE_BUMP_PULL_REQUEST_PAT: ${{ secrets.FORCE_BUMP_PULL_REQUEST_PAT }}
2 changes: 1 addition & 1 deletion .github/workflows/kustom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.21.x
go-version: 1.23.x
- uses: actions/checkout@v4
with:
# this fetches all branches. Needed because we need gh-pages branch for deploy to work
Expand Down
8 changes: 7 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
version: 2

linters:
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- errorlint
- revive
- ginkgolinter
- gofmt
- govet

formatters:
enable:
- gofmt

run:
timeout: 5m
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ repos:
entry: bashate --error . --ignore=E006,E040,E011,E020,E012

- repo: https://github.com/golangci/golangci-lint
rev: v1.59.1
rev: v2.4.0
hooks:
- id: golangci-lint-full
args: ["-v"]
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GOLANG_BUILDER=registry.access.redhat.com/ubi9/go-toolset:1.21
ARG GOLANG_BUILDER=registry.access.redhat.com/ubi9/go-toolset:1.23
ARG OPERATOR_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi-minimal:latest
# Build the manager binary
FROM $GOLANG_BUILDER AS builder
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,10 @@ tidy: ## Run go mod tidy on every mod file in the repo
go mod tidy
cd ./apis && go mod tidy

GOLANGCI_LINT_VERSION ?= v2.4.0
.PHONY: golangci-lint
golangci-lint:
test -s $(LOCALBIN)/golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.59.1
test -s $(LOCALBIN)/golangci-lint || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s $(GOLANGCI_LINT_VERSION)
$(LOCALBIN)/golangci-lint run --fix

MAX_PROCS := 5
Expand Down Expand Up @@ -312,7 +313,7 @@ KUSTOMIZE_VERSION ?= v5.5.0 #(dprince: bumped to aquire new features like --load
CONTROLLER_TOOLS_VERSION ?= v0.14.0
CRD_MARKDOWN_VERSION ?= v0.0.3
KUTTL_VERSION ?= 0.17.0
GOTOOLCHAIN_VERSION ?= go1.21.0
GOTOOLCHAIN_VERSION ?= go1.23.0
OC_VERSION ?= 4.16.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
Expand Down
2 changes: 1 addition & 1 deletion apis/core/v1beta1/openstackcontrolplane_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1beta1
import (
"context"
"fmt"
"slices"
"strings"

keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1"
Expand All @@ -28,7 +29,6 @@ import (
placementv1 "github.com/openstack-k8s-operators/placement-operator/api/v1beta1"
watcherv1 "github.com/openstack-k8s-operators/watcher-operator/api/v1beta1"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand Down
2 changes: 1 addition & 1 deletion apis/dataplane/v1beta1/openstackdataplanenodeset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package v1beta1
import (
"context"
"fmt"
"slices"

"golang.org/x/exp/slices"
"sigs.k8s.io/controller-runtime/pkg/client"

infranetworkv1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1"
Expand Down
2 changes: 1 addition & 1 deletion apis/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/openstack-k8s-operators/openstack-operator/apis

go 1.21
go 1.23

require (
github.com/cert-manager/cert-manager v1.14.7
Expand Down
1 change: 1 addition & 0 deletions cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package main provides the entry point for the OpenStack operator
package main

import (
Expand Down
18 changes: 10 additions & 8 deletions controllers/client/openstackclient_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package client contains the OpenStackClient controller implementation
package client

import (
Expand Down Expand Up @@ -87,7 +88,7 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
Log := r.GetLogger(ctx)

instance := &clientv1.OpenStackClient{}
err := r.Client.Get(context.TODO(), req.NamespacedName, instance)
err := r.Get(context.TODO(), req.NamespacedName, instance)
if err != nil {
if k8s_errors.IsNotFound(err) {
Log.Info("OpenStackClient CR not found")
Expand Down Expand Up @@ -271,7 +272,8 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
condition.TLSInputReadyCondition,
condition.RequestedReason,
condition.SeverityInfo,
fmt.Sprintf(condition.TLSInputReadyWaitingMessage, instance.Spec.CaBundleSecretName)))
condition.TLSInputReadyWaitingMessage,
instance.Spec.CaBundleSecretName))
return ctrl.Result{}, nil
}
instance.Status.Conditions.Set(condition.FalseCondition(
Expand Down Expand Up @@ -320,7 +322,7 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
podSpecHashName := "podSpec"

op, err := controllerutil.CreateOrPatch(ctx, r.Client, osclient, func() error {
isPodUpdate := !osclient.ObjectMeta.CreationTimestamp.IsZero()
isPodUpdate := !osclient.CreationTimestamp.IsZero()
currentPodSpecHash := instance.Status.Hash[podSpecHashName]
if !isPodUpdate || currentPodSpecHash != podSpecHash {
osclient.Spec = spec
Expand Down Expand Up @@ -348,14 +350,14 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
// openstackclient pod
if err := r.Delete(ctx, osclient); err != nil && !k8s_errors.IsNotFound(err) {
// Error deleting the object
return ctrl.Result{}, fmt.Errorf("Error deleting OpenStackClient pod %s: %w", osclient.Name, err)
return ctrl.Result{}, fmt.Errorf("error deleting OpenStackClient pod %s: %w", osclient.Name, err)
}
Log.Info(fmt.Sprintf("OpenStackClient pod deleted due to change %s", err.Error()))

return ctrl.Result{Requeue: true}, nil
}

return ctrl.Result{}, fmt.Errorf("Failed to create or update pod %s: %w", osclient.Name, err)
return ctrl.Result{}, fmt.Errorf("failed to create or update pod %s: %w", osclient.Name, err)
}

if err != nil {
Expand Down Expand Up @@ -383,9 +385,9 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
terminatingDuration := time.Since(osclient.DeletionTimestamp.Time)
if terminatingDuration > time.Minute*3 {
// Force delete only truly stuck pods
err := r.Client.Delete(ctx, osclient, client.GracePeriodSeconds(0))
err := r.Delete(ctx, osclient, client.GracePeriodSeconds(0))
if err != nil {
return ctrl.Result{}, fmt.Errorf("Failed to force delete pod: %w", err)
return ctrl.Result{}, fmt.Errorf("failed to force delete pod: %w", err)
}
}
}
Expand Down Expand Up @@ -480,7 +482,7 @@ func (r *OpenStackClientReconciler) SetupWithManager(
listOpts := []client.ListOption{
client.InNamespace(o.GetNamespace()),
}
if err := r.Client.List(ctx, openstackclients, listOpts...); err != nil {
if err := r.List(ctx, openstackclients, listOpts...); err != nil {
Log.Error(err, "Unable to retrieve OpenstackClient CRs %v")
return nil
}
Expand Down
7 changes: 4 additions & 3 deletions controllers/core/openstackcontrolplane_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package core contains the OpenStackControlPlane controller implementation
package core

import (
Expand All @@ -32,7 +34,6 @@ import (
ironicv1 "github.com/openstack-k8s-operators/ironic-operator/api/v1beta1"
keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1"
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
"github.com/openstack-k8s-operators/lib-common/modules/common/helper"
common_helper "github.com/openstack-k8s-operators/lib-common/modules/common/helper"
corev1 "k8s.io/api/core/v1"

Expand Down Expand Up @@ -131,7 +132,7 @@ func (r *OpenStackControlPlaneReconciler) Reconcile(ctx context.Context, req ctr
Log := r.GetLogger(ctx)
// Fetch the OpenStackControlPlane instance
instance := &corev1beta1.OpenStackControlPlane{}
err := r.Client.Get(ctx, req.NamespacedName, instance)
err := r.Get(ctx, req.NamespacedName, instance)
if err != nil {
if k8s_errors.IsNotFound(err) {
// Request object not found, could have been deleted after reconcile request.
Expand Down Expand Up @@ -777,7 +778,7 @@ func (r *OpenStackControlPlaneReconciler) findObjectsForSrc(ctx context.Context,
// Verify the referenced topology exists
func (r *OpenStackControlPlaneReconciler) checkTopologyRef(
ctx context.Context,
h *helper.Helper,
h *common_helper.Helper,
topologyRef *topologyv1.TopoRef,
namespace string,
) error {
Expand Down
6 changes: 3 additions & 3 deletions controllers/core/openstackversion_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req
Log.Info("Reconciling OpenStackVersion")
// Fetch the instance
instance := &corev1beta1.OpenStackVersion{}
err := r.Client.Get(ctx, req.NamespacedName, instance)
err := r.Get(ctx, req.NamespacedName, instance)
if err != nil {
if k8s_errors.IsNotFound(err) {
// Request object not found, could have been deleted after reconcile request.
Expand Down Expand Up @@ -228,7 +228,7 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req

// lookup the current Controlplane object
controlPlane := &corev1beta1.OpenStackControlPlane{}
err = r.Client.Get(ctx, client.ObjectKey{
err = r.Get(ctx, client.ObjectKey{
Namespace: instance.Namespace,
Name: instance.Name,
}, controlPlane)
Expand Down Expand Up @@ -414,7 +414,7 @@ func (r *OpenStackVersionReconciler) SetupWithManager(mgr ctrl.Manager) error {
listOpts := []client.ListOption{
client.InNamespace(o.GetNamespace()),
}
if err := r.Client.List(ctx, versionList, listOpts...); err != nil {
if err := r.List(ctx, versionList, listOpts...); err != nil {
Log.Error(err, "Unable to retrieve OpenStackVersion")
return nil
}
Expand Down
11 changes: 6 additions & 5 deletions controllers/dataplane/openstackdataplanedeployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package dataplane contains the OpenStackDataPlaneDeployment controller implementation
package dataplane

import (
Expand Down Expand Up @@ -82,7 +83,7 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
}
// Fetch the OpenStackDataPlaneDeployment instance
instance := &dataplanev1.OpenStackDataPlaneDeployment{}
err := r.Client.Get(ctx, req.NamespacedName, instance)
err := r.Get(ctx, req.NamespacedName, instance)
if err != nil {
if k8s_errors.IsNotFound(err) {
// Request object not found, could have been deleted after reconcile request.
Expand Down Expand Up @@ -343,7 +344,7 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
severity,
condition.DeploymentReadyErrorMessage,
deploymentErrMsg)
return ctrl.Result{}, fmt.Errorf(deploymentErrMsg)
return ctrl.Result{}, fmt.Errorf("%s", deploymentErrMsg)
}

if shouldRequeue {
Expand All @@ -365,7 +366,7 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
return ctrl.Result{}, nil
}

// GetService
// GetService retrieves a service for the OpenStackDataPlaneDeployment
func (r *OpenStackDataPlaneDeploymentReconciler) GetService(
ctx context.Context,
helper *helper.Helper,
Expand Down Expand Up @@ -456,7 +457,7 @@ func (r *OpenStackDataPlaneDeploymentReconciler) SetupWithManager(mgr ctrl.Manag
listOpts := []client.ListOption{
client.InNamespace(obj.GetNamespace()),
}
if err := r.Client.List(context.Background(), deployments, listOpts...); err != nil {
if err := r.List(context.Background(), deployments, listOpts...); err != nil {
Log.Error(err, "Unable to retrieve deployments %w")
return nil
}
Expand Down Expand Up @@ -504,7 +505,7 @@ func (r *OpenStackDataPlaneDeploymentReconciler) listNodeSets(ctx context.Contex

// Fetch the OpenStackDataPlaneNodeSet instance
nodeSetInstance := &dataplanev1.OpenStackDataPlaneNodeSet{}
err := r.Client.Get(
err := r.Get(
ctx,
types.NamespacedName{
Namespace: instance.GetNamespace(),
Expand Down
14 changes: 7 additions & 7 deletions controllers/dataplane/openstackdataplanenodeset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ package dataplane
import (
"context"
"fmt"
"slices"
"strings"
"time"

"github.com/go-playground/validator/v10"
"golang.org/x/exp/slices"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
Expand Down Expand Up @@ -145,7 +145,7 @@ func (r *OpenStackDataPlaneNodeSetReconciler) Reconcile(ctx context.Context, req

// Fetch the OpenStackDataPlaneNodeSet instance
instance := &dataplanev1.OpenStackDataPlaneNodeSet{}
err := r.Client.Get(ctx, req.NamespacedName, instance)
err := r.Get(ctx, req.NamespacedName, instance)
if err != nil {
if k8s_errors.IsNotFound(err) {
// Request object not found, could have been deleted after reconcile request.
Expand Down Expand Up @@ -282,7 +282,7 @@ func (r *OpenStackDataPlaneNodeSetReconciler) Reconcile(ctx context.Context, req
condition.InputReadyCondition,
condition.RequestedReason,
condition.SeverityError,
err.Error())
"%s", err.Error())
return result, err
} else if (result != ctrl.Result{}) {
instance.Status.Conditions.MarkFalse(
Expand Down Expand Up @@ -461,7 +461,7 @@ func (r *OpenStackDataPlaneNodeSetReconciler) Reconcile(ctx context.Context, req
}
instance.Status.Conditions.MarkFalse(condition.DeploymentReadyCondition,
condition.ErrorReason, condition.SeverityError,
deployErrorMsg)
"%s", deployErrorMsg)
}

return ctrl.Result{}, err
Expand Down Expand Up @@ -511,7 +511,7 @@ func checkDeployment(ctx context.Context, helper *helper.Helper,
instance.Status.DeploymentStatuses[deployment.Name] = deploymentConditions
deploymentCondition := deploymentConditions.Get(dataplanev1.NodeSetDeploymentReadyCondition)
if condition.IsError(deploymentCondition) {
err = fmt.Errorf(deploymentCondition.Message)
err = fmt.Errorf("%s", deploymentCondition.Message)
isDeploymentFailed = true
failedDeploymentName = deployment.Name
break
Expand Down Expand Up @@ -677,7 +677,7 @@ func (r *OpenStackDataPlaneNodeSetReconciler) machineConfigWatcherFn(
listOpts := []client.ListOption{
client.InNamespace(obj.GetNamespace()),
}
if err := r.Client.List(ctx, nodeSets, listOpts...); err != nil {
if err := r.List(ctx, nodeSets, listOpts...); err != nil {
Log.Error(err, "Unable to retrieve OpenStackDataPlaneNodeSetList")
return nil
}
Expand Down Expand Up @@ -739,7 +739,7 @@ func (r *OpenStackDataPlaneNodeSetReconciler) genericWatcherFn(
listOpts := []client.ListOption{
client.InNamespace(obj.GetNamespace()),
}
if err := r.Client.List(ctx, nodeSets, listOpts...); err != nil {
if err := r.List(ctx, nodeSets, listOpts...); err != nil {
Log.Error(err, "Unable to retrieve OpenStackDataPlaneNodeSetList")
return nil
}
Expand Down
Loading