Skip to content

Commit d6f5bbd

Browse files
rafabeneclaude
andcommitted
HYPERFLEET-1017 - refactor: rename aggregated Available condition to LastKnownReconciled
Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 60956b9 commit d6f5bbd

6 files changed

Lines changed: 95 additions & 63 deletions

File tree

openapi/openapi.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ paths:
5050
5151
**Note**: The `status` object in the response is read-only and computed by the service.
5252
It is NOT part of the request body. Initially,
53-
status.conditions will include mandatory "Available", "Ready" and "Reconciled" conditions.
53+
status.conditions will include mandatory "LastKnownReconciled", "Ready" and "Reconciled" conditions.
5454
parameters: []
5555
responses:
5656
'201':
@@ -189,7 +189,7 @@ paths:
189189
created_time: '2021-01-01T10:00:00Z'
190190
last_updated_time: '2021-01-01T10:00:00Z'
191191
last_transition_time: '2021-01-01T10:00:00Z'
192-
- type: Available
192+
- type: LastKnownReconciled
193193
status: 'True'
194194
reason: All adapters reported Available True for the same generation
195195
message: All adapters reported Available True for the same generation
@@ -394,7 +394,7 @@ paths:
394394
created_time: '2021-01-01T10:00:00Z'
395395
last_updated_time: '2021-01-01T10:00:00Z'
396396
last_transition_time: '2021-01-01T10:00:00Z'
397-
- type: Available
397+
- type: LastKnownReconciled
398398
status: 'True'
399399
reason: All adapters reported Available True for the same generation
400400
message: All adapters reported Available True for the same generation
@@ -1075,7 +1075,7 @@ components:
10751075
created_time: '2021-01-01T10:00:00Z'
10761076
last_updated_time: '2021-01-01T10:00:00Z'
10771077
last_transition_time: '2021-01-01T10:00:00Z'
1078-
- type: Available
1078+
- type: LastKnownReconciled
10791079
status: 'True'
10801080
reason: All adapters reported Available True for the same generation
10811081
message: All adapters reported Available True for the same generation
@@ -1199,7 +1199,7 @@ components:
11991199
**Mandatory conditions**:
12001200
- `type: "Ready"` *(deprecated — use Reconciled)*: Whether all adapters report successfully at the current generation.
12011201
- `type: "Reconciled"`: Whether the resource's desired state has been fully reconciled by all adapters at the current generation.
1202-
- `type: "Available"`: Aggregated adapter result for a common observed_generation.
1202+
- `type: "LastKnownReconciled"`: Aggregated adapter result for a common observed_generation. Sticky — stays True as long as all required adapters were reconciled at a common observed generation, even if a new generation is being processed.
12031203
12041204
These conditions are present immediately upon resource creation.
12051205
description: |-
@@ -1374,7 +1374,7 @@ components:
13741374
created_time: '2021-01-01T10:00:00Z'
13751375
last_updated_time: '2021-01-01T10:00:00Z'
13761376
last_transition_time: '2021-01-01T10:00:00Z'
1377-
- type: Available
1377+
- type: LastKnownReconciled
13781378
status: 'True'
13791379
reason: All adapters reported Available True for the same generation
13801380
message: All adapters reported Available True for the same generation
@@ -1565,7 +1565,7 @@ components:
15651565
**Mandatory conditions**:
15661566
- `type: "Ready"` *(deprecated — use Reconciled)*: Whether all adapters report successfully at the current generation.
15671567
- `type: "Reconciled"`: Whether the resource's desired state has been fully reconciled by all adapters at the current generation.
1568-
- `type: "Available"`: Aggregated adapter result for a common observed_generation.
1568+
- `type: "LastKnownReconciled"`: Aggregated adapter result for a common observed_generation. Sticky — stays True as long as all required adapters were reconciled at a common observed generation, even if a new generation is being processed.
15691569
15701570
These conditions are present immediately upon resource creation.
15711571
description: |-

pkg/api/status_types.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ func (s AdapterConditionStatus) IsValid() bool {
2828

2929
// Condition type constants
3030
const (
31-
ConditionTypeAvailable = "Available"
32-
ConditionTypeApplied = "Applied"
33-
ConditionTypeHealth = "Health"
34-
ConditionTypeReady = "Ready"
35-
ConditionTypeReconciled = "Reconciled"
36-
ConditionTypeFinalized = "Finalized"
31+
ConditionTypeAvailable = "Available"
32+
ConditionTypeLastKnownReconciled = "LastKnownReconciled"
33+
ConditionTypeApplied = "Applied"
34+
ConditionTypeHealth = "Health"
35+
ConditionTypeReady = "Ready"
36+
ConditionTypeReconciled = "Reconciled"
37+
ConditionTypeFinalized = "Finalized"
3738
)
3839

3940
// ResourceCondition represents a condition of a resource

pkg/services/aggregation.go

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const (
2525
)
2626

2727
// fixedConditionCount is the number of top-level conditions always present in resource status:
28-
// Ready (deprecated), Reconciled, and Available.
28+
// Ready (deprecated), Reconciled, and LastKnownReconciled.
2929
const fixedConditionCount = 3
3030

3131
// reasonMissingRequiredAdapters is the reason code for the Ready condition when one or more
@@ -52,7 +52,7 @@ func ValidateMandatoryConditions(conditions []api.AdapterCondition) (errorType,
5252
return "", ""
5353
}
5454

55-
// --- Aggregated Ready / Available -------------------------------------------------
55+
// --- Aggregated Reconciled / LastKnownReconciled ----------------------------------
5656

5757
// adapterConditionSuffixMap allows overriding the default suffix for specific adapters (reserved).
5858
var adapterConditionSuffixMap = map[string]string{}
@@ -107,7 +107,7 @@ func AdapterObservedTime(as *api.AdapterStatus) time.Time {
107107
return as.LastReportTime
108108
}
109109

110-
// AggregateResourceStatus computes Reconciled, Available, and per-adapter conditions from stored adapter
110+
// AggregateResourceStatus computes Reconciled, LastKnownReconciled, and per-adapter conditions from stored adapter
111111
// rows and previous conditions. It does not use wall clock.
112112
//
113113
// The returned adapterConditions slice contains one entry per required adapter that has reported,
@@ -128,7 +128,7 @@ func AggregateResourceStatus(ctx context.Context, in AggregateResourceStatusInpu
128128
reports,
129129
in.HasChildResources,
130130
)
131-
available = computeAvailable(
131+
available = computeLastKnownReconciled(
132132
in.RefTime,
133133
prevAvail,
134134
in.RequiredAdapters,
@@ -163,6 +163,11 @@ func parsePrevConditions(ctx context.Context, raw []byte) (
163163
case api.ConditionTypeReconciled:
164164
prevReconciled = &c
165165
case api.ConditionTypeAvailable:
166+
// Migration: legacy records stored this as "Available"
167+
if prevAvail == nil {
168+
prevAvail = &c
169+
}
170+
case api.ConditionTypeLastKnownReconciled:
166171
prevAvail = &c
167172
default:
168173
prevAdapterByType[c.Type] = &c
@@ -423,14 +428,14 @@ func computeReadyLastTransitionTime(
423428
return newLastUpdated
424429
}
425430

426-
// computeAvailableStatus decides the Available condition status from normalized adapter snapshots.
431+
// computeLastKnownReconciledStatus decides the LastKnownReconciled condition status from normalized adapter snapshots.
427432
//
428433
// Rules (in order):
429434
// 1. No required adapters, or any required adapter has not yet reported → False.
430435
// 2. All adapters True at a uniform generation, or mixed-gen but aggregate was already True → True.
431436
// 3. Some adapter is False, but aggregate was True and no False is at the tracked generation → True (sticky).
432437
// 4. Otherwise → False.
433-
func computeAvailableStatus(
438+
func computeLastKnownReconciledStatus(
434439
prev *api.ResourceCondition,
435440
required []string,
436441
byAdapter map[string]adapterAvailableSnapshot,
@@ -469,18 +474,18 @@ func computeAvailableStatus(
469474
return api.ConditionTrue
470475
}
471476

472-
func computeAvailable(
477+
func computeLastKnownReconciled(
473478
refTime time.Time,
474479
prev *api.ResourceCondition,
475480
required []string,
476481
byAdapter map[string]adapterAvailableSnapshot,
477482
) api.ResourceCondition {
478483
allTrue, commonGen, mixed := sameGenerationAllTrue(required, byAdapter)
479-
status := computeAvailableStatus(prev, required, byAdapter, allTrue, mixed)
484+
status := computeLastKnownReconciledStatus(prev, required, byAdapter, allTrue, mixed)
480485

481-
obsGen := computeAvailableObservedGeneration(status, prev, required, byAdapter, allTrue, commonGen, mixed)
486+
obsGen := computeLastKnownReconciledObservedGeneration(status, prev, required, byAdapter, allTrue, commonGen, mixed)
482487

483-
lastUpdated := computeAvailableLastUpdatedTime(
488+
lastUpdated := computeLastKnownReconciledLastUpdatedTime(
484489
status, prev, refTime, required, byAdapter, obsGen, allTrue, mixed,
485490
)
486491
lastTransition := computeGenericLastTransitionTime(prev, status, lastUpdated)
@@ -498,7 +503,7 @@ func computeAvailable(
498503
}
499504

500505
return api.ResourceCondition{
501-
Type: api.ConditionTypeAvailable,
506+
Type: api.ConditionTypeLastKnownReconciled,
502507
Status: status,
503508
ObservedGeneration: obsGen,
504509
Reason: strPtr(reason),
@@ -533,7 +538,7 @@ func sameGenerationAllTrue(
533538
return true, *g, mixed
534539
}
535540

536-
func computeAvailableObservedGeneration(
541+
func computeLastKnownReconciledObservedGeneration(
537542
status api.ResourceConditionStatus,
538543
prev *api.ResourceCondition,
539544
required []string,
@@ -576,7 +581,7 @@ func computeAvailableObservedGeneration(
576581
return maxG
577582
}
578583

579-
func computeAvailableLastUpdatedTime(
584+
func computeLastKnownReconciledLastUpdatedTime(
580585
status api.ResourceConditionStatus,
581586
prev *api.ResourceCondition,
582587
refTime time.Time,

0 commit comments

Comments
 (0)