diff --git a/.github/workflows/scan.yml b/.github/workflows/scan.yml index 4a94138314..bd65638fdd 100644 --- a/.github/workflows/scan.yml +++ b/.github/workflows/scan.yml @@ -14,7 +14,7 @@ jobs: export DOCKER_SQUASH=0 ./e2e-tests/build - name: Run Trivy vulnerability scanner - uses: aquasecurity/trivy-action@0.13.1 + uses: aquasecurity/trivy-action@0.14.0 with: image-ref: 'docker.io/perconalab/percona-xtradb-cluster-operator:${{ github.sha }}' format: 'table' diff --git a/cmd/pitr/collector/collector.go b/cmd/pitr/collector/collector.go index 20d7807041..49bb18e1c3 100644 --- a/cmd/pitr/collector/collector.go +++ b/cmd/pitr/collector/collector.go @@ -41,6 +41,7 @@ type Config struct { BufferSize int64 `env:"BUFFER_SIZE"` CollectSpanSec float64 `env:"COLLECT_SPAN_SEC" envDefault:"60"` VerifyTLS bool `env:"VERIFY_TLS" envDefault:"true"` + TimeoutSeconds float64 `env:"TIMEOUT_SECONDS" envDefault:"60"` } type BackupS3 struct { diff --git a/cmd/pitr/main.go b/cmd/pitr/main.go index 51f19acedc..cae5d5b68e 100644 --- a/cmd/pitr/main.go +++ b/cmd/pitr/main.go @@ -45,9 +45,12 @@ func runCollector(ctx context.Context) { } log.Println("run binlog collector") for { - err := c.Run(ctx) + timeout, cancel := context.WithTimeout(ctx, time.Duration(config.CollectSpanSec)*time.Second) + defer cancel() + + err := c.Run(timeout) if err != nil { - log.Println("ERROR:", err) + log.Fatalln("ERROR:", err) } t := time.NewTimer(time.Duration(config.CollectSpanSec) * time.Second) diff --git a/config/crd/bases/pxc.percona.com_perconaxtradbclusters.yaml b/config/crd/bases/pxc.percona.com_perconaxtradbclusters.yaml index 02db77c543..6412d201e7 100644 --- a/config/crd/bases/pxc.percona.com_perconaxtradbclusters.yaml +++ b/config/crd/bases/pxc.percona.com_perconaxtradbclusters.yaml @@ -115,6 +115,8 @@ spec: type: string timeBetweenUploads: type: number + timeoutSeconds: + type: number type: object schedule: items: diff --git a/deploy/bundle.yaml b/deploy/bundle.yaml index d120743ea6..37681218b9 100644 --- a/deploy/bundle.yaml +++ b/deploy/bundle.yaml @@ -852,6 +852,8 @@ spec: type: string timeBetweenUploads: type: number + timeoutSeconds: + type: number type: object schedule: items: diff --git a/deploy/cr.yaml b/deploy/cr.yaml index b4e75b0b4b..c8c65df6af 100644 --- a/deploy/cr.yaml +++ b/deploy/cr.yaml @@ -507,6 +507,7 @@ spec: enabled: false storageName: STORAGE-NAME-HERE timeBetweenUploads: 60 + timeoutSeconds: 60 # resources: # requests: # memory: 0.1G diff --git a/deploy/crd.yaml b/deploy/crd.yaml index fe8902597e..63aa865d00 100644 --- a/deploy/crd.yaml +++ b/deploy/crd.yaml @@ -852,6 +852,8 @@ spec: type: string timeBetweenUploads: type: number + timeoutSeconds: + type: number type: object schedule: items: diff --git a/deploy/cw-bundle.yaml b/deploy/cw-bundle.yaml index 45494fe85c..524ef34200 100644 --- a/deploy/cw-bundle.yaml +++ b/deploy/cw-bundle.yaml @@ -852,6 +852,8 @@ spec: type: string timeBetweenUploads: type: number + timeoutSeconds: + type: number type: object schedule: items: diff --git a/e2e-tests/functions b/e2e-tests/functions index 20bb574a74..0af8c715ea 100755 --- a/e2e-tests/functions +++ b/e2e-tests/functions @@ -310,7 +310,7 @@ deploy_operator() { deploy_helm() { helm repo add hashicorp https://helm.releases.hashicorp.com - helm repo add minio https://helm.min.io/ + helm repo add minio https://charts.min.io/ helm repo update } @@ -1245,15 +1245,19 @@ start_minio() { local endpoint="http://minio-service:9000" local minio_args=( - --version 8.0.5 - --set accessKey=some-access-key - --set secretKey=some-secret-key + --version 5.0.14 + --set replicas=1 + --set mode=standalone + --set resources.requests.memory=256Mi + --set rootUser=rootuser + --set rootPassword=rootpass123 + --set "users[0].accessKey=some-access-key" + --set "users[0].secretKey=some-secret-key" + --set "users[0].policy=consoleAdmin" --set service.type=ClusterIP --set configPathmc=/tmp/.minio/ --set securityContext.enabled=false --set persistence.size=2G - --set environment.MINIO_REGION=us-east-1 - --set environment.MINIO_HTTP_TRACE=/tmp/trace.log ) if [[ -n $cert_secret ]]; then endpoint="https://minio-service:9000" diff --git a/pkg/apis/pxc/v1/pxc_types.go b/pkg/apis/pxc/v1/pxc_types.go index 6d9c934561..12f69e4f67 100644 --- a/pkg/apis/pxc/v1/pxc_types.go +++ b/pkg/apis/pxc/v1/pxc_types.go @@ -148,6 +148,7 @@ type PITRSpec struct { StorageName string `json:"storageName"` Resources corev1.ResourceRequirements `json:"resources,omitempty"` TimeBetweenUploads float64 `json:"timeBetweenUploads,omitempty"` + TimeoutSeconds float64 `json:"timeoutSeconds,omitempty"` } type PXCScheduledBackupSchedule struct { @@ -876,6 +877,10 @@ func (cr *PerconaXtraDBCluster) CheckNSetDefaults(serverVersion *version.ServerV if cr.Spec.Backup.PITR.TimeBetweenUploads == 0 { cr.Spec.Backup.PITR.TimeBetweenUploads = 60 } + + if cr.Spec.Backup.PITR.TimeoutSeconds == 0 { + cr.Spec.Backup.PITR.TimeoutSeconds = 3600 + } } for _, sch := range c.Backup.Schedule { diff --git a/pkg/pxc/app/deployment/binlog-collector.go b/pkg/pxc/app/deployment/binlog-collector.go index 1b552d7d82..65b0664dd0 100644 --- a/pkg/pxc/app/deployment/binlog-collector.go +++ b/pkg/pxc/app/deployment/binlog-collector.go @@ -69,6 +69,16 @@ func GetBinlogCollectorDeployment(cr *api.PerconaXtraDBCluster) (appsv1.Deployme Value: strconv.FormatInt(bufferSize, 10), }, }...) + + if cr.CompareVersionWith("1.14.0") >= 0 { + timeout := fmt.Sprintf("%.2f", cr.Spec.Backup.PITR.TimeoutSeconds) + + envs = append(envs, corev1.EnvVar{ + Name: "TIMEOUT_SECONDS", + Value: timeout, + }) + } + container := corev1.Container{ Name: "pitr", Image: cr.Spec.Backup.Image,