...
1 package reconcile
2
3 import (
4 "context"
5 "errors"
6
7 "edge-infra.dev/pkg/k8s/meta/status"
8 "edge-infra.dev/pkg/k8s/object"
9 "edge-infra.dev/pkg/k8s/runtime/conditions"
10 "edge-infra.dev/pkg/k8s/runtime/patch"
11 )
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 func Progressing(ctx context.Context,
30 obj conditions.Setter,
31 patcher *patch.SerialPatcher,
32 patchOpts ...patch.Option) error {
33 conditions.Progressing(obj, status.ProgressingReason, "Reconciliation in progress")
34
35 obsGen, err := object.GetStatusObservedGeneration(obj)
36 switch {
37 case err != nil && !errors.Is(err, object.ErrObservedGenerationNotFound):
38 return err
39 case err == nil:
40 if obsGen != obj.GetGeneration() {
41 conditions.Progressing(obj, status.ProgressingReason,
42 "processing object: new generation %d -> %d", obsGen, obj.GetGeneration())
43 return patcher.Patch(ctx, obj, patchOpts...)
44 }
45 }
46
47 var recAtVal string
48 if v, ok := GetAnnotation(obj.GetAnnotations()); ok {
49 recAtVal = v
50 }
51 lastRecHandledAtVal, err := GetStatusLastHandledReconcileAt(obj)
52 switch {
53 case !errors.Is(err, ErrLastHandledReconcileAtNotFound):
54 return err
55 case err != nil && recAtVal != lastRecHandledAtVal:
56 return patcher.Patch(ctx, obj, patchOpts...)
57 }
58
59 return nil
60 }
61
View as plain text