Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ commands:
common_setup:
steps:
- go/install:
version: '1.25.5'
version: '1.25.8'
- checkout
- use_mod_cache
- run:
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ CLUSTER_TEST_SKIP_CLEANUP ?= 0
CLUSTER_TEST_IMAGE_TAG ?=
CLUSTER_TEST_DATA_DIR ?=

ci_enabled=$(filter true,$(CI))
docker_swarm_state=$(shell docker info --format '{{.Swarm.LocalNodeState}}')
buildx_builder=$(if $(CI),"control-plane-ci","control-plane")
buildx_config=$(if $(CI),"./buildkit.ci.toml","./buildkit.toml")
buildx_builder=$(if $(ci_enabled),"control-plane-ci","control-plane")
buildx_config=$(if $(ci_enabled),"./buildkit.ci.toml","./buildkit.toml")
docker_compose_dev=WORKSPACE_DIR=$(shell pwd) \
DEBUG=$(DEBUG) \
LOG_LEVEL=$(LOG_LEVEL) \
Expand Down Expand Up @@ -53,10 +54,10 @@ cluster_test_args=-tags=cluster_test -count=1 -timeout=10m \
# Automatically adds junit output named after the rule, e.g.
# 'test-e2e-results.xml' in CI environment.
gotestsum=$(gobin)/gotestsum \
$(if $(filter true,$(CI)),--junitfile $@-results.xml)
$(if $(ci_enabled),--junitfile $@-results.xml)

golangci-lint=$(gobin)/golangci-lint \
$(if $(filter true,$(CI)),--output.text.path stdout --output.junit-xml.path $@-results.xml)
$(if $(ci_enabled),--output.text.path stdout --output.junit-xml.path $@-results.xml)

.DEFAULT_GOAL := build

Expand Down
1 change: 0 additions & 1 deletion api/apiv1/design/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,6 @@ var Database = g.Type("Database", func() {
"deleting",
"degraded",
"failed",
"backing_up",
"restoring",
"unknown",
)
Expand Down
3 changes: 1 addition & 2 deletions api/apiv1/gen/http/openapi.json

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

3 changes: 1 addition & 2 deletions api/apiv1/gen/http/openapi.yaml

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

15 changes: 5 additions & 10 deletions api/apiv1/gen/http/openapi3.json

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

15 changes: 5 additions & 10 deletions api/apiv1/gen/http/openapi3.yaml

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

3 changes: 2 additions & 1 deletion client/enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ const (
DatabaseStateAvailable = "available"
DatabaseStateDeleting = "deleting"
DatabaseStateDegraded = "degraded"
DatabaseStateUnknown = "unknown"
DatabaseStateFailed = "failed"
DatabaseStateRestoring = "restoring"
DatabaseStateUnknown = "unknown"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion docker/control-plane-dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.25.5
FROM golang:1.25.8

ENV CGO_ENABLED=0

Expand Down
7 changes: 6 additions & 1 deletion docker/control-plane-dev/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"profiling_enabled": true,
"client_addresses": ["127.0.0.1"]
"client_addresses": ["127.0.0.1"],
"logging": {
"component_levels": {
"api_server": "error"
}
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/pgEdge/control-plane

go 1.25.0

toolchain go1.25.5
toolchain go1.25.8

require (
github.com/alessio/shellescape v1.4.2
Expand Down
2 changes: 2 additions & 0 deletions server/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/pgEdge/control-plane/server/internal/orchestrator/swarm"
"github.com/pgEdge/control-plane/server/internal/ports"
"github.com/pgEdge/control-plane/server/internal/resource"
"github.com/pgEdge/control-plane/server/internal/resource/migrations"
"github.com/pgEdge/control-plane/server/internal/scheduler"
"github.com/pgEdge/control-plane/server/internal/task"
"github.com/pgEdge/control-plane/server/internal/workflows"
Expand Down Expand Up @@ -79,6 +80,7 @@ func newRootCmd(i *do.Injector) *cobra.Command {
monitor.Provide(i)
ports.Provide(i)
resource.Provide(i)
migrations.Provide(i)
scheduler.Provide(i)
workflows.Provide(i)
activities.Provide(i)
Expand Down
7 changes: 1 addition & 6 deletions server/internal/api/apiv1/post_init_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,6 @@ func (s *PostInitHandlers) BackupDatabaseNode(ctx context.Context, req *api.Back
HostID: hostID,
}
}
prevState := db.State
t, err := s.workflowSvc.CreatePgBackRestBackup(ctx,
db.DatabaseID,
node.Name,
Expand All @@ -495,11 +494,7 @@ func (s *PostInitHandlers) BackupDatabaseNode(ctx context.Context, req *api.Back
},
)
if err != nil {
restorationErr := s.dbSvc.UpdateDatabaseState(ctx, db.DatabaseID, database.DatabaseStateBackingUp, prevState)
if restorationErr != nil {
s.logger.Err(restorationErr).Msg("failed to roll back database state change")
}
return nil, apiErr(err)
return nil, apiErr(fmt.Errorf("failed to initialize backup workflow: %w", err))
}

return &api.BackupDatabaseNodeResponse{
Expand Down
28 changes: 28 additions & 0 deletions server/internal/api/apiv1/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func validateDatabaseSpec(spec *api.DatabaseSpec) error {
errs = append(errs, validateCPUs(spec.Cpus, []string{"cpus"})...)
errs = append(errs, validateMemory(spec.Memory, []string{"memory"})...)
errs = append(errs, validatePorts(spec.Port, spec.PatroniPort, []string{"port"}))
errs = append(errs, validateUsers(spec.DatabaseUsers, []string{"database_users"})...)

// Track node-name uniqueness and prepare set for cross-node checks.
seenNodeNames := make(ds.Set[string], len(spec.Nodes))
Expand Down Expand Up @@ -450,6 +451,33 @@ func validatePorts(postgresPort, patroniPort *int, path []string) error {
return nil
}

func validateUsers(users []*api.DatabaseUserSpec, path []string) []error {
var errs []error

seenNames := ds.NewSet[string]()
var hasOwner bool
for i, user := range users {
userPath := appendPath(path, arrayIndexPath(i))

if seenNames.Has(user.Username) {
err := errors.New("usernames must be unique within a database")
errs = append(errs, newValidationError(err, userPath))
}
if user.DbOwner != nil && *user.DbOwner && hasOwner {
err := errors.New("cannot have multiple users with db_owner = true")
errs = append(errs, newValidationError(err, userPath))
}

seenNames.Add(user.Username)

if user.DbOwner != nil && *user.DbOwner {
hasOwner = true
}
}

return errs
}

func validateBackupConfig(cfg *api.BackupConfigSpec, path []string) []error {
var errs []error

Expand Down
Loading