Skip to content

Commit

Permalink
pvc - support for storage resize of zuul-executor, zuul-merger and ma…
Browse files Browse the repository at this point in the history
…riadb

For Zuul merger and executor the resize of belonging PVCs in case of
scaling is supported.

Change-Id: I635025547c03924d9a0990967e8de7ce179ad35d
  • Loading branch information
morucci committed Sep 6, 2024
1 parent 27c2c6b commit 2cb2685
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
5 changes: 4 additions & 1 deletion controllers/mariadb.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,10 @@ GRANT ALL ON *.* TO root@'%%' WITH GRANT OPTION;`,
}
}

isReady := stsReady && zuulDBSecret.Data != nil
pvcDataReadiness := r.reconcileExpandPVC(MariaDBIdent+"-"+MariaDBIdent+"-0", r.cr.Spec.MariaDB.DBStorage)
pvcLogsReadiness := r.reconcileExpandPVC(MariaDBIdent+"-logs-"+MariaDBIdent+"-0", r.cr.Spec.MariaDB.LogStorage)

isReady := stsReady && pvcDataReadiness && pvcLogsReadiness && zuulDBSecret.Data != nil

conds.UpdateConditions(&r.cr.Status.Conditions, MariaDBIdent, isReady)

Expand Down
21 changes: 20 additions & 1 deletion controllers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,25 @@ func BaseGetStorageConfOrDefault(storageSpec sfv1.StorageSpec, storageDefault sf
}
}

func (r *SFUtilContext) reconcileExpandPVCs(serviceName string, newStorageSpec sfv1.StorageSpec) bool {
PVCList := &apiv1.PersistentVolumeClaimList{}
err := r.Client.List(r.ctx, PVCList, client.MatchingLabels{"run": serviceName, "app": "sf"})
if err != nil {
utils.LogE(err, "Unable to get the list of PVC for service "+serviceName)
return false
}
readyList := []bool{}
for _, pvc := range PVCList.Items {
readyList = append(readyList, r.reconcileExpandPVC(pvc.Name, newStorageSpec))
}
for _, r := range readyList {
if !r {
return false
}
}
return true
}

// reconcileExpandPVC resizes the pvc with the spec
func (r *SFUtilContext) reconcileExpandPVC(pvcName string, newStorageSpec sfv1.StorageSpec) bool {
newQTY := newStorageSpec.Size
Expand Down Expand Up @@ -474,7 +493,7 @@ func (r *SFUtilContext) reconcileExpandPVC(pvcName string, newStorageSpec sfv1.S
case
apiv1.PersistentVolumeClaimResizing,
apiv1.PersistentVolumeClaimFileSystemResizePending:
utils.LogI("Volume resizing in progress, not ready")
utils.LogI("Volume " + pvcName + " resizing in progress, not ready")
return false
}
}
Expand Down
8 changes: 6 additions & 2 deletions controllers/zuul.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,9 @@ func (r *SFController) EnsureZuulExecutor(cfg *ini.File) bool {
return false
}

ready := r.IsStatefulSetReady(current)
pvcReadiness := r.reconcileExpandPVCs("zuul-executor", r.cr.Spec.Zuul.Executor.Storage)

ready := r.IsStatefulSetReady(current) && pvcReadiness
conds.UpdateConditions(&r.cr.Status.Conditions, "zuul-executor", ready)

return ready
Expand Down Expand Up @@ -675,7 +677,9 @@ func (r *SFController) EnsureZuulMerger(cfg *ini.File) bool {
return false
}

ready := r.IsStatefulSetReady(current)
pvcReadiness := r.reconcileExpandPVCs("zuul-merger", r.cr.Spec.Zuul.Merger.Storage)

ready := r.IsStatefulSetReady(current) && pvcReadiness
conds.UpdateConditions(&r.cr.Status.Conditions, service, ready)

return ready
Expand Down
6 changes: 6 additions & 0 deletions doc/reference/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ All notable changes to this project will be documented in this file.
### Fixed
### Security

## [v0.0.40] - 2024-09-06

### Added

- support for storage (PVC) resize of zuul-executor, zuul-merger and mariadb.

## [v0.0.39] - 2024-09-04

### Added
Expand Down

0 comments on commit 2cb2685

Please sign in to comment.