Skip to content

Commit

Permalink
Merge pull request #47 from kloeckner-i/METAL-2613/backup_activedeadl…
Browse files Browse the repository at this point in the history
…ineseconds

METAL-2613 configurable activedeadline seconds
  • Loading branch information
hyunysmile authored Apr 22, 2021
2 parents b1c5b7e + 29ea46d commit 6fbc752
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 7 deletions.
5 changes: 3 additions & 2 deletions helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
DB Operator is Kubernetes operator

## Prerequisites
* Kubernetes 1.13+
* Helm 2.11+
* Kubernetes v1.14+
* Helm v3.0.2+

## Configuring helm client
```
Expand Down Expand Up @@ -47,6 +47,7 @@ The following table lists the configurable parameters of the db-operator chart a
| `config.instance.google.proxy.image` | Container image of google cloud proxy | `gcr.io/cloudsql-docker/gce-proxy:1.11` |
| `config.instance.google.proxy.nodeSelector` | Node labels for google cloud proxy pod assignment | `{}` |
| `config.backup.nodeSelector` | Node labels for backup pod assignment | `{}` |
| `config.backup.activeDeadlineSeconds` | activeDeadlineSeconds of backup cronjob | `600` |
| `config.backup.postgres.image` | Container image of backup cronjob (only for postgres databases) | `kloeckneri/pgdump-gcs:latest` |
| `config.monitoring.nodeSelector` | Node labels for monitoring pod assignment | `{}` |
| `config.monitoring.postgres.image` | Container image of prometheus exporter (only for postgres databases) | `wrouesnel/postgres_exporter:latest` |
Expand Down
Binary file added helm/db-operator-0.4.0.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion helm/db-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ apiVersion: v1
appVersion: "1.0"
description: A Database Operator
name: db-operator
version: 0.3.0
version: 0.4.0
1 change: 1 addition & 0 deletions helm/db-operator/templates/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ data:
proxy:
image: {{ .Values.config.instance.percona.proxy.image }}
backup:
activeDeadlineSeconds: {{ .Values.config.backup.activeDeadlineSeconds }}
nodeSelector:
{{ toYaml .Values.config.backup.nodeSelector | indent 8 }}
postgres:
Expand Down
1 change: 1 addition & 0 deletions helm/db-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ config:
proxy:
image: severalnines/proxysql:2.0
backup:
activeDeadlineSeconds: 600 # 10m
nodeSelector: {}
postgres:
image: "kloeckneri/pgdump-gcs:latest"
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func TestLoadConfig(t *testing.T) {

confStatic.Instances.Google.ClientSecretName = "cloudsql-readonly-serviceaccount"
assert.Equal(t, confStatic.Instances.Google.ClientSecretName, confLoad.Instances.Google.ClientSecretName, "Values should be match")
assert.EqualValues(t, confLoad.Backup.ActiveDeadlineSeconds, int64(600))
}

func TestLoadConfigFailCases(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions pkg/config/test/config_ok.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ instance:
image: severalnines/proxysql:2.0
backup:
nodeSelector: {}
activeDeadlineSeconds: 600
postgres:
image: postgresbackupimage:latest
mysql:
Expand Down
7 changes: 4 additions & 3 deletions pkg/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ type proxyConfig struct {
// backupConfig defines docker image for creating database dump by backup cronjob
// backup cronjob will be created by db-operator when backup is enabled
type backupConfig struct {
Postgres postgresBackupConfig `yaml:"postgres"`
Mysql mysqlBackupConfig `yaml:"mysql"`
NodeSelector map[string]string `yaml:"nodeSelector"`
Postgres postgresBackupConfig `yaml:"postgres"`
Mysql mysqlBackupConfig `yaml:"mysql"`
NodeSelector map[string]string `yaml:"nodeSelector"`
ActiveDeadlineSeconds int64 `yaml:"activeDeadlineSeconds"`
}

type postgresBackupConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/database/backup/cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func buildCronJobSpec(dbcr *kciv1alpha1.Database) (batchv1beta1.CronJobSpec, err
}

func buildJobTemplate(dbcr *kciv1alpha1.Database) (batchv1beta1.JobTemplateSpec, error) {
ActiveDeadlineSeconds := int64(60 * 10) // 10m
ActiveDeadlineSeconds := int64(conf.Backup.ActiveDeadlineSeconds)
BackoffLimit := int32(3)
instance, err := dbcr.GetInstanceRef()
if err != nil {
Expand Down

0 comments on commit 6fbc752

Please sign in to comment.