Skip to content
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

add eventType argument to RecordNodeStatusChange #127014

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/controller/nodeipam/ipam/range_allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (r *rangeAllocator) AllocateOrOccupyCIDR(ctx context.Context, node *v1.Node
for idx := range r.cidrSets {
podCIDR, err := r.cidrSets[idx].AllocateNext()
if err != nil {
controllerutil.RecordNodeStatusChange(logger, r.recorder, node, "CIDRNotAvailable")
controllerutil.RecordNodeStatusChange(logger, r.recorder, node, v1.EventTypeWarning, "CIDRNotAvailable")
return fmt.Errorf("failed to allocate cidr from cluster cidr at idx:%v: %v", idx, err)
}
allocatedCIDRs[idx] = podCIDR
Expand Down Expand Up @@ -425,7 +425,7 @@ func (r *rangeAllocator) updateCIDRsAllocation(ctx context.Context, nodeName str
}
// failed release back to the pool
logger.Error(err, "Failed to update node PodCIDR after multiple attempts", "node", klog.KObj(node), "podCIDRs", cidrsString)
controllerutil.RecordNodeStatusChange(logger, r.recorder, node, "CIDRAssignmentFailed")
controllerutil.RecordNodeStatusChange(logger, r.recorder, node, v1.EventTypeWarning, "CIDRAssignmentFailed")
// We accept the fact that we may leak CIDRs here. This is safer than releasing
// them in case when we don't know if request went through.
// NodeController restart will return all falsely allocated CIDRs to the pool.
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/nodelifecycle/node_lifecycle_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ func (nc *Controller) monitorNodeHealth(ctx context.Context) error {
switch {
case currentReadyCondition.Status != v1.ConditionTrue && observedReadyCondition.Status == v1.ConditionTrue:
// Report node event only once when status changed.
controllerutil.RecordNodeStatusChange(logger, nc.recorder, node, "NodeNotReady")
controllerutil.RecordNodeStatusChange(logger, nc.recorder, node, v1.EventTypeWarning, "NodeNotReady")
fallthrough
case needsRetry && observedReadyCondition.Status != v1.ConditionTrue:
if err = controllerutil.MarkPodsNotReady(ctx, nc.kubeClient, nc.recorder, pods, node.Name); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/util/node/controller_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func RecordNodeEvent(ctx context.Context, recorder record.EventRecorder, nodeNam
}

// RecordNodeStatusChange records a event related to a node status change. (Common to lifecycle and ipam)
func RecordNodeStatusChange(logger klog.Logger, recorder record.EventRecorder, node *v1.Node, newStatus string) {
func RecordNodeStatusChange(logger klog.Logger, recorder record.EventRecorder, node *v1.Node, eventType, newStatus string) {
ref := &v1.ObjectReference{
APIVersion: "v1",
Kind: "Node",
Expand All @@ -186,7 +186,7 @@ func RecordNodeStatusChange(logger klog.Logger, recorder record.EventRecorder, n
logger.V(2).Info("Recording status change event message for node", "status", newStatus, "node", node.Name)
// TODO: This requires a transaction, either both node status is updated
// and event is recorded or neither should happen, see issue #6055.
recorder.Eventf(ref, v1.EventTypeNormal, newStatus, "Node %s status is now: %s", node.Name, newStatus)
recorder.Eventf(ref, eventType, newStatus, "Node %s status is now: %s", node.Name, newStatus)
}

// SwapNodeControllerTaint returns true in case of success and false
Expand Down