Skip to content

Commit

Permalink
Merge branch 'main' into k8spxc-1301-run-operator-locally
Browse files Browse the repository at this point in the history
  • Loading branch information
inelpandzic committed Dec 29, 2023
2 parents b153930 + 932c252 commit 87a8712
Show file tree
Hide file tree
Showing 146 changed files with 7,645 additions and 1,807 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ updates:
directory: /
schedule:
interval: monthly
day: "thursday"
time: "01:00"
reviewers:
- hors
- egegunes
Expand Down Expand Up @@ -41,3 +43,5 @@ updates:
- "dependencies"
schedule:
interval: monthly
day: "thursday"
time: "01:00"
8 changes: 4 additions & 4 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: '^1.19'
go-version: '^1.21'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand All @@ -32,9 +32,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: '^1.19'
go-version: '^1.21'
- run: go install mvdan.cc/sh/v3/cmd/shfmt@latest
- run: $(go env GOPATH)/bin/shfmt -f . | grep -v 'vendor' | xargs $(go env GOPATH)/bin/shfmt -bn -ci -s -w
- name: suggester / shfmt
Expand Down
43 changes: 39 additions & 4 deletions .github/workflows/scan.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,57 @@
name: Scan docker
on: [pull_request]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: docker.io

# github.repository as <account>/<repo>
IMAGE_NAME: perconalab/percona-xtradb-cluster-operator

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build an image from Dockerfile

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build an image from Dockerfile (linux/arm64)
run: |
export IMAGE=perconalab/percona-xtradb-cluster-operator:${{ github.sha }}
export IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-arm64
export DOCKER_PUSH=0
export DOCKER_SQUASH=0
export DOCKER_DEFAULT_PLATFORM='linux/arm64'
./e2e-tests/build
- name: Run Trivy vulnerability scanner
- name: Run Trivy vulnerability scanner image (linux/arm64)
uses: aquasecurity/[email protected]
with:
image-ref: '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-arm64'
format: 'table'
exit-code: '1'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'

- name: Build an image from Dockerfile (linux/amd64)
run: |
export IMAGE=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-amd64
export DOCKER_PUSH=0
export DOCKER_SQUASH=0
export DOCKER_DEFAULT_PLATFORM='linux/amd64'
./e2e-tests/build
- name: Run Trivy vulnerability scanner image (linux/amd64)
uses: aquasecurity/[email protected]
with:
image-ref: 'docker.io/perconalab/percona-xtradb-cluster-operator:${{ github.sha }}'
image-ref: '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-amd64'
format: 'table'
exit-code: '1'
ignore-unfixed: true
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ jobs:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: '^1.19'
go-version: '^1.21'
- uses: actions/checkout@v4
- name: go test
run: make test
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
linters-settings:
staticcheck:
checks:
- "-SA1019"
16 changes: 0 additions & 16 deletions ADOPTERS.md

This file was deleted.

5 changes: 3 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ EOF
docker login -u '${USER}' -p '${PASS}'
export RELEASE=0
export IMAGE=\$DOCKER_TAG
docker buildx create --use
./e2e-tests/build
docker logout
"
Expand All @@ -364,7 +365,7 @@ EOF
--rm \
-v $WORKSPACE/src/github.com/percona/percona-xtradb-cluster-operator:/go/src/github.com/percona/percona-xtradb-cluster-operator \
-w /go/src/github.com/percona/percona-xtradb-cluster-operator \
golang:1.19 sh -c '
golang:1.21 sh -c '
go install -mod=readonly github.com/google/go-licenses@latest;
/go/bin/go-licenses csv github.com/percona/percona-xtradb-cluster-operator/cmd/manager \
| cut -d , -f 3 \
Expand Down Expand Up @@ -393,7 +394,7 @@ EOF
-w /go/src/github.com/percona/percona-xtradb-cluster-operator \
-e GO111MODULE=on \
-e GOFLAGS='-buildvcs=false' \
golang:1.19 sh -c 'go build -v -o percona-xtradb-cluster-operator github.com/percona/percona-xtradb-cluster-operator/cmd/manager'
golang:1.21 sh -c 'go build -v -o percona-xtradb-cluster-operator github.com/percona/percona-xtradb-cluster-operator/cmd/manager'
"
'''

Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ uninstall: manifests ## Uninstall CRDs, rbac

.PHONY: deploy
deploy: ## Deploy operator
yq eval '(.spec.template.spec.containers[] | select(.name=="$(NAME)") | .image) = "$(IMAGE)"' $(DEPLOYDIR)/operator.yaml | kubectl apply -f -
yq eval '(.spec.template.spec.containers[] | select(.name=="$(NAME)") | .image) = "$(IMAGE)"' $(DEPLOYDIR)/operator.yaml \
| yq eval '(.spec.template.spec.containers[] | select(.name=="$(NAME)") | .env[] | select(.name=="DISABLE_TELEMETRY") | .value) = "true"' - \
| yq eval '(.spec.template.spec.containers[] | select(.name=="$(NAME)") | .env[] | select(.name=="LOG_LEVEL") | .value) = "DEBUG"' - \
| kubectl apply -f -

undeploy: ## Undeploy operator
kubectl delete -f $(DEPLOYDIR)/operator.yaml
Expand Down
14 changes: 0 additions & 14 deletions adopters/example/README.md

This file was deleted.

15 changes: 0 additions & 15 deletions adopters/leviatan/README.md

This file was deleted.

33 changes: 0 additions & 33 deletions adopters/users/laimison/README.md

This file was deleted.

13 changes: 0 additions & 13 deletions adopters/users/spron-in/README.md

This file was deleted.

5 changes: 2 additions & 3 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19 AS go_builder
FROM golang:1.21 AS go_builder
WORKDIR /go/src/github.com/percona/percona-xtradb-cluster-operator

COPY . .
Expand All @@ -8,12 +8,11 @@ ARG GIT_BRANCH
ARG BUILD_TIME
ARG GO_LDFLAGS
ARG GOOS=linux
ARG GOARCH=amd64
ARG CGO_ENABLED=0

RUN go mod download \
&& mkdir -p build/_output/bin \
&& GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=$CGO_ENABLED GO_LDFLAGS=$GO_LDFLAGS \
&& GOOS=$GOOS 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" \
-o build/_output/bin/percona-xtradb-cluster-operator \
cmd/manager/main.go \
Expand Down
3 changes: 3 additions & 0 deletions build/pmm-prerun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

set -o errexit

CLUSTER_NAME="${PMM_PREFIX}${CLUSTER_NAME}"
PMM_AGENT_SETUP_NODE_NAME="${PMM_PREFIX}${PMM_AGENT_SETUP_NODE_NAME}"

pmm_args=()

read -ra PMM_ADMIN_CUSTOM_PARAMS_ARRAY <<<"$PMM_ADMIN_CUSTOM_PARAMS"
Expand Down
10 changes: 1 addition & 9 deletions build/pxc-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ fi
# add sst.cpat to exclude pxc-entrypoint, unsafe-bootstrap, pxc-configure-pxc from SST cleanup
grep -q "^progress=" $CFG && sed -i "s|^progress=.*|progress=1|" $CFG
grep -q "^\[sst\]" "$CFG" || printf '[sst]\n' >>"$CFG"
grep -q "^cpat=" "$CFG" || sed '/^\[sst\]/a cpat=.*\\.pem$\\|.*init\\.ok$\\|.*galera\\.cache$\\|.*wsrep_recovery_verbose\\.log$\\|.*readiness-check\\.sh$\\|.*liveness-check\\.sh$\\|.*get-pxc-state$\\|.*sst_in_progress$\\|.*pmm-prerun\\.sh$\\|.*sst-xb-tmpdir$\\|.*\\.sst$\\|.*gvwstate\\.dat$\\|.*grastate\\.dat$\\|.*\\.err$\\|.*\\.log$\\|.*RPM_UPGRADE_MARKER$\\|.*RPM_UPGRADE_HISTORY$\\|.*pxc-entrypoint\\.sh$\\|.*unsafe-bootstrap\\.sh$\\|.*pxc-configure-pxc\\.sh\\|.*peer-list$\\|.*auth_plugin$' "$CFG" 1<>"$CFG"
grep -q "^cpat=" "$CFG" || sed '/^\[sst\]/a cpat=.*\\.pem$\\|.*init\\.ok$\\|.*galera\\.cache$\\|.*wsrep_recovery_verbose\\.log$\\|.*readiness-check\\.sh$\\|.*liveness-check\\.sh$\\|.*get-pxc-state$\\|.*sst_in_progress$\\|.*sleep-forever$\\|.*pmm-prerun\\.sh$\\|.*sst-xb-tmpdir$\\|.*\\.sst$\\|.*gvwstate\\.dat$\\|.*grastate\\.dat$\\|.*\\.err$\\|.*\\.log$\\|.*RPM_UPGRADE_MARKER$\\|.*RPM_UPGRADE_HISTORY$\\|.*pxc-entrypoint\\.sh$\\|.*unsafe-bootstrap\\.sh$\\|.*pxc-configure-pxc\\.sh\\|.*peer-list$\\|.*auth_plugin$' "$CFG" 1<>"$CFG"
if [[ $MYSQL_VERSION == '8.0' ]]; then
if [[ $MYSQL_PATCH_VERSION -ge 26 ]]; then
grep -q "^skip_replica_start=ON" "$CFG" || sed -i "/\[mysqld\]/a skip_replica_start=ON" $CFG
Expand Down Expand Up @@ -226,7 +226,6 @@ else
fi

file_env 'XTRABACKUP_PASSWORD' 'xtrabackup' 'xtrabackup'
file_env 'CLUSTERCHECK_PASSWORD' '' 'clustercheck'

NODE_NAME=$(hostname -f)
NODE_PORT=3306
Expand Down Expand Up @@ -269,9 +268,6 @@ elif [ -n "$DISCOVERY_SERVICE" ]; then
{ set +x; } 2>/dev/null
sed -r "s|^[#]?wsrep_sst_auth=.*$|wsrep_sst_auth='xtrabackup:${XTRABACKUP_PASSWORD}'|" "${CFG}" 1<>"${CFG}"

/usr/bin/clustercheckcron clustercheck "${CLUSTERCHECK_PASSWORD}" 1 /var/lib/mysql/clustercheck.log 1 &
set -x

else
: checking incoming cluster parameters
NODE_IP=$(hostname -I | awk ' { print $1 } ')
Expand Down Expand Up @@ -396,7 +392,6 @@ if [ -z "$CLUSTER_JOIN" ] && [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
if [[ $MYSQL_VERSION == "8.0" ]] && ((MYSQL_PATCH_VERSION >= 16)); then
read -r -d '' systemUserGrant <<-EOSQL || true
GRANT SYSTEM_USER ON *.* TO 'monitor'@'${MONITOR_HOST}';
GRANT SYSTEM_USER ON *.* TO 'clustercheck'@'localhost';
EOSQL
fi

Expand All @@ -422,9 +417,6 @@ if [ -z "$CLUSTER_JOIN" ] && [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
GRANT SELECT ON performance_schema.* TO 'monitor'@'${MONITOR_HOST}';
${monitorConnectGrant}
CREATE USER 'clustercheck'@'localhost' IDENTIFIED BY '$(escape_special "${CLUSTERCHECK_PASSWORD}")' PASSWORD EXPIRE NEVER;
GRANT PROCESS ON *.* TO 'clustercheck'@'localhost';
${systemUserGrant}
CREATE USER 'replication'@'%' IDENTIFIED BY '$(escape_special "${REPLICATION_PASSWORD}")' PASSWORD EXPIRE NEVER;
Expand Down
17 changes: 10 additions & 7 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/webhook"
metricsServer "sigs.k8s.io/controller-runtime/pkg/metrics/server"
ctrlWebhook "sigs.k8s.io/controller-runtime/pkg/webhook"

_ "github.com/Percona-Lab/percona-version-service/api"
"github.com/percona/percona-xtradb-cluster-operator/pkg/apis"
Expand Down Expand Up @@ -71,7 +72,7 @@ func main() {
setupLog.Info("Runs on", "platform", sv.Platform, "version", sv.Info)

setupLog.Info("Manager starting up", "gitCommit", GitCommit, "gitBranch", GitBranch,
"goVersion", runtime.Version(), "os", runtime.GOOS, "arch", runtime.GOARCH)
"buildTime", BuildTime, "goVersion", runtime.Version(), "os", runtime.GOOS, "arch", runtime.GOARCH)

namespace, err := k8s.GetWatchNamespace()
if err != nil {
Expand All @@ -86,13 +87,15 @@ func main() {

options := ctrl.Options{
Scheme: scheme,
WebhookServer: webhook.NewServer(webhook.Options{
Metrics: metricsServer.Options{
BindAddress: metricsAddr,
},
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "08db0feb.percona.com",
WebhookServer: ctrlWebhook.NewServer(ctrlWebhook.Options{
Port: 9443,
}),
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "08db1feb.percona.com",
LeaderElectionNamespace: operatorNamespace,
}

// Add support for MultiNamespace set in WATCH_NAMESPACE
Expand Down
Loading

0 comments on commit 87a8712

Please sign in to comment.