|
7 | 7 | "time" |
8 | 8 |
|
9 | 9 | "github.com/pkg/errors" |
| 10 | + "k8s.io/apimachinery/pkg/api/meta" |
10 | 11 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
11 | 12 |
|
12 | 13 | "github.com/percona/percona-backup-mongodb/pbm/defs" |
@@ -57,14 +58,23 @@ const ( |
57 | 58 |
|
58 | 59 | // PerconaServerMongoDBRestoreStatus defines the observed state of PerconaServerMongoDBRestore |
59 | 60 | 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"` |
66 | 68 | } |
67 | 69 |
|
| 70 | +const ( |
| 71 | + ConditionPBMAgentConfiguredForSnapshot string = "PBMAgentConfiguredForSnapshot" |
| 72 | + ConditionReplsetPVCsRestoredFromSnapshot string = "ReplsetPVCsRestoredFromSnapshot" |
| 73 | + ConditionPBMAgentAwaitingRestoreFinish string = "PBMAgentAwaitingRestoreFinish" |
| 74 | + ConditionPBMAwaitingRestoreFinished string = "PBMAwaitingRestoreFinish" |
| 75 | + ConditionPBMRestoreFinished string = "PBMRestoreFinished" |
| 76 | +) |
| 77 | + |
68 | 78 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
69 | 79 |
|
70 | 80 | // PerconaServerMongoDBRestore is the Schema for the perconaservermongodbrestores API |
@@ -92,6 +102,18 @@ type PerconaServerMongoDBRestoreList struct { |
92 | 102 | Items []PerconaServerMongoDBRestore `json:"items"` |
93 | 103 | } |
94 | 104 |
|
| 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 | + |
95 | 117 | func (r *PerconaServerMongoDBRestore) SetDefaults() error { |
96 | 118 | if bs := r.Spec.BackupSource; bs != nil { |
97 | 119 | if bs.Type == "" { |
|
0 commit comments