Skip to content

Commit 49d8ffd

Browse files
committed
Optimize: Skip saving/restoring images when TriggerRound/RecoveryRound < 0
1 parent c87b5c7 commit 49d8ffd

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Diff for: internal/controller/snapshotpod_controller.go

+3
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,9 @@ func (r *SnapshotPodReconciler) Reconcile(ctx context.Context, req ctrl.Request)
299299
logger.Error(err, "get instance error")
300300
return ctrl.Result{}, err
301301
}
302+
if sp.Spec.TriggerRound <= 0 {
303+
return ctrl.Result{}, nil
304+
}
302305
type reconciler func(ctx context.Context, sp *snapshotpodv1alpha1.SnapshotPod) error
303306
type rec struct {
304307
typ string

Diff for: internal/webhooks/pod.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func (p *PodImageWebhookAdmission) handlePodCreate(ctx context.Context, pod *cor
183183
pullSecret: sp.Spec.ImageSaveOptions.RegistrySecretRef,
184184
}
185185
})
186-
} else {
186+
} else if sp.Spec.RecoveryRound == 0 {
187187
sort.Slice(sp.Status.Snapshots, func(i, j int) bool {
188188
return sp.Status.Snapshots[i].TriggerRound > sp.Status.Snapshots[j].TriggerRound
189189
})
@@ -199,6 +199,8 @@ func (p *PodImageWebhookAdmission) handlePodCreate(ctx context.Context, pod *cor
199199
}
200200
}
201201
})
202+
} else {
203+
return nil, false
202204
}
203205
return out, len(out) > 0
204206
}

0 commit comments

Comments
 (0)