From cd05682482304000654ff1d6c6feaae882fbfe39 Mon Sep 17 00:00:00 2001 From: Steven Berler <1030627+berler@users.noreply.github.com> Date: Thu, 11 Dec 2025 01:22:40 -0800 Subject: [PATCH 1/2] fix switchover schedule tests (#2995) * fix switchover schedule tests Previously the tests would fail depending on the local time zone and the time of day the test was being run. --------- Co-authored-by: Felix Kunde Co-authored-by: Mikkel Oscar Lyderik Larsen --- pkg/cluster/cluster.go | 6 +++++- pkg/cluster/cluster_test.go | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/cluster/cluster.go b/pkg/cluster/cluster.go index 9cd750e84..b6a4e24a8 100644 --- a/pkg/cluster/cluster.go +++ b/pkg/cluster/cluster.go @@ -1767,9 +1767,13 @@ func (c *Cluster) GetStatus() *ClusterStatus { } func (c *Cluster) GetSwitchoverSchedule() string { + now := time.Now().UTC() + return c.getSwitchoverScheduleAtTime(now) +} + +func (c *Cluster) getSwitchoverScheduleAtTime(now time.Time) string { var possibleSwitchover, schedule time.Time - now := time.Now().UTC() for _, window := range c.Spec.MaintenanceWindows { // in the best case it is possible today possibleSwitchover = time.Date(now.Year(), now.Month(), now.Day(), window.StartTime.Hour(), window.StartTime.Minute(), 0, 0, time.UTC) diff --git a/pkg/cluster/cluster_test.go b/pkg/cluster/cluster_test.go index 25f61db98..d78d4c92e 100644 --- a/pkg/cluster/cluster_test.go +++ b/pkg/cluster/cluster_test.go @@ -2116,7 +2116,7 @@ func TestCompareVolumeMounts(t *testing.T) { } func TestGetSwitchoverSchedule(t *testing.T) { - now := time.Now() + now, _ := time.Parse(time.RFC3339, "2025-11-11T12:35:00Z") futureTimeStart := now.Add(1 * time.Hour) futureWindowTimeStart := futureTimeStart.Format("15:04") @@ -2195,7 +2195,7 @@ func TestGetSwitchoverSchedule(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { cluster.Spec.MaintenanceWindows = tt.windows - schedule := cluster.GetSwitchoverSchedule() + schedule := cluster.getSwitchoverScheduleAtTime(now) if schedule != tt.expected { t.Errorf("Expected GetSwitchoverSchedule to return %s, returned: %s", tt.expected, schedule) } From a27727f8d04cde3f45b48dd0364639d4e0ac54e2 Mon Sep 17 00:00:00 2001 From: Ida Novindasari Date: Fri, 12 Dec 2025 16:49:58 +0100 Subject: [PATCH 2/2] [ui] internal pipeline fix to build ui image (#3013) * fix ui pipeline * adjust logical backup image tagging --- delivery.yaml | 167 +++++++++++++++++++++++++++----------------------- ui/Makefile | 13 ---- 2 files changed, 89 insertions(+), 91 deletions(-) diff --git a/delivery.yaml b/delivery.yaml index 9ab8b5a4c..e582b982b 100644 --- a/delivery.yaml +++ b/delivery.yaml @@ -7,92 +7,103 @@ build_env: &BUILD_ENV MULTI_ARCH_REGISTRY: container-registry-test.zalando.net/acid pipeline: - - id: build-postgres-operator - env: - <<: *BUILD_ENV - type: script - vm_config: - type: linux - size: large - image: cdp-runtime/go - cache: - paths: - - /go/pkg/mod # pkg cache for Go modules - - ~/.cache/go-build # Go build cache - commands: - - desc: Run unit tests - cmd: | - make deps mocks test + - id: build-postgres-operator + env: + <<: *BUILD_ENV + type: script + vm_config: + type: linux + size: large + image: cdp-runtime/go + cache: + paths: + - /go/pkg/mod # pkg cache for Go modules + - ~/.cache/go-build # Go build cache + commands: + - desc: Run unit tests + cmd: | + make deps mocks test - - desc: Build Docker image - cmd: | - if [ -z ${CDP_SOURCE_BRANCH} ]; then - IMAGE=${MULTI_ARCH_REGISTRY}/postgres-operator - else - IMAGE=${MULTI_ARCH_REGISTRY}/postgres-operator-test - fi + - desc: Build Docker image + cmd: | + if [ -z ${CDP_SOURCE_BRANCH} ]; then + IMAGE=${MULTI_ARCH_REGISTRY}/postgres-operator + else + IMAGE=${MULTI_ARCH_REGISTRY}/postgres-operator-test + fi - docker buildx create --config /etc/cdp-buildkitd.toml --driver-opt network=host --bootstrap --use - docker buildx build --platform "linux/amd64,linux/arm64" \ - --build-arg BASE_IMAGE="${ALPINE_BASE_IMAGE}" \ - -t "${IMAGE}:${CDP_BUILD_VERSION}" \ - -f docker/Dockerfile \ - --push . + docker buildx create --config /etc/cdp-buildkitd.toml --driver-opt network=host --bootstrap --use + docker buildx build --platform "linux/amd64,linux/arm64" \ + --build-arg BASE_IMAGE="${ALPINE_BASE_IMAGE}" \ + -t "${IMAGE}:${CDP_BUILD_VERSION}" \ + -f docker/Dockerfile \ + --push . - if [ -z ${CDP_SOURCE_BRANCH} ]; then - cdp-promote-image ${IMAGE}:${CDP_BUILD_VERSION} - fi + if [ -z ${CDP_SOURCE_BRANCH} ]; then + cdp-promote-image ${IMAGE}:${CDP_BUILD_VERSION} + fi - - id: build-operator-ui - env: - <<: *BUILD_ENV - type: script - vm_config: - type: linux + - id: build-operator-ui + env: + <<: *BUILD_ENV + type: script + vm_config: + type: linux - commands: - - desc: 'Prepare environment' - cmd: | - apt-get update - apt-get install -y build-essential + commands: + - desc: 'Prepare environment' + cmd: | + apt-get update + apt-get install -y build-essential - - desc: 'Compile JavaScript app' - cmd: | - cd ui - make appjs + - desc: 'Compile JavaScript app' + cmd: | + cd ui + make appjs - - desc: 'Build and push Docker image' - cmd: | - cd ui - if [ -z ${CDP_SOURCE_BRANCH} ]; then - IMAGE=${MULTI_ARCH_REGISTRY}/postgres-operator-ui - else - IMAGE=${MULTI_ARCH_REGISTRY}/postgres-operator-ui-test - fi - - IMAGE_TAG=$(make docker-push IMAGE=${IMAGE} BASE_IMAGE=${PYTHON_BASE_IMAGE}) + - desc: 'Build and push Docker image' + cmd: | + cd ui + if [ -z ${CDP_SOURCE_BRANCH} ]; then + IMAGE=${MULTI_ARCH_REGISTRY}/postgres-operator-ui + else + IMAGE=${MULTI_ARCH_REGISTRY}/postgres-operator-ui-test + fi + + make appjs + docker buildx create --config /etc/cdp-buildkitd.toml --driver-opt network=host --bootstrap --use + docker buildx build --platform linux/amd64,linux/arm64 \ + --build-arg BASE_IMAGE="${PYTHON_BASE_IMAGE}" \ + -t ${IMAGE}:${CDP_BUILD_VERSION} \ + --push . - if [ -z ${CDP_SOURCE_BRANCH} ]; then - cdp-promote-image ${IMAGE_TAG} - fi + if [ -z ${CDP_SOURCE_BRANCH} ]; then + cdp-promote-image ${IMAGE}:${CDP_BUILD_VERSION} + fi - - id: build-logical-backup - env: - <<: *BUILD_ENV - type: script - vm_config: - type: linux + - id: build-logical-backup + env: + <<: *BUILD_ENV + type: script + vm_config: + type: linux - commands: - - desc: Build image - cmd: | - cd logical-backup - export TAG=$(git describe --tags --always --dirty) - docker buildx create --config /etc/cdp-buildkitd.toml --driver-opt network=host --bootstrap --use - docker buildx build --platform linux/amd64,linux/arm64 \ - -t ${MULTI_ARCH_REGISTRY}/postgres-operator-logical-backup:${TAG} \ - --push . + commands: + - desc: Build image + cmd: | + cd logical-backup - if [ -z ${CDP_SOURCE_BRANCH} ]; then - cdp-promote-image ${MULTI_ARCH_REGISTRY}/postgres-operator-logical-backup:${TAG} - fi + if [ -z ${CDP_SOURCE_BRANCH} ]; then + IMAGE=${MULTI_ARCH_REGISTRY}/logical-backup + else + IMAGE=${MULTI_ARCH_REGISTRY}/logical-backup-test + fi + + docker buildx create --config /etc/cdp-buildkitd.toml --driver-opt network=host --bootstrap --use + docker buildx build --platform linux/amd64,linux/arm64 \ + -t ${IMAGE}:${CDP_BUILD_VERSION} \ + --push . + + if [ -z ${CDP_SOURCE_BRANCH} ]; then + cdp-promote-image ${IMAGE}:${CDP_BUILD_VERSION} + fi diff --git a/ui/Makefile b/ui/Makefile index 70c2018db..ff4cf94f6 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -33,18 +33,5 @@ docker: appjs echo "git describe $(shell git describe --tags --always --dirty)" docker build --rm -t "$(IMAGE):$(TAG)$(CDP_TAG)" -f Dockerfile --build-arg BASE_IMAGE="${BASE_IMAGE}" . -docker-push: appjs - echo "Tag ${TAG}" - echo "Version ${VERSION}" - echo "CDP tag ${CDP_TAG}" - echo "git describe $(shell git describe --tags --always --dirty)" - docker buildx create --config /etc/cdp-buildkitd.toml --driver-opt network=host --bootstrap --use - docker buildx build --platform linux/amd64,linux/arm64 \ - --build-arg BASE_IMAGE="${BASE_IMAGE}" \ - -f Dockerfile \ - -t "$(IMAGE):$(TAG)$(CDP_TAG)" \ - --push . - echo "$(IMAGE):$(TAG)$(CDP_TAG)" - mock: docker run -it -p 8081:8081 "$(IMAGE):$(TAG)" --mock