Skip to content

Commit a81a33f

Browse files
committed
BootID support for KMM
1 parent 56eddaf commit a81a33f

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

api/v1beta1/nodemodulesconfig_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ type NodeModuleStatus struct {
6868
Config ModuleConfig `json:"config,omitempty"`
6969
//+optional
7070
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
71+
//+optional
72+
BootId string `json:"bootId,omitempty"`
7173
}
7274

7375
// NodeModuleConfigStatus is the most recently observed status of the KMM modules on node.

config/crd/bases/kmm.sigs.x-k8s.io_nodemodulesconfigs.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ spec:
241241
state status
242242
items:
243243
properties:
244+
bootId:
245+
type: string
244246
config:
245247
properties:
246248
containerImage:

internal/controllers/nmc_reconciler.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,12 @@ func (h *nmcReconcilerHelperImpl) ProcessModuleSpec(
374374
return h.podManager.CreateLoaderPod(ctx, nmcObj, spec)
375375
}
376376

377-
if h.nodeAPI.NodeBecomeReadyAfter(node, status.LastTransitionTime) {
377+
currentBootId := node.Status.NodeInfo.BootID
378+
bootIdChanged := status.BootId != currentBootId
379+
if bootIdChanged {
380+
logger.Info("Detected BootId change")
381+
}
382+
if bootIdChanged || h.nodeAPI.NodeBecomeReadyAfter(node, status.LastTransitionTime) {
378383
logger.Info("node has been rebooted and become ready after kernel module was loaded; creating loader Pod")
379384
return h.podManager.CreateLoaderPod(ctx, nmcObj, spec)
380385
}
@@ -578,6 +583,12 @@ func (h *nmcReconcilerHelperImpl) SyncStatus(ctx context.Context, nmcObj *kmmv1b
578583
Terminated.
579584
FinishedAt
580585

586+
node := &v1.Node{}
587+
if err := h.client.Get(ctx, types.NamespacedName{Name: nmcObj.Name}, node); err != nil {
588+
logger.Error(err, "Failed to get node object", "node", nmcObj.Name)
589+
} else {
590+
status.BootId = node.Status.NodeInfo.BootID
591+
}
581592
status.LastTransitionTime = podLTT
582593

583594
nmc.SetModuleStatus(&nmcObj.Status.Modules, *status)

0 commit comments

Comments
 (0)