Skip to content

Commit

Permalink
Merge pull request #23 from cybertec-postgresql/v0.7.0-build-fixes
Browse files Browse the repository at this point in the history
V0.7.0 build fixes
  • Loading branch information
Schmaetz authored Mar 12, 2024
2 parents 3b0639e + 248eab7 commit e503e09
Show file tree
Hide file tree
Showing 73 changed files with 1,004 additions and 908 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: clean local test linux macos mocks docker push e2e

BINARY ?= postgres-operator
BINARY ?= cybertec-pg-operator
BUILD_FLAGS ?= -v
CGO_ENABLED ?= 0
ifeq ($(RACE),1)
Expand All @@ -12,7 +12,7 @@ LOCAL_BUILD_FLAGS ?= $(BUILD_FLAGS)
LDFLAGS ?= -X=main.version=$(VERSION)
DOCKERDIR = docker

IMAGE ?= registry.opensource.zalan.do/acid/$(BINARY)
IMAGE ?= docker.io/cybertecpostgresql/$(BINARY)
TAG ?= $(VERSION)
GITHEAD = $(shell git rev-parse --short HEAD)
GITURL = $(shell git config --get remote.origin.url)
Expand Down
2 changes: 1 addition & 1 deletion hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -o nounset
set -o pipefail

GENERATED_PACKAGE_ROOT="github.com"
OPERATOR_PACKAGE_ROOT="${GENERATED_PACKAGE_ROOT}/zalando/postgres-operator"
OPERATOR_PACKAGE_ROOT="${GENERATED_PACKAGE_ROOT}/cybertec-postgresql/cybertec-pg-operator"
SCRIPT_ROOT=$(dirname ${BASH_SOURCE})/..
TARGET_CODE_DIR=${1-${SCRIPT_ROOT}/pkg}
CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SCRIPT_ROOT}"; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo "${GOPATH}"/src/k8s.io/code-generator)}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/cpo.opensource.cybertec.at/register.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package acidzalando
package cpoopensourcecybertecat

const (
// GroupName is the group name for the operator CRDs
Expand Down
116 changes: 106 additions & 10 deletions pkg/apis/cpo.opensource.cybertec.at/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"sync"
"time"

acidv1 "github.com/cybertec-postgresql/cybertec-pg-operator/pkg/apis/cpo.opensource.cybertec.at/v1"
cpov1 "github.com/cybertec-postgresql/cybertec-pg-operator/pkg/apis/cpo.opensource.cybertec.at/v1"
"github.com/sirupsen/logrus"

"github.com/cybertec-postgresql/cybertec-pg-operator/pkg/generated/clientset/versioned/scheme"
Expand Down Expand Up @@ -69,7 +69,7 @@ type kubeResources struct {
// Cluster describes postgresql cluster
type Cluster struct {
kubeResources
acidv1.Postgresql
cpov1.Postgresql
Config
logger *logrus.Entry
eventRecorder record.EventRecorder
Expand Down Expand Up @@ -106,7 +106,7 @@ type compareStatefulsetResult struct {
}

// New creates a new cluster. This function should be called from a controller.
func New(cfg Config, kubeClient k8sutil.KubernetesClient, pgSpec acidv1.Postgresql, logger *logrus.Entry, eventRecorder record.EventRecorder) *Cluster {
func New(cfg Config, kubeClient k8sutil.KubernetesClient, pgSpec cpov1.Postgresql, logger *logrus.Entry, eventRecorder record.EventRecorder) *Cluster {
deletePropagationPolicy := metav1.DeletePropagationOrphan

podEventsQueue := cache.NewFIFO(func(obj interface{}) (string, error) {
Expand All @@ -122,11 +122,11 @@ func New(cfg Config, kubeClient k8sutil.KubernetesClient, pgSpec acidv1.Postgres
passwordEncryption = "scram-sha-256"
}
if pgSpec.Spec.Monitoring != nil {
flg := acidv1.UserFlags{constants.RoleFlagLogin}
flg := cpov1.UserFlags{constants.RoleFlagLogin}
if pgSpec.Spec.Users != nil {
pgSpec.Spec.Users[monitorUsername] = flg
} else {
users := make(map[string]acidv1.UserFlags)
users := make(map[string]cpov1.UserFlags)
pgSpec.Spec.Users = users
pgSpec.Spec.Users[monitorUsername] = flg
}
Expand Down Expand Up @@ -262,13 +262,13 @@ func (c *Cluster) Create() (err error) {

defer func() {
if err == nil {
c.KubeClient.SetPostgresCRDStatus(c.clusterName(), acidv1.ClusterStatusRunning) //TODO: are you sure it's running?
c.KubeClient.SetPostgresCRDStatus(c.clusterName(), cpov1.ClusterStatusRunning) //TODO: are you sure it's running?
} else {
c.KubeClient.SetPostgresCRDStatus(c.clusterName(), acidv1.ClusterStatusAddFailed)
c.KubeClient.SetPostgresCRDStatus(c.clusterName(), cpov1.ClusterStatusAddFailed)
}
}()

c.KubeClient.SetPostgresCRDStatus(c.clusterName(), acidv1.ClusterStatusCreating)
c.KubeClient.SetPostgresCRDStatus(c.clusterName(), cpov1.ClusterStatusCreating)
c.eventRecorder.Event(c.GetReference(), v1.EventTypeNormal, "Create", "Started creation of new cluster resources")

for _, role := range []PostgresRole{Master, Replica} {
Expand Down Expand Up @@ -852,22 +852,22 @@ func (c *Cluster) compareServices(old, new *v1.Service) (bool, string) {
// (i.e. service) is treated as an error
// logical backup cron jobs are an exception: a user-initiated Update can enable a logical backup job
// for a cluster that had no such job before. In this case a missing job is not an error.
func (c *Cluster) Update(oldSpec, newSpec *acidv1.Postgresql) error {
func (c *Cluster) Update(oldSpec, newSpec *cpov1.Postgresql) error {
updateFailed := false
userInitFailed := false
syncStatefulSet := false

c.mu.Lock()
defer c.mu.Unlock()

c.KubeClient.SetPostgresCRDStatus(c.clusterName(), acidv1.ClusterStatusUpdating)
c.KubeClient.SetPostgresCRDStatus(c.clusterName(), cpov1.ClusterStatusUpdating)
c.setSpec(newSpec)

defer func() {
if updateFailed {
c.KubeClient.SetPostgresCRDStatus(c.clusterName(), acidv1.ClusterStatusUpdateFailed)
c.KubeClient.SetPostgresCRDStatus(c.clusterName(), cpov1.ClusterStatusUpdateFailed)
} else {
c.KubeClient.SetPostgresCRDStatus(c.clusterName(), acidv1.ClusterStatusRunning)
c.KubeClient.SetPostgresCRDStatus(c.clusterName(), cpov1.ClusterStatusRunning)
}
}()

Expand Down Expand Up @@ -1215,7 +1215,7 @@ func (c *Cluster) Delete() {
}

// NeedsRepair returns true if the cluster should be included in the repair scan (based on its in-memory status).
func (c *Cluster) NeedsRepair() (bool, acidv1.PostgresStatus) {
func (c *Cluster) NeedsRepair() (bool, cpov1.PostgresStatus) {
c.specMu.RLock()
defer c.specMu.RUnlock()
return !c.Status.Success(), c.Status
Expand Down Expand Up @@ -1330,7 +1330,7 @@ func (c *Cluster) initSystemUsers() {
func (c *Cluster) initPreparedDatabaseRoles() error {

if c.Spec.PreparedDatabases != nil && len(c.Spec.PreparedDatabases) == 0 { // TODO: add option to disable creating such a default DB
c.Spec.PreparedDatabases = map[string]acidv1.PreparedDatabase{strings.Replace(c.Name, "-", "_", -1): {}}
c.Spec.PreparedDatabases = map[string]cpov1.PreparedDatabase{strings.Replace(c.Name, "-", "_", -1): {}}
}

// create maps with default roles/users as keys and their membership as values
Expand All @@ -1349,7 +1349,7 @@ func (c *Cluster) initPreparedDatabaseRoles() error {
// get list of prepared schemas to set in search_path
preparedSchemas := preparedDB.PreparedSchemas
if len(preparedDB.PreparedSchemas) == 0 {
preparedSchemas = map[string]acidv1.PreparedSchema{"data": {DefaultRoles: util.True()}}
preparedSchemas = map[string]cpov1.PreparedSchema{"data": {DefaultRoles: util.True()}}
}

var searchPath strings.Builder
Expand Down
Loading

0 comments on commit e503e09

Please sign in to comment.