Skip to content

Commit

Permalink
Expect backup with nil summary to actually start
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvoncek committed Dec 3, 2024
1 parent d04f2ed commit 3ae146a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions controllers/medusa/medusabackupjob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ func (r *MedusaBackupJobReconciler) getBackupSummary(ctx context.Context, backup
return nil, err
} else {
for _, remoteBackup := range remoteBackups {
if remoteBackup == nil {
err := fmt.Errorf("backup %s summary is nil", backup.Name)
logger.Error(err, "remote backup is nil")
return nil, err
}
logger.Info("found backup", "CassandraPod", pod.Name, "Backup", remoteBackup.BackupName)
if backup.ObjectMeta.Name == remoteBackup.BackupName {
return remoteBackup, nil
Expand Down
10 changes: 8 additions & 2 deletions controllers/medusa/medusabackupjob_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,10 @@ func createAndVerifyMedusaBackup(dcKey framework.ClusterKey, dc *cassdcapi.Cassa
if backupName != backupWithNoPods {
t.Log("verify that the backups start eventually")
verifyBackupJobStarted(require.Eventually, t, dc, f, ctx, backupKey)
verifyBackupJobFinished(t, require, dc, f, ctx, backupKey, backupName)
if backupName != backupWithNilSummary {
// backup that will receive a nil summary will never finish, can't assert on that
verifyBackupJobFinished(t, require, dc, f, ctx, backupKey, backupName)
}
} else {
t.Log("verify that the backups never start")
verifyBackupJobStarted(require.Never, t, dc, f, ctx, backupKey)
Expand Down Expand Up @@ -536,9 +539,12 @@ func findDatacenterCondition(status *cassdcapi.CassandraDatacenterStatus, condTy

func deleteDatacenterPods(t *testing.T, f *framework.Framework, ctx context.Context, dcKey framework.ClusterKey, dc *cassdcapi.CassandraDatacenter) {
for i := 0; i < int(dc.Spec.Size); i++ {
pod := &corev1.Pod{}

podName := fmt.Sprintf("%s-%s-%d", dc.Spec.ClusterName, dc.DatacenterName(), i)
podKey := framework.NewClusterKey(dcKey.K8sContext, dcKey.Namespace, podName)
pod := &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{Name: podKey.Name, Namespace: podKey.Namespace},
}
err := f.Delete(ctx, podKey, pod)
if err != nil {
t.Logf("failed to delete pod %s: %v", podKey, err)
Expand Down

0 comments on commit 3ae146a

Please sign in to comment.