-
Notifications
You must be signed in to change notification settings - Fork 0
Added node logging #19
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ rules: | |
| - apiGroups: | ||
| - "" | ||
| resources: | ||
| - nodes | ||
| - pods | ||
| verbs: | ||
| - get | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -49,6 +49,7 @@ type LoggerReconciler struct { | |||||||||||
| // +kubebuilder:rbac:groups="",resources=pods,verbs=get;list;watch | ||||||||||||
| // +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch | ||||||||||||
| // +kubebuilder:rbac:groups=apps,resources=replicasets,verbs=get;list;watch | ||||||||||||
| // +kubebuilder:rbac:groups="",resources=nodes,verbs=get;list;watch | ||||||||||||
|
|
||||||||||||
| // Reconcile is part of the main kubernetes reconciliation loop which aims to | ||||||||||||
| // move the current state of the cluster closer to the desired state. | ||||||||||||
|
|
@@ -84,7 +85,13 @@ func rsLine(rs appsv1.ReplicaSet) string { | |||||||||||
| fmt.Sprintf("%d", rs.Status.Replicas) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| func (r *LoggerReconciler) loggerRequestsForPod( | ||||||||||||
| func nodeLine(node corev1.Node) string { | ||||||||||||
| return "node/" + node.Name + " " + | ||||||||||||
| node.Namespace + " " + | ||||||||||||
| fmt.Sprintf("%v", node.Status.Capacity) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
Comment on lines
+90
to
+93
|
||||||||||||
| node.Namespace + " " + | |
| fmt.Sprintf("%v", node.Status.Capacity) | |
| } | |
| fmt.Sprintf("%v", node.Status.Capacity) | |
| } |
Copilot
AI
Mar 12, 2026
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.
There are controller tests covering namespace vs cluster scope for pods/deployments/replicasets, but no tests covering the new nodes resource. Adding a test case for Resources: ["nodes"] (and especially for Namespace scope) would help catch issues like accidentally applying namespace list options to node listing.
Copilot
AI
Mar 12, 2026
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.
opts := listOptionsFromScope(&logger) may include client.InNamespace(...) for namespace-scoped loggers. Passing that into r.List for corev1.NodeList is not semantically valid (Nodes are cluster-scoped) and can lead to incorrect behavior or errors. Consider listing nodes without namespace list options (or skipping node logging when scope type is Namespace).
| if err := r.List(ctx, &nodelist, opts...); err != nil { | |
| if err := r.List(ctx, &nodelist); err != nil { |
Copilot
AI
Mar 12, 2026
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.
Adding a watch on corev1.Node{} will enqueue all Logger reconciles on every Node update. Node status changes (heartbeats/conditions) can be very frequent, which may cause reconcile/log storms. Consider removing the Node watch and relying on the existing periodic RequeueAfter, or add predicates to filter Node events down to meaningful changes.
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.
node.Status.Capacityis a map; formatting it with%vresults in non-deterministic key ordering in Go, making logs noisy and hard to diff. Consider logging a stable subset (cpu/memory) or formatting the ResourceList deterministically.