-
Notifications
You must be signed in to change notification settings - Fork 9
Implementation of the pool status aggregation (milestone-3c) #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alicefr
wants to merge
11
commits into
bootc-dev:main
Choose a base branch
from
alicefr:milestone-3c
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
19a1773
controller: return the rollout state results
alicefr 329daa9
controller: add pool status aggregation logic
alicefr eb81c8b
controller: wire syncPoolStatus into Reconcile
alicefr 8722d7c
tests: add unit tests for syncPoolStatus
alicefr ec4249f
tests: add pool status assertions to e2e tests
alicefr 9da0121
api: add kubectl print columns for pool status counts
alicefr 57c0287
api: add short names for CRDs (bnp, bn)
alicefr 94907e5
docs: mark milestone 3c as completed
alicefr 14efd90
ci: bump e2e test timeout from 20m to 30m
alicefr 1ca9d8e
ci: move aa-teardown after podman install
alicefr 9e4ec70
daemon: filter BootcNode watch to spec-only changes
alicefr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package controller | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
|
|
||
| apimeta "k8s.io/apimachinery/pkg/api/meta" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
|
||
| bootcv1alpha1 "github.com/bootc-dev/bootc-operator/api/v1alpha1" | ||
| ) | ||
|
|
||
| // syncPoolStatus populates the pool's status counts, digest tracking, | ||
| // and UpToDate condition from the current rollout state. | ||
| func syncPoolStatus(pool *bootcv1alpha1.BootcNodePool, rs *rolloutState) { | ||
| if pool == nil || rs == nil { | ||
| return | ||
| } | ||
| pool.Status.ObservedGeneration = pool.Generation | ||
| pool.Status.NodeCount = int32(rs.nodeCount()) | ||
| pool.Status.UpdatedCount = int32(len(rs.upToDate)) | ||
| pool.Status.UpdatingCount = int32(len(rs.pending) + len(rs.staging) + len(rs.staged) + len(rs.rebooting)) | ||
| pool.Status.DegradedCount = int32(len(rs.degraded)) | ||
|
|
||
| if pool.Status.NodeCount == pool.Status.UpdatedCount { | ||
| pool.Status.DeployedDigest = pool.Status.TargetDigest | ||
| } | ||
| pool.Status.UpdateAvailable = pool.Status.TargetDigest != pool.Status.DeployedDigest | ||
|
|
||
| syncUpToDateCondition(pool, rs) | ||
| } | ||
|
|
||
| func syncUpToDateCondition(pool *bootcv1alpha1.BootcNodePool, rs *rolloutState) { | ||
| if pool == nil || rs == nil { | ||
| return | ||
| } | ||
| switch { | ||
| case pool.Spec.Rollout != nil && pool.Spec.Rollout.Paused && pool.Status.NodeCount != pool.Status.UpdatedCount: | ||
| apimeta.SetStatusCondition(&pool.Status.Conditions, metav1.Condition{ | ||
| Type: bootcv1alpha1.PoolUpToDate, | ||
| Status: metav1.ConditionFalse, | ||
| Reason: bootcv1alpha1.PoolPaused, | ||
| Message: rolloutBreakdown(pool, rs), | ||
| }) | ||
| case pool.Status.NodeCount != pool.Status.UpdatedCount: | ||
| apimeta.SetStatusCondition(&pool.Status.Conditions, metav1.Condition{ | ||
| Type: bootcv1alpha1.PoolUpToDate, | ||
| Status: metav1.ConditionFalse, | ||
| Reason: bootcv1alpha1.PoolRolloutInProgress, | ||
| Message: rolloutBreakdown(pool, rs), | ||
| }) | ||
| default: | ||
| apimeta.SetStatusCondition(&pool.Status.Conditions, metav1.Condition{ | ||
| Type: bootcv1alpha1.PoolUpToDate, | ||
| Status: metav1.ConditionTrue, | ||
| Reason: bootcv1alpha1.PoolAllUpdated, | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func rolloutBreakdown(pool *bootcv1alpha1.BootcNodePool, rs *rolloutState) string { | ||
| var b strings.Builder | ||
| fmt.Fprintf(&b, "%d/%d updated", len(rs.upToDate), rs.nodeCount()) | ||
|
|
||
| type bucket struct { | ||
| name string | ||
| count int | ||
| } | ||
| buckets := []bucket{ | ||
| {"pending", len(rs.pending)}, | ||
| {"staging", len(rs.staging)}, | ||
| {"staged", len(rs.staged)}, | ||
| {"rebooting", len(rs.rebooting)}, | ||
| {"degraded", len(rs.degraded)}, | ||
| } | ||
|
|
||
| b.WriteString("; ") | ||
| for i, bk := range buckets { | ||
| if i > 0 { | ||
| b.WriteString(", ") | ||
| } | ||
| fmt.Fprintf(&b, "%d %s", bk.count, bk.name) | ||
| } | ||
| return b.String() | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably run go fmt throughout the project as a separate PR