Skip to content

Commit 78b0e3d

Browse files
committed
fixup! feat: add DevWorkspace pruner
1 parent cdbf388 commit 78b0e3d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

controllers/pruner/pruner_controller.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (r *DevWorkspacePrunerReconciler) SetupWithManager(mgr ctrl.Manager) error
112112
return shouldReconcileOnUpdate(e, log)
113113
},
114114
CreateFunc: func(e event.CreateEvent) bool { return true },
115-
DeleteFunc: func(e event.DeleteEvent) bool { return false },
115+
DeleteFunc: func(e event.DeleteEvent) bool { return true },
116116
GenericFunc: func(e event.GenericEvent) bool { return false },
117117
}
118118

@@ -287,6 +287,7 @@ func (r *DevWorkspacePrunerReconciler) dryRunPruneStrategy(retainTime time.Durat
287287
log.Info(fmt.Sprintf("Found %d DevWorkspaces to prune", len(filteredObjs)))
288288

289289
// Return an empty list of DevWorkspaces because this is a dry-run
290+
log.Info("Dry run mode: no DevWorkspaces will be pruned")
290291
return []client.Object{}, nil
291292
}
292293
}
@@ -320,11 +321,9 @@ func canPrune(dw dwv2.DevWorkspace, retainTime time.Duration, log logr.Logger) b
320321
}
321322

322323
var startTime *metav1.Time
323-
for _, condition := range dw.Status.Conditions {
324-
if condition.Type == conditions.Started {
325-
startTime = &condition.LastTransitionTime
326-
break
327-
}
324+
startedCondition := conditions.GetConditionByType(dw.Status.Conditions, conditions.Started)
325+
if startedCondition != nil {
326+
startTime = &startedCondition.LastTransitionTime
328327
}
329328
if startTime == nil {
330329
log.Info(fmt.Sprintf("Skipping DevWorkspace '%s/%s': missing 'Started' condition", dw.Namespace, dw.Name))

0 commit comments

Comments
 (0)