Skip to content

Commit

Permalink
Merge pull request #1761 from briantkennedy/gen
Browse files Browse the repository at this point in the history
Log Generation / Observed generation.
  • Loading branch information
k8s-ci-robot authored Feb 27, 2023
2 parents 24b762c + d81769a commit 31d02ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions conformance/utils/kubernetes/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,14 @@ func ConditionsHaveLatestObservedGeneration(obj metav1.Object, conditions []meta
return nil
}

wantGeneration := obj.GetGeneration()
var b strings.Builder
fmt.Fprint(&b, "expected observedGeneration to be updated for all conditions")
fmt.Fprintf(&b, "expected observedGeneration to be updated to %d for all conditions", wantGeneration)
fmt.Fprintf(&b, ", only %d/%d were updated.", len(conditions)-len(staleConditions), len(conditions))
fmt.Fprintf(&b, " stale conditions are: ")

for i, c := range staleConditions {
fmt.Fprintf(&b, c.Type)
fmt.Fprintf(&b, "%s (generation %d)", c.Type, c.ObservedGeneration)
if i != len(staleConditions)-1 {
fmt.Fprintf(&b, ", ")
}
Expand Down
4 changes: 2 additions & 2 deletions conformance/utils/kubernetes/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestVerifyConditionsMatchGeneration(t *testing.T) {
{Type: "FakeCondition2", ObservedGeneration: 19},
{Type: "FakeCondition3", ObservedGeneration: 20},
},
expected: fmt.Errorf("expected observedGeneration to be updated for all conditions, only 2/3 were updated. stale conditions are: FakeCondition2"),
expected: fmt.Errorf("expected observedGeneration to be updated to 20 for all conditions, only 2/3 were updated. stale conditions are: FakeCondition2 (generation 19)"),
},
{
name: "conditions where most do not match the generation fail verification",
Expand All @@ -121,7 +121,7 @@ func TestVerifyConditionsMatchGeneration(t *testing.T) {
{Type: "FakeCondition5", ObservedGeneration: 16},
{Type: "FakeCondition6", ObservedGeneration: 15},
},
expected: fmt.Errorf("expected observedGeneration to be updated for all conditions, only 1/6 were updated. stale conditions are: FakeCondition1, FakeCondition2, FakeCondition3, FakeCondition5, FakeCondition6"),
expected: fmt.Errorf("expected observedGeneration to be updated to 20 for all conditions, only 1/6 were updated. stale conditions are: FakeCondition1 (generation 18), FakeCondition2 (generation 18), FakeCondition3 (generation 14), FakeCondition5 (generation 16), FakeCondition6 (generation 15)"),
},
}

Expand Down

0 comments on commit 31d02ae

Please sign in to comment.