Skip to content

Commit

Permalink
K8SPXC-1152: restore stucks on operator restart
Browse files Browse the repository at this point in the history
https://perconadev.atlassian.net/browse/K8SPXC-1152

fix unit test

fix for pvc restores

refactor

fix tests

fix `security-context` test

add unit-test

improvements

add TODO comment
  • Loading branch information
pooknull committed Jan 9, 2025
1 parent 191f386 commit df69c14
Show file tree
Hide file tree
Showing 17 changed files with 795 additions and 438 deletions.
20 changes: 20 additions & 0 deletions config/crd/bases/pxc.percona.com_perconaxtradbclusterrestores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -354,16 +354,36 @@ spec:
type: object
status:
properties:
clusterSize:
format: int32
type: integer
comments:
type: string
completed:
format: date-time
type: string
haproxySize:
format: int32
type: integer
lastscheduled:
format: date-time
type: string
proxysqlSize:
format: int32
type: integer
state:
type: string
unsafeFlags:
properties:
backupIfUnhealthy:
type: boolean
proxySize:
type: boolean
pxcSize:
type: boolean
tls:
type: boolean
type: object
type: object
type: object
served: true
Expand Down
20 changes: 20 additions & 0 deletions deploy/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -597,16 +597,36 @@ spec:
type: object
status:
properties:
clusterSize:
format: int32
type: integer
comments:
type: string
completed:
format: date-time
type: string
haproxySize:
format: int32
type: integer
lastscheduled:
format: date-time
type: string
proxysqlSize:
format: int32
type: integer
state:
type: string
unsafeFlags:
properties:
backupIfUnhealthy:
type: boolean
proxySize:
type: boolean
pxcSize:
type: boolean
tls:
type: boolean
type: object
type: object
type: object
served: true
Expand Down
20 changes: 20 additions & 0 deletions deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -597,16 +597,36 @@ spec:
type: object
status:
properties:
clusterSize:
format: int32
type: integer
comments:
type: string
completed:
format: date-time
type: string
haproxySize:
format: int32
type: integer
lastscheduled:
format: date-time
type: string
proxysqlSize:
format: int32
type: integer
state:
type: string
unsafeFlags:
properties:
backupIfUnhealthy:
type: boolean
proxySize:
type: boolean
pxcSize:
type: boolean
tls:
type: boolean
type: object
type: object
type: object
served: true
Expand Down
20 changes: 20 additions & 0 deletions deploy/cw-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -597,16 +597,36 @@ spec:
type: object
status:
properties:
clusterSize:
format: int32
type: integer
comments:
type: string
completed:
format: date-time
type: string
haproxySize:
format: int32
type: integer
lastscheduled:
format: date-time
type: string
proxysqlSize:
format: int32
type: integer
state:
type: string
unsafeFlags:
properties:
backupIfUnhealthy:
type: boolean
proxySize:
type: boolean
pxcSize:
type: boolean
tls:
type: boolean
type: object
type: object
type: object
served: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ metadata:
percona.com/restore-svc-name: restore-src-restore-pvc-sec-context
name: restore-src-restore-pvc-sec-context
ownerReferences:
- controller: true
- blockOwnerDeletion: true
controller: true
kind: PerconaXtraDBClusterRestore
name: restore-pvc
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ metadata:
percona.com/restore-svc-name: restore-src-restore-pvc-sec-context
name: restore-src-restore-pvc-sec-context
ownerReferences:
- controller: true
- blockOwnerDeletion: true
controller: true
kind: PerconaXtraDBClusterRestore
name: restore-pvc
spec:
Expand Down
5 changes: 4 additions & 1 deletion pkg/apis/pxc/v1/pxc_prestore_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ type PerconaXtraDBClusterRestoreStatus struct {
Comments string `json:"comments,omitempty"`
CompletedAt *metav1.Time `json:"completed,omitempty"`
LastScheduled *metav1.Time `json:"lastscheduled,omitempty"`
PXCSize int32 `json:"clusterSize,omitempty"`
HAProxySize int32 `json:"haproxySize,omitempty"`
ProxySQLSize int32 `json:"proxysqlSize,omitempty"`
Unsafe UnsafeFlags `json:"unsafeFlags,omitempty"`
}

type PITR struct {
Expand Down Expand Up @@ -63,7 +67,6 @@ type BcpRestoreStates string

const (
RestoreNew BcpRestoreStates = ""
RestoreStarting BcpRestoreStates = "Starting"
RestoreStopCluster BcpRestoreStates = "Stopping Cluster"
RestoreRestore BcpRestoreStates = "Restoring"
RestoreStartCluster BcpRestoreStates = "Starting Cluster"
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/pxc/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/controller/pxc/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ func (r *ReconcilePerconaXtraDBCluster) isRestoreRunning(clusterName, namespace
}

switch v.Status.State {
case api.RestoreStarting, api.RestoreStopCluster, api.RestoreRestore,
case api.RestoreStopCluster, api.RestoreRestore,
api.RestoreStartCluster, api.RestorePITR:
return true, nil
}
Expand Down
Loading

0 comments on commit df69c14

Please sign in to comment.