File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -188,9 +188,22 @@ func (m *cleanupManager) run(ctx context.Context) error {
188
188
stage_manager .ProtectionReasonBuiltWithinLastNHoursPolicy .SetDescription (fmt .Sprintf ("built within last %d hours" , keepImagesBuiltWithinLastNHours ))
189
189
190
190
if ! (m .ConfigMetaCleanup .DisableBuiltWithinLastNHoursPolicy || keepImagesBuiltWithinLastNHours == 0 ) {
191
+ loop:
191
192
for stageDescToDelete := range m .stageManager .GetStageDescSet ().Iter () {
192
- if (time .Since (stageDescToDelete .Info .GetCreatedAt ()).Hours ()) <= float64 (keepImagesBuiltWithinLastNHours ) {
193
- m .stageManager .MarkStageDescAsProtected (stageDescToDelete , stage_manager .ProtectionReasonBuiltWithinLastNHoursPolicy , false )
193
+ var hoursSinceCreationList []float64
194
+ if stageDescToDelete .Info .IsIndex {
195
+ for _ , platformInfo := range stageDescToDelete .Info .Index {
196
+ hoursSinceCreationList = append (hoursSinceCreationList , time .Since (platformInfo .GetCreatedAt ()).Hours ())
197
+ }
198
+ } else {
199
+ hoursSinceCreationList = append (hoursSinceCreationList , time .Since (stageDescToDelete .Info .GetCreatedAt ()).Hours ())
200
+ }
201
+
202
+ for _ , hoursSinceCreation := range hoursSinceCreationList {
203
+ if hoursSinceCreation <= float64 (keepImagesBuiltWithinLastNHours ) {
204
+ m .stageManager .MarkStageDescAsProtected (stageDescToDelete , stage_manager .ProtectionReasonBuiltWithinLastNHoursPolicy , false )
205
+ continue loop
206
+ }
194
207
}
195
208
}
196
209
}
You can’t perform that action at this time.
0 commit comments