Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
f03f9f7
add feature gates
mayankshah1607 Nov 24, 2025
83ac65c
add boilerplate for xtrabackup sidecar server
mayankshah1607 Nov 25, 2025
7b53a46
add sidecar to node sts when feature enabled
mayankshah1607 Nov 25, 2025
22d1cb7
update dockerfile
mayankshah1607 Nov 25, 2025
42754fb
typo
mayankshah1607 Nov 25, 2025
c0c7144
fix base context
mayankshah1607 Nov 25, 2025
8a17a79
refactoring
mayankshah1607 Nov 25, 2025
51bd79f
add run-backup script
mayankshah1607 Nov 25, 2025
9291709
update Dockerfile
mayankshah1607 Nov 25, 2025
6342784
add volume mount
mayankshah1607 Nov 25, 2025
af8bdf1
update run-backup
mayankshah1607 Nov 25, 2025
c8df8dd
use server stream
mayankshah1607 Nov 25, 2025
26bab21
implement backup job
mayankshah1607 Nov 25, 2025
3957c44
refactor getPrimaryPod func
mayankshah1607 Nov 26, 2025
c64dd5c
add HOST env var to backup job
mayankshah1607 Nov 26, 2025
354993f
add logging
mayankshah1607 Nov 26, 2025
37b7e6a
fix job
mayankshah1607 Nov 26, 2025
1fa9199
fix pod dns
mayankshah1607 Nov 26, 2025
4a8863b
implement CreateBackup handler
mayankshah1607 Nov 26, 2025
0d34512
add socket path
mayankshah1607 Nov 27, 2025
7a95201
refactoring
mayankshah1607 Nov 28, 2025
2162bf8
implement log streaming
mayankshah1607 Nov 28, 2025
5f921cc
add log
mayankshah1607 Nov 28, 2025
fdb9583
Merge branch 'main' into K8SPXC-1576-poc
mayankshah1607 Nov 28, 2025
4a5236e
Update pkg/controller/pxc/upgrade.go
mayankshah1607 Nov 28, 2025
d9e738c
fix errors
mayankshah1607 Nov 28, 2025
275550a
linting
mayankshah1607 Nov 28, 2025
2f9b072
add unit test for JobSpec
mayankshah1607 Nov 28, 2025
a97a832
add unit tests for commands
mayankshah1607 Nov 28, 2025
ac1319b
Merge branch 'main' into K8SPXC-1576-poc
mayankshah1607 Nov 28, 2025
12564d5
Merge branch 'main' into K8SPXC-1576-poc
mayankshah1607 Nov 28, 2025
75f12e4
do not allow pvc backups
mayankshah1607 Nov 30, 2025
91588dd
Merge branch 'main' into K8SPXC-1576-poc
mayankshah1607 Nov 30, 2025
bbe8dbf
Merge branch 'main' into K8SPXC-1576-poc
mayankshah1607 Dec 1, 2025
9bc42ed
allow specifying PXCO_FEATURE_GATES in tests
mayankshah1607 Dec 1, 2025
3b958f3
add protoc to Makefile
mayankshah1607 Dec 1, 2025
8203b84
add --galera-info
mayankshah1607 Dec 1, 2025
8f9dbca
fix pitr
mayankshah1607 Dec 2, 2025
ef68b3a
refactor code
mayankshah1607 Dec 2, 2025
2340e30
add unit test for gtid
mayankshah1607 Dec 2, 2025
b3c3482
update go.mod
mayankshah1607 Dec 2, 2025
4007afd
fix recoverer
mayankshah1607 Dec 2, 2025
647f063
Merge branch 'main' into K8SPXC-1576-poc
mayankshah1607 Dec 2, 2025
b23d370
fix CI
mayankshah1607 Dec 2, 2025
bb875cc
remove --galera-info
mayankshah1607 Dec 2, 2025
dae2331
fix gen.go
mayankshah1607 Dec 2, 2025
0b1aadf
fix make protoc
mayankshah1607 Dec 2, 2025
c64cf71
fix make protoc
mayankshah1607 Dec 2, 2025
0b103d9
add pitr-xtrabackup to run-pr
mayankshah1607 Dec 2, 2025
472935a
update cw-operator.yaml
mayankshah1607 Dec 2, 2025
06395ea
Update e2e-tests/pitr-xtrabackup/run
mayankshah1607 Dec 2, 2025
9afc81d
Merge branch 'main' into K8SPXC-1576-poc
mayankshah1607 Dec 2, 2025
4e80be9
Merge branch 'main' into K8SPXC-1576-poc
mayankshah1607 Dec 3, 2025
b0836b9
support encryption
mayankshah1607 Dec 3, 2025
19260a3
fix test
mayankshah1607 Dec 3, 2025
4adee1c
update demand-backup-encrypted-tls to work with xtrabackup
mayankshah1607 Dec 3, 2025
348b92a
add demand-backup-encrypted-with-tls-xtrabackup
mayankshah1607 Dec 3, 2025
6a07c54
fix restore scripts
mayankshah1607 Dec 3, 2025
a80ba72
Merge branch 'main' into K8SPXC-1576-poc
hors Dec 3, 2025
015b1fd
fix restore
mayankshah1607 Dec 3, 2025
4410520
use zap logger
mayankshah1607 Dec 4, 2025
fe6a5b4
fix mispell
mayankshah1607 Dec 4, 2025
9eaf287
Merge branch 'main' into K8SPXC-1576-poc
mayankshah1607 Dec 4, 2025
c37895e
fix script
mayankshah1607 Dec 4, 2025
55724a0
add and fix tests
mayankshah1607 Dec 4, 2025
f87bc12
fix version
mayankshah1607 Dec 4, 2025
e16e157
increase sleep
mayankshah1607 Dec 4, 2025
881940a
fix tests
mayankshah1607 Dec 5, 2025
9f8d1ab
try fix testname
mayankshah1607 Dec 5, 2025
d908614
fix storage tests
mayankshah1607 Dec 5, 2025
8e5bbec
Merge branch 'main' into K8SPXC-1576-poc
mayankshah1607 Dec 5, 2025
f57ecc1
go mod tidy
mayankshah1607 Dec 5, 2025
1a25b90
add request sanitation
mayankshah1607 Dec 5, 2025
43cd482
update e2e tests
mayankshah1607 Dec 5, 2025
c5a8cbe
add missing feature flags to test
mayankshah1607 Dec 5, 2025
2d6e606
add 8.4 to run-pr
mayankshah1607 Dec 5, 2025
c015033
move functions to pxc package
mayankshah1607 Dec 5, 2025
a6b9cd9
rename to BackupSidecar
mayankshah1607 Dec 5, 2025
fdc4485
fix test
mayankshah1607 Dec 5, 2025
d8c3bff
update statufulset
mayankshah1607 Dec 5, 2025
cb08922
Update e2e-tests/demand-backup-cloud-pxb/run
mayankshah1607 Dec 5, 2025
e59ffba
Update build/backup/recovery-cloud.sh
mayankshah1607 Dec 5, 2025
6b63592
Update e2e-tests/demand-backup-cloud-pxb/run
mayankshah1607 Dec 5, 2025
e74bf1d
improve test
mayankshah1607 Dec 5, 2025
eec67ac
fix recovery-cloud.sh
mayankshah1607 Dec 5, 2025
ab150a0
fix flaky test
mayankshah1607 Dec 5, 2025
d47f880
add sleep
mayankshah1607 Dec 5, 2025
ff41c2b
typos
mayankshah1607 Dec 6, 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
23 changes: 22 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ all: build
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

generate: controller-gen ## Generate CRDs and RBAC files
generate: controller-gen protoc ## Generate CRDs and RBAC files
go generate ./...
$(CONTROLLER_GEN) crd:maxDescLen=0,allowDangerousTypes=true,generateEmbeddedObjectMeta=true rbac:roleName=$(NAME) webhook paths="./..." output:crd:artifacts:config=config/crd/bases ## Generate WebhookConfiguration, Role and CustomResourceDefinition objects.
$(CONTROLLER_GEN) object paths="./..." ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
Expand Down Expand Up @@ -108,6 +108,27 @@ SWAGGER = $(shell pwd)/bin/swagger
swagger: ## Download swagger locally if necessary.
$(call go-get-tool,$(SWAGGER),github.com/go-swagger/go-swagger/cmd/swagger@latest)

PROTOC_VERSION = 33.1
PROTOC = $(shell pwd)/bin/protoc
PROTOC_GEN_GO = $(shell pwd)/bin/protoc-gen-go
PROTOC_GEN_GO_GRPC = $(shell pwd)/bin/protoc-gen-go-grpc
protoc: ## Download protoc locally if necessary.
os='linux'; \
arch='x86_64'; \
if [ "$(shell uname)" = "Darwin" ]; then \
os='osx'; \
fi; \
if [ "$(shell uname -m)" = "arm64" ]; then \
arch='aarch_64'; \
fi; \
curl -LO "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-$${os}-$${arch}.zip"; \
unzip -o protoc-${PROTOC_VERSION}-$${os}-$${arch}.zip -d protoc-${PROTOC_VERSION}-$${os}-$${arch}; \
rm protoc-${PROTOC_VERSION}-$${os}-$${arch}.zip; \
mv -f protoc-${PROTOC_VERSION}-$${os}-$${arch}/bin/protoc $(PROTOC); \
rm -rf protoc-${PROTOC_VERSION}-$${os}-$${arch}; \
$(call go-get-tool,$(PROTOC_GEN_GO),google.golang.org/protobuf/cmd/protoc-gen-go@latest); \
$(call go-get-tool,$(PROTOC_GEN_GO_GRPC),google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest)

# Prepare release
include e2e-tests/release_versions
CERT_MANAGER_VER := $(shell grep -Eo "cert-manager v.*" go.mod|grep -Eo "[0-9]+\.[0-9]+\.[0-9]+")
Expand Down
12 changes: 12 additions & 0 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ RUN GOOS=$GOOS GOARCH=${TARGETARCH} CGO_ENABLED=$CGO_ENABLED GO_LDFLAGS=$GO_LDFL
go build -o build/_output/bin/pitr \
cmd/pitr/main.go \
&& cp -r build/_output/bin/pitr /usr/local/bin/pitr

RUN GOOS=$GOOS GOARCH=${TARGETARCH} CGO_ENABLED=$CGO_ENABLED GO_LDFLAGS=$GO_LDFLAGS \
go build -o build/_output/bin/xtrabackup-server-sidecar \
cmd/xtrabackup/server/main.go \
&& cp -r build/_output/bin/xtrabackup-server-sidecar /usr/local/bin/xtrabackup-server-sidecar

RUN GOOS=$GOOS GOARCH=${TARGETARCH} CGO_ENABLED=$CGO_ENABLED GO_LDFLAGS=$GO_LDFLAGS \
go build -o build/_output/bin/xtrabackup-run-backup \
cmd/xtrabackup/run-backup/main.go \
&& cp -r build/_output/bin/xtrabackup-run-backup /usr/local/bin/xtrabackup-run-backup

RUN GOOS=$GOOS GOARCH=${TARGETARCH} CGO_ENABLED=$CGO_ENABLED GO_LDFLAGS=$GO_LDFLAGS \
go build -ldflags "-w -s -X main.GitCommit=$GIT_COMMIT -X main.GitBranch=$GIT_BRANCH -X main.BuildTime=$BUILD_TIME" \
Expand All @@ -55,6 +65,8 @@ COPY --from=go_builder /usr/local/bin/percona-xtradb-cluster-operator /usr/local
COPY --from=go_builder /usr/local/bin/peer-list /peer-list
COPY --from=go_builder /usr/local/bin/pitr /pitr
COPY --from=go_builder /usr/local/bin/mysql-state-monitor /mysql-state-monitor
COPY --from=go_builder /usr/local/bin/xtrabackup-server-sidecar /xtrabackup-server-sidecar
COPY --from=go_builder /usr/local/bin/xtrabackup-run-backup /xtrabackup-run-backup
COPY build/pxc-entrypoint.sh /pxc-entrypoint.sh
COPY build/pxc-init-entrypoint.sh /pxc-init-entrypoint.sh
COPY build/pitr-init-entrypoint.sh /pitr-init-entrypoint.sh
Expand Down
1 change: 1 addition & 0 deletions build/backup-init-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -o errexit
set -o xtrace

install -o "$(id -u)" -g "$(id -g)" -m 0755 -D /peer-list /opt/percona/peer-list
install -o "$(id -u)" -g "$(id -g)" -m 0755 -D /xtrabackup-run-backup /opt/percona/xtrabackup-run-backup

mkdir -p /opt/percona/backup/lib/pxc
install -o "$(id -u)" -g "$(id -g)" -m 0755 -D /backup/lib/pxc/* /opt/percona/backup/lib/pxc/
Expand Down
45 changes: 32 additions & 13 deletions build/backup/recovery-cloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ fi
# shellcheck disable=SC2086
xbcloud get --parallel="$(grep -c processor /proc/cpuinfo)" ${XBCLOUD_ARGS} "$(destination)" | xbstream -x -C "${tmp}" --parallel="$(grep -c processor /proc/cpuinfo)" $XBSTREAM_EXTRA_ARGS

set +o xtrace
if [[ -f "${tmp}/sst_info" ]]; then
transition_key=$(vault_get "$tmp/sst_info")
if [[ -n $transition_key && $transition_key != null ]]; then
MYSQL_VERSION=$(parse_ini 'mysql-version' "$tmp/sst_info")
if ! check_for_version "$MYSQL_VERSION" '5.7.29' \
&& [[ $MYSQL_VERSION != '5.7.28-31-57.2' ]]; then

# shellcheck disable=SC2016
transition_key='$transition_key'
fi

transition_option="--transition-key=$transition_key"
echo transition-key exists
fi
fi

PXB_VAULT_PREPARE_ARGS=""
PXB_VAULT_MOVEBACK_ARGS=""
VAULT_CONFIG_FILE=/etc/mysql/vault-keyring-secret/keyring_vault.conf
Expand All @@ -65,23 +82,18 @@ if [[ -f ${VAULT_CONFIG_FILE} ]]; then
PXB_VAULT_PREPARE_ARGS="${PXB_VAULT_MOVEBACK_ARGS}"
else
PXB_VAULT_MOVEBACK_ARGS="--keyring-vault-config=${VAULT_CONFIG_FILE} --early-plugin-load=keyring_vault.so"

# If backup-my.cnf does not contain plugin_load, then --prepare will fail if you pass the --keyring-vault-config option.
if [[ -n "$(parse_ini 'plugin_load' "${tmp}/backup-my.cnf")" ]] && [[ -z $transition_key ]]; then
PXB_VAULT_PREPARE_ARGS="--keyring-vault-config=${VAULT_CONFIG_FILE}"
fi
fi
fi

set +o xtrace
transition_key=$(vault_get "$tmp/sst_info")
if [[ -n $transition_key && $transition_key != null ]]; then
MYSQL_VERSION=$(parse_ini 'mysql-version' "$tmp/sst_info")
if ! check_for_version "$MYSQL_VERSION" '5.7.29' \
&& [[ $MYSQL_VERSION != '5.7.28-31-57.2' ]]; then

# shellcheck disable=SC2016
transition_key='$transition_key'
fi

transition_option="--transition-key=$transition_key"

if [ -f "${tmp}/xtrabackup_keys" ]; then
master_key_options="--generate-new-master-key"
echo transition-key exists
fi

# Extract --defaults-file from XB_EXTRA_ARGS if present and place it as the first argument
Expand All @@ -108,6 +120,13 @@ if ! check_for_version "$XTRABACKUP_VERSION" '8.0.0'; then
XB_EXTRA_ARGS="$XB_EXTRA_ARGS --binlog-info=ON"
fi

DEFAULTS_GROUP="--defaults-group=mysqld"
if [[ ${XTRABACKUP_ENABLED} == "true" ]]; then
# these must not be set for pxb
DEFAULTS_GROUP=""
DEFAULTS_FILE=""
fi

echo "+ xtrabackup $DEFAULTS_FILE ${XB_USE_MEMORY+--use-memory=$XB_USE_MEMORY} --prepare \
$REMAINING_XB_ARGS --rollback-prepared-trx --xtrabackup-plugin-dir=/usr/lib64/xtrabackup/plugin \
--target-dir=$tmp ${PXB_VAULT_PREPARE_ARGS}"
Expand All @@ -122,7 +141,7 @@ echo "+ xtrabackup $DEFAULTS_FILE --defaults-group=mysqld --datadir=/datadir --m
${PXB_VAULT_MOVEBACK_ARGS} --xtrabackup-plugin-dir=/usr/lib64/xtrabackup/plugin --target-dir=$tmp"

# shellcheck disable=SC2086
xtrabackup $DEFAULTS_FILE --defaults-group=mysqld --datadir=/datadir --move-back $REMAINING_XB_ARGS \
xtrabackup $DEFAULTS_FILE $DEFAULTS_GROUP --datadir=/datadir --move-back $REMAINING_XB_ARGS \
--force-non-empty-directories $transition_option $master_key_options \
${PXB_VAULT_MOVEBACK_ARGS} --xtrabackup-plugin-dir=/usr/lib64/xtrabackup/plugin --target-dir="$tmp"

Expand Down
1 change: 1 addition & 0 deletions build/pxc-init-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ install -o "$(id -u)" -g "$(id -g)" -m 0755 -D /pxc-configure-pxc.sh /var/lib/my
install -o "$(id -u)" -g "$(id -g)" -m 0755 -D /liveness-check.sh /var/lib/mysql/liveness-check.sh
install -o "$(id -u)" -g "$(id -g)" -m 0755 -D /readiness-check.sh /var/lib/mysql/readiness-check.sh
install -o "$(id -u)" -g "$(id -g)" -m 0755 -D /peer-list /var/lib/mysql/peer-list
install -o "$(id -u)" -g "$(id -g)" -m 0755 -D /xtrabackup-server-sidecar /var/lib/mysql/xtrabackup-server-sidecar
install -o "$(id -u)" -g "$(id -g)" -m 0755 -D /get-pxc-state /var/lib/mysql/get-pxc-state
install -o "$(id -u)" -g "$(id -g)" -m 0755 -D /pmm-prerun.sh /var/lib/mysql/pmm-prerun.sh
install -o "$(id -u)" -g "$(id -g)" -m 0755 -D /mysql-state-monitor /var/lib/mysql/mysql-state-monitor
Expand Down
17 changes: 17 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/percona/percona-xtradb-cluster-operator/pkg/apis"
pxcv1 "github.com/percona/percona-xtradb-cluster-operator/pkg/apis/pxc/v1"
"github.com/percona/percona-xtradb-cluster-operator/pkg/controller"
"github.com/percona/percona-xtradb-cluster-operator/pkg/features"
"github.com/percona/percona-xtradb-cluster-operator/pkg/k8s"
"github.com/percona/percona-xtradb-cluster-operator/pkg/version"
"github.com/percona/percona-xtradb-cluster-operator/pkg/webhook"
Expand Down Expand Up @@ -89,6 +90,19 @@ func main() {
os.Exit(1)
}

fg := features.NewGate()
if err := fg.Set(os.Getenv("PXCO_FEATURE_GATES")); err != nil {
setupLog.Error(err, "failed to set feature gates")
os.Exit(1)
}
fgCtx := features.NewContextWithGate(context.Background(), fg)
setupLog.Info("Feature gates",
// These are set by the user
"PXCO_FEATURE_GATES", features.ShowAssigned(fgCtx),
// These are enabled, including features that are on by default
"enabled", features.ShowEnabled(fgCtx),
)

options := ctrl.Options{
Scheme: scheme,
Metrics: metricsServer.Options{
Expand All @@ -100,6 +114,9 @@ func main() {
WebhookServer: ctrlWebhook.NewServer(ctrlWebhook.Options{
Port: 9443,
}),
BaseContext: func() context.Context {
return features.NewContextWithGate(context.Background(), fg)
},
}

err = configureGroupKindConcurrency(&options)
Expand Down
Loading
Loading