Skip to content

Commit

Permalink
Add Backup and Restore hooks (#978)
Browse files Browse the repository at this point in the history
* wip: add backup and restore probes
* Add probe for sidecar model
* preBackup hook: add httpGet test
* preBackupHook: Add HTTP Post test
* preBackupHooks: add TCP probe test
* preBackupHooks: add Exec probe test
* Add postBackupHooks test
* Add restore hook test
* use busybox
* Make SetupWorkloadBackup() and SetupWorkloadRestore() configurable
* Execute postBackup/postRestore hook even if the backup/restore process fail
* wip: add hook for job model
* add hook for job model
* wip: add hook test for job model
* Add preBackup hook test for job model
* Add test of job model for preBackup hook
* Add test for job model of preRestore hook
* Add test for job model of postRestore hook
* wip: add preBackup hook test for database backup (MySQL)
* Complete preBackup hook test for database (MySQL)
* wip: add postBackup hook for database (MySQL)
* Add license header
* Use os.Chmod() to make the output file to all users
* wip: fix postBackup hook for database
* Fix postBackup test hook for database
* Add postRestore hook test for database (MySQL)
* Add postRestore hook test for database (MySQL)
* Remove unnecessary pod/exec permissions
* Remove unnecessary Can not be updated' comment
* Add debug helper for failed cases
* Print operator log after test suit + format log
* fix check
* Fix StatefulSet tests
* Fix failing cases
* comment out verify-gen
  • Loading branch information
hossainemruz authored and tamalsaha committed Dec 19, 2019
1 parent cc11d98 commit fa59718
Show file tree
Hide file tree
Showing 101 changed files with 12,888 additions and 1,088 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

- name: Run checks
run: |
sudo apt-get -qq update
sudo apt-get -qq update || true
sudo apt-get install -y bzr
make ci
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ BIN_PLATFORMS := $(DOCKER_PLATFORMS) windows/amd64 darwin/amd64
OS := $(if $(GOOS),$(GOOS),$(shell go env GOOS))
ARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))

BASEIMAGE_PROD ?= gcr.io/distroless/base
BASEIMAGE_PROD ?= busybox:1.31.1
BASEIMAGE_DBG ?= debian:stretch

IMAGE := $(REGISTRY)/$(BIN)
Expand Down Expand Up @@ -539,7 +539,7 @@ purge: uninstall
dev: gen fmt push

.PHONY: verify
verify: verify-modules verify-gen
verify: verify-gen # verify-modules

.PHONY: verify-modules
verify-modules:
Expand Down
12 changes: 6 additions & 6 deletions api/crds/bindata.go

Large diffs are not rendered by default.

56 changes: 43 additions & 13 deletions api/crds/stash.appscode.com_backupbatches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,18 @@ spec:
properties:
hooks:
description: Actions that Stash should take in response to
backup sessions. Cannot be updated.
backup sessions.
properties:
postBackup:
description: PostBackup is called immediately after a
backup session is complete.
properties:
containerName:
description: ContainerName specifies the name of the
container where to execute the commands for Exec
probe or where to find the port for HTTP or TCP
probe
type: string
exec:
description: One and only one of the following should
be specified. Exec specifies the action to take.
Expand Down Expand Up @@ -146,15 +152,17 @@ spec:
description: Body to set in the request.
type: string
form:
additionalProperties:
description: Form to set in the request body.
items:
properties:
key:
type: string
values:
items:
type: string
type: array
type: object
description: Form to set in the request body.
type: object
type: array
host:
description: Host name to connect to, defaults
to the pod IP. You probably want to set "Host"
Expand Down Expand Up @@ -221,6 +229,12 @@ spec:
description: PreBackup is called immediately before a
backup session is initiated.
properties:
containerName:
description: ContainerName specifies the name of the
container where to execute the commands for Exec
probe or where to find the port for HTTP or TCP
probe
type: string
exec:
description: One and only one of the following should
be specified. Exec specifies the action to take.
Expand Down Expand Up @@ -292,15 +306,17 @@ spec:
description: Body to set in the request.
type: string
form:
additionalProperties:
description: Form to set in the request body.
items:
properties:
key:
type: string
values:
items:
type: string
type: array
type: object
description: Form to set in the request body.
type: object
type: array
host:
description: Host name to connect to, defaults
to the pod IP. You probably want to set "Host"
Expand Down Expand Up @@ -2484,6 +2500,11 @@ spec:
description: PostBackup is called immediately after a backup session
is complete.
properties:
containerName:
description: ContainerName specifies the name of the container
where to execute the commands for Exec probe or where to find
the port for HTTP or TCP probe
type: string
exec:
description: One and only one of the following should be specified.
Exec specifies the action to take.
Expand Down Expand Up @@ -2550,15 +2571,17 @@ spec:
description: Body to set in the request.
type: string
form:
additionalProperties:
description: Form to set in the request body.
items:
properties:
key:
type: string
values:
items:
type: string
type: array
type: object
description: Form to set in the request body.
type: object
type: array
host:
description: Host name to connect to, defaults to the pod
IP. You probably want to set "Host" in httpHeaders instead.
Expand Down Expand Up @@ -2624,6 +2647,11 @@ spec:
description: PreBackup is called immediately before a backup session
is initiated.
properties:
containerName:
description: ContainerName specifies the name of the container
where to execute the commands for Exec probe or where to find
the port for HTTP or TCP probe
type: string
exec:
description: One and only one of the following should be specified.
Exec specifies the action to take.
Expand Down Expand Up @@ -2690,15 +2718,17 @@ spec:
description: Body to set in the request.
type: string
form:
additionalProperties:
description: Form to set in the request body.
items:
properties:
key:
type: string
values:
items:
type: string
type: array
type: object
description: Form to set in the request body.
type: object
type: array
host:
description: Host name to connect to, defaults to the pod
IP. You probably want to set "Host" in httpHeaders instead.
Expand Down
27 changes: 20 additions & 7 deletions api/crds/stash.appscode.com_backupconfigurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ spec:
type: string
hooks:
description: Actions that Stash should take in response to backup sessions.
Cannot be updated.
properties:
postBackup:
description: PostBackup is called immediately after a backup session
is complete.
properties:
containerName:
description: ContainerName specifies the name of the container
where to execute the commands for Exec probe or where to find
the port for HTTP or TCP probe
type: string
exec:
description: One and only one of the following should be specified.
Exec specifies the action to take.
Expand Down Expand Up @@ -136,15 +140,17 @@ spec:
description: Body to set in the request.
type: string
form:
additionalProperties:
description: Form to set in the request body.
items:
properties:
key:
type: string
values:
items:
type: string
type: array
type: object
description: Form to set in the request body.
type: object
type: array
host:
description: Host name to connect to, defaults to the pod
IP. You probably want to set "Host" in httpHeaders instead.
Expand Down Expand Up @@ -210,6 +216,11 @@ spec:
description: PreBackup is called immediately before a backup session
is initiated.
properties:
containerName:
description: ContainerName specifies the name of the container
where to execute the commands for Exec probe or where to find
the port for HTTP or TCP probe
type: string
exec:
description: One and only one of the following should be specified.
Exec specifies the action to take.
Expand Down Expand Up @@ -276,15 +287,17 @@ spec:
description: Body to set in the request.
type: string
form:
additionalProperties:
description: Form to set in the request body.
items:
properties:
key:
type: string
values:
items:
type: string
type: array
type: object
description: Form to set in the request body.
type: object
type: array
host:
description: Host name to connect to, defaults to the pod
IP. You probably want to set "Host" in httpHeaders instead.
Expand Down
Loading

0 comments on commit fa59718

Please sign in to comment.