Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions apis/meta/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,17 @@ limitations under the License.
package meta

const (
// ReconcileAtAnnotation is the annotation used for triggering a reconciliation
// outside of the defined schedule. Despite the name, the value is not
// interpreted as a timestamp, and any change in value shall trigger a
// reconciliation.
// DEPRECATED: has been replaced by ReconcileRequestAnnotation. For
// backward-compatibility, use ReconcileAnnotationValue, which will account for
// both annotations.
ReconcileAtAnnotation string = "fluxcd.io/reconcileAt"

// ReconcileRequestAnnotation is the annotation used for triggering a reconciliation
// outside of a defined schedule. The value is interpreted as a token, and any change
// in value SHOULD trigger a reconciliation.
ReconcileRequestAnnotation string = "reconcile.fluxcd.io/requestedAt"
)

// ReconcileAnnotationValue returns a value for the reconciliation request annotations, which can be used to detect
// changes; and, a boolean indicating whether either annotation was set.
// ReconcileAnnotationValue returns a value for the reconciliation request annotation, which can be used to detect
// changes; and, a boolean indicating whether the annotation was set.
func ReconcileAnnotationValue(annotations map[string]string) (string, bool) {
reconcileAt, ok1 := annotations[ReconcileAtAnnotation]
requestedAt, ok2 := annotations[ReconcileRequestAnnotation]
// the values are concatenated; this means
// - a change in either will be detectable*, and
// - if one is set, the value will be just that; and,
// - if neither is set, it's a zero value.
//
// *unless the change is to shift a substring across the
// interstice between the strings; e.g., by swapping the value
// from one annotation to the other. Assuming a fresh timestamp is
// used each time, this caveat won't matter.
return reconcileAt + requestedAt, ok1 || ok2
requestedAt, ok := annotations[ReconcileRequestAnnotation]
return requestedAt, ok
}

// ReconcileRequestStatus is a struct to embed in a status type, so that all types using the mechanism have the same
Expand Down
6 changes: 3 additions & 3 deletions apis/meta/annotations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func TestGetAnnotationValue(t *testing.T) {
}
obj.Status.SetLastHandledReconcileRequest(val)

// set one annotation: should detect a change
obj.Annotations[ReconcileAtAnnotation] = time.Now().Format(time.RFC3339Nano)
// set annotation: should detect a change
obj.Annotations[ReconcileRequestAnnotation] = time.Now().Format(time.RFC3339Nano)
val, ok = ReconcileAnnotationValue(obj.Annotations)
if !ok {
t.Error("expected ReconcileAnnotationValue to return true when an annotation is set")
Expand All @@ -54,7 +54,7 @@ func TestGetAnnotationValue(t *testing.T) {

obj.Status.SetLastHandledReconcileRequest(val)

// set the other annotation; should detect a change
// update annotation; should detect a change
obj.Annotations[ReconcileRequestAnnotation] = time.Now().Format(time.RFC3339Nano)
val, ok = ReconcileAnnotationValue(obj.Annotations)
if !ok {
Expand Down
24 changes: 0 additions & 24 deletions runtime/predicates/reconcile_at_changed.go

This file was deleted.