Skip to content

Commit

Permalink
Merge branch 'main' into K8SPXC-1079-standardize-service-exposure
Browse files Browse the repository at this point in the history
  • Loading branch information
inelpandzic authored Dec 3, 2023
2 parents 2662e2d + 6a3f339 commit 68245f7
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions cmd/pitr/collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 5 additions & 2 deletions cmd/pitr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/pxc.percona.com_perconaxtradbclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ spec:
type: string
timeBetweenUploads:
type: number
timeoutSeconds:
type: number
type: object
schedule:
items:
Expand Down
2 changes: 2 additions & 0 deletions deploy/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,8 @@ spec:
type: string
timeBetweenUploads:
type: number
timeoutSeconds:
type: number
type: object
schedule:
items:
Expand Down
1 change: 1 addition & 0 deletions deploy/cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ spec:
enabled: false
storageName: STORAGE-NAME-HERE
timeBetweenUploads: 60
timeoutSeconds: 60
# resources:
# requests:
# memory: 0.1G
Expand Down
2 changes: 2 additions & 0 deletions deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,8 @@ spec:
type: string
timeBetweenUploads:
type: number
timeoutSeconds:
type: number
type: object
schedule:
items:
Expand Down
2 changes: 2 additions & 0 deletions deploy/cw-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,8 @@ spec:
type: string
timeBetweenUploads:
type: number
timeoutSeconds:
type: number
type: object
schedule:
items:
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/pxc/v1/pxc_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,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 {
Expand Down Expand Up @@ -907,6 +908,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 {
Expand Down
10 changes: 10 additions & 0 deletions pkg/pxc/app/deployment/binlog-collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 68245f7

Please sign in to comment.