Skip to content

Commit 617585c

Browse files
wip: snapshot restore improvements
Signed-off-by: Mayank Shah <mayank.shah@percona.com>
1 parent 7230fea commit 617585c

17 files changed

Lines changed: 633 additions & 154 deletions

File tree

config/crd/bases/psmdb.percona.com_perconaservermongodbrestores.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,42 @@ spec:
272272
completed:
273273
format: date-time
274274
type: string
275+
conditions:
276+
items:
277+
properties:
278+
lastTransitionTime:
279+
format: date-time
280+
type: string
281+
message:
282+
maxLength: 32768
283+
type: string
284+
observedGeneration:
285+
format: int64
286+
minimum: 0
287+
type: integer
288+
reason:
289+
maxLength: 1024
290+
minLength: 1
291+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
292+
type: string
293+
status:
294+
enum:
295+
- "True"
296+
- "False"
297+
- Unknown
298+
type: string
299+
type:
300+
maxLength: 316
301+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
302+
type: string
303+
required:
304+
- lastTransitionTime
305+
- message
306+
- reason
307+
- status
308+
- type
309+
type: object
310+
type: array
275311
error:
276312
type: string
277313
lastTransition:

deploy/bundle.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,42 @@ spec:
565565
completed:
566566
format: date-time
567567
type: string
568+
conditions:
569+
items:
570+
properties:
571+
lastTransitionTime:
572+
format: date-time
573+
type: string
574+
message:
575+
maxLength: 32768
576+
type: string
577+
observedGeneration:
578+
format: int64
579+
minimum: 0
580+
type: integer
581+
reason:
582+
maxLength: 1024
583+
minLength: 1
584+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
585+
type: string
586+
status:
587+
enum:
588+
- "True"
589+
- "False"
590+
- Unknown
591+
type: string
592+
type:
593+
maxLength: 316
594+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
595+
type: string
596+
required:
597+
- lastTransitionTime
598+
- message
599+
- reason
600+
- status
601+
- type
602+
type: object
603+
type: array
568604
error:
569605
type: string
570606
lastTransition:

deploy/cr.yaml

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: minio-secret
5+
stringData:
6+
AWS_ACCESS_KEY_ID: "minioadmin"
7+
AWS_SECRET_ACCESS_KEY: "minioadmin"
8+
---
19
apiVersion: psmdb.percona.com/v1
210
kind: PerconaServerMongoDB
311
metadata:
@@ -122,7 +130,9 @@ spec:
122130
# priority: 0
123131
# - host: 34.124.76.92
124132
# # for more configuration fields refer to https://docs.mongodb.com/manual/reference/configuration-options/
125-
# configuration: |
133+
configuration: |
134+
security:
135+
enableEncryption: false
126136
# operationProfiling:
127137
# mode: slowOp
128138
# systemLog:
@@ -759,7 +769,7 @@ spec:
759769

760770
backup:
761771
enabled: true
762-
image: perconalab/percona-server-mongodb-operator:main-backup
772+
image: perconalab/percona-backup-mongodb:nightly
763773
# startingDeadlineSeconds: 300
764774
# hookScript:
765775
# configMapRef:
@@ -778,7 +788,7 @@ spec:
778788
# memory: "1Gi"
779789
# containerSecurityContext:
780790
# privileged: false
781-
# storages:
791+
storages:
782792
# s3-us-east:
783793
# main: true
784794
# type: s3
@@ -811,19 +821,15 @@ spec:
811821
# backoffInitial: 1
812822
# backoffMax: 30
813823
# backoffMultiplier: 2
814-
# minio:
815-
# type: minio
816-
# minio:
817-
# bucket: MINIO-BACKUP-BUCKET-NAME-HERE
818-
# region: us-east-1
819-
# credentialsSecret: my-cluster-name-backup-minio
820-
# endpointUrl: minio.psmdb.svc.cluster.local:9000/minio/
821-
# insecureSkipTLSVerify: false
822-
# caBundle:
823-
# name: minio-ca-bundle
824-
# key: ca.crt
825-
# prefix: ""
826-
# secure: false
824+
minio:
825+
type: minio
826+
minio:
827+
bucket: psmdb
828+
region: us-east-1
829+
credentialsSecret: minio-secret
830+
endpointUrl: minio.minio
831+
insecureSkipTLSVerify: true
832+
secure: true
827833
# azure-blob:
828834
# type: azure
829835
# azure:

deploy/crd.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,42 @@ spec:
565565
completed:
566566
format: date-time
567567
type: string
568+
conditions:
569+
items:
570+
properties:
571+
lastTransitionTime:
572+
format: date-time
573+
type: string
574+
message:
575+
maxLength: 32768
576+
type: string
577+
observedGeneration:
578+
format: int64
579+
minimum: 0
580+
type: integer
581+
reason:
582+
maxLength: 1024
583+
minLength: 1
584+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
585+
type: string
586+
status:
587+
enum:
588+
- "True"
589+
- "False"
590+
- Unknown
591+
type: string
592+
type:
593+
maxLength: 316
594+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
595+
type: string
596+
required:
597+
- lastTransitionTime
598+
- message
599+
- reason
600+
- status
601+
- type
602+
type: object
603+
type: array
568604
error:
569605
type: string
570606
lastTransition:

deploy/cw-bundle.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,42 @@ spec:
565565
completed:
566566
format: date-time
567567
type: string
568+
conditions:
569+
items:
570+
properties:
571+
lastTransitionTime:
572+
format: date-time
573+
type: string
574+
message:
575+
maxLength: 32768
576+
type: string
577+
observedGeneration:
578+
format: int64
579+
minimum: 0
580+
type: integer
581+
reason:
582+
maxLength: 1024
583+
minLength: 1
584+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
585+
type: string
586+
status:
587+
enum:
588+
- "True"
589+
- "False"
590+
- Unknown
591+
type: string
592+
type:
593+
maxLength: 316
594+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
595+
type: string
596+
required:
597+
- lastTransitionTime
598+
- message
599+
- reason
600+
- status
601+
- type
602+
type: object
603+
type: array
568604
error:
569605
type: string
570606
lastTransition:

e2e-tests/version-service/conf/crd.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,42 @@ spec:
565565
completed:
566566
format: date-time
567567
type: string
568+
conditions:
569+
items:
570+
properties:
571+
lastTransitionTime:
572+
format: date-time
573+
type: string
574+
message:
575+
maxLength: 32768
576+
type: string
577+
observedGeneration:
578+
format: int64
579+
minimum: 0
580+
type: integer
581+
reason:
582+
maxLength: 1024
583+
minLength: 1
584+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
585+
type: string
586+
status:
587+
enum:
588+
- "True"
589+
- "False"
590+
- Unknown
591+
type: string
592+
type:
593+
maxLength: 316
594+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
595+
type: string
596+
required:
597+
- lastTransitionTime
598+
- message
599+
- reason
600+
- status
601+
- type
602+
type: object
603+
type: array
568604
error:
569605
type: string
570606
lastTransition:

pkg/apis/psmdb/v1/perconaservermongodbrestore_types.go

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"time"
88

99
"github.com/pkg/errors"
10+
"k8s.io/apimachinery/pkg/api/meta"
1011
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1112

1213
"github.com/percona/percona-backup-mongodb/pbm/defs"
@@ -57,14 +58,23 @@ const (
5758

5859
// PerconaServerMongoDBRestoreStatus defines the observed state of PerconaServerMongoDBRestore
5960
type PerconaServerMongoDBRestoreStatus struct {
60-
State RestoreState `json:"state,omitempty"`
61-
PBMname string `json:"pbmName,omitempty"`
62-
PITRTarget string `json:"pitrTarget,omitempty"`
63-
Error string `json:"error,omitempty"`
64-
CompletedAt *metav1.Time `json:"completed,omitempty"`
65-
LastTransition *metav1.Time `json:"lastTransition,omitempty"`
61+
State RestoreState `json:"state,omitempty"`
62+
PBMname string `json:"pbmName,omitempty"`
63+
PITRTarget string `json:"pitrTarget,omitempty"`
64+
Error string `json:"error,omitempty"`
65+
CompletedAt *metav1.Time `json:"completed,omitempty"`
66+
LastTransition *metav1.Time `json:"lastTransition,omitempty"`
67+
Conditions []metav1.Condition `json:"conditions,omitempty"`
6668
}
6769

70+
const (
71+
ConditionPBMAgentConfiguredForSnapshot string = "PBMAgentConfiguredForSnapshot"
72+
ConditionReplsetPVCsRestoredFromSnapshot string = "ReplsetPVCsRestoredFromSnapshot"
73+
ConditionPBMAgentAwaitingRestoreFinish string = "PBMAgentAwaitingRestoreFinish"
74+
ConditionPBMAwaitingRestoreFinished string = "PBMAwaitingRestoreFinish"
75+
ConditionPBMRestoreFinished string = "PBMRestoreFinished"
76+
)
77+
6878
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
6979

7080
// PerconaServerMongoDBRestore is the Schema for the perconaservermongodbrestores API
@@ -92,6 +102,18 @@ type PerconaServerMongoDBRestoreList struct {
92102
Items []PerconaServerMongoDBRestore `json:"items"`
93103
}
94104

105+
func (status *PerconaServerMongoDBRestoreStatus) ConditionsEqual(otherStatus *PerconaServerMongoDBRestoreStatus) bool {
106+
if len(status.Conditions) != len(otherStatus.Conditions) {
107+
return false
108+
}
109+
for _, cond := range status.Conditions {
110+
if !meta.IsStatusConditionPresentAndEqual(otherStatus.Conditions, cond.Type, cond.Status) {
111+
return false
112+
}
113+
}
114+
return true
115+
}
116+
95117
func (r *PerconaServerMongoDBRestore) SetDefaults() error {
96118
if bs := r.Spec.BackupSource; bs != nil {
97119
if bs.Type == "" {

0 commit comments

Comments
 (0)