Emit Kubernetes Events - #155
Open
HarshwardhanPatil07 wants to merge 7 commits into
Open
Conversation
HarshwardhanPatil07
force-pushed
the
issue-101-k8s-events
branch
from
September 2, 2026 09:09
b8f0464 to
75fbea9
Compare
Collaborator
Author
ptalgulk01
reviewed
Sep 2, 2026
HarshwardhanPatil07
force-pushed
the
issue-101-k8s-events
branch
from
September 3, 2026 06:14
75fbea9 to
1fc7d50
Compare
Collaborator
Author
|
@ptalgulk01 Thanks. added the changes |
HarshwardhanPatil07
force-pushed
the
issue-101-k8s-events
branch
from
September 7, 2026 11:47
1fc7d50 to
4386b07
Compare
Collaborator
Author
|
rebase |
alicefr
reviewed
Sep 7, 2026
Collaborator
|
@HarshwardhanPatil07 can we split the commit 161e5e7 into mulitple. At least one per event type, like one for the draining stalls, one for the node events and one for the degraded nodes. |
HarshwardhanPatil07
force-pushed
the
issue-101-k8s-events
branch
from
September 8, 2026 06:58
4386b07 to
595e81d
Compare
alicefr
reviewed
Sep 8, 2026
| // truncateEventNote keeps notes within the events.k8s.io/v1 1 KiB limit and | ||
| // never splits a UTF-8 sequence. Event templates are fixed, but interpolated | ||
| // image references, condition messages, and errors are not length-bounded. | ||
| func truncateEventNote(note string) string { |
Collaborator
There was a problem hiding this comment.
I'm really not a big fan of truncate the string. I think instead we should use an interface and struct with well defined fields and functions that can shorten the string. Something like:
// Event note types — each knows its own max rendered length.
type PoolImageUpdateNote struct {
ImageRef string // max ~255 (OCI spec)
NewDigest string // fixed 71 (sha256:64hex)
PreviousDigest string // fixed 71
}
func (n PoolImageUpdateNote) Note() string {
return fmt.Sprintf("Image tag %s resolved to new digest %s (previously %s)",
n.ImageRef, shortDigest(n.NewDigest), shortDigest(n.PreviousDigest))
}
type PoolRolloutStartedNote struct {
TargetDigest string
}
func (n PoolRolloutStartedNote) Note() string {
return fmt.Sprintf("Rollout started toward digest %s", shortDigest(n.TargetDigest))
}
// Interface all event notes implement.
type EventNote interface {
Note() string
}
func shortDigest(d string) string {
if len(d) > 19 { // "sha256:" + 12 hex
return d[:19]
}
return d
}and then the recordEventf becomes:
func (r *BootcNodePoolReconciler) recordEvent(
regarding, related runtime.Object,
eventType, reason, action string,
note EventNote,)
{
r.Recorder.Eventf(regarding, related, eventType, reason, action, "%s", note.Note())
}| } | ||
|
|
||
| observationWithImage := observation + ":" + node.Spec.DesiredImage | ||
| switch idle.Reason { |
Collaborator
There was a problem hiding this comment.
Should we also add when the node becomes idle again?
Collaborator
Author
There was a problem hiding this comment.
added a nodeIdleNote "Node is up to date" event emitted when a node returns to idle
6 tasks
The controller may update BootcNode metadata while envtest simulates a daemon status update. Both operations advance resourceVersion, making a single Get followed by Status().Update susceptible to conflicts. Use client-go RetryOnConflict so the simulated daemon refetches the latest BootcNode before retrying its status update. Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
HarshwardhanPatil07
force-pushed
the
issue-101-k8s-events
branch
from
September 11, 2026 16:35
595e81d to
0ed183a
Compare
Expose image retargeting and rollout progress through Kubernetes Events so users can follow updates without reading controller logs. Record Events only after the corresponding pool status update succeeds, and grant the recorder access to the events.k8s.io API. Bound interpolated Event notes to the API's 1 KiB limit because image references and status messages are not fixed-length values. Related: bootc-dev#101 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Surface new and changed degraded pool conditions as Warning Events. Use the condition reason and message so users can identify invalid specs, node conflicts, and halted rollouts from standard Kubernetes tooling. Related: bootc-dev#101 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Report Staging, Staged, and Rebooting observations against each BootcNode, with the owning pool as the related object. Persist the last observation in controller-owned metadata so unrelated reconciles and controller restarts do not repeatedly emit the same transition. Related: bootc-dev#101 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Report failed drains immediately and warn once when an active drain exceeds five minutes. Requeue at the next stall deadline so a blocked drain is observable even when no other watched object changes. Keep Event reporting supplemental to rollout control: drain failures continue through the existing retry path and stalled-drain bookkeeping does not drive desired state. Related: bootc-dev#101 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Exercise pool, degraded, node, and drain Event behavior with exact reason, action, relationship, and note assertions. Cover transition deduplication, annotation write failures, tag resolution, drain scheduling, and UTF-8-safe note truncation. Use envtest Event objects filtered by regarding UID so retained Events from an earlier object with the same name cannot satisfy the integration assertions. Related: bootc-dev#101 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
Envtest does not exercise the deployed RBAC, Event broadcaster, daemon, or real reboot path. Extend the existing bink update and tag-resolution scenarios to assert the Events produced by a deployed operator. Filter Events by the regarding object UID and verify exact types, reasons, actions, notes, and related pool identity. Related: bootc-dev#101 Assisted-by: AI Signed-off-by: HarshwardhanPatil07 <harshpat@redhat.com>
HarshwardhanPatil07
force-pushed
the
issue-101-k8s-events
branch
from
September 11, 2026 16:43
0ed183a to
2279e10
Compare
Collaborator
Author
|
PTAL @alicefr |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pool Events:
ImageUpdateAvailableRolloutStartedRolloutCompletedNode Events:
StagingStagedRebootingDrainFailedDrainTakingTooLongNode Events reference the BootcNode as the primary object and the owning BootcNodePool as the related object.
Testing
Completed: Manual Event verification on a bink cluster
make buildimg make deploy-bink make e2e V=1 RUN='TestUpdateReboot\|TestTagResolution'watch events in second terminal:
kubectl get events.events.k8s.io -A --watchcloses: #101