@@ -479,14 +479,27 @@ func (dcrh *deviceConfigReconcilerHelper) getDeviceConfigOwnedKMMModule(ctx cont
479479
480480func (dcrh * deviceConfigReconcilerHelper ) updateDeviceConfigNodeStatus (ctx context.Context , devConfig * amdv1alpha1.DeviceConfig , nodes * v1.NodeList ) error {
481481 logger := log .FromContext (ctx )
482+ previousUpgradeTimes := make (map [string ]string )
483+ // Persist the UpgradeStartTime
484+ for nodeName , moduleStatus := range devConfig .Status .NodeModuleStatus {
485+ previousUpgradeTimes [nodeName ] = moduleStatus .UpgradeStartTime
486+ }
482487 devConfig .Status .NodeModuleStatus = map [string ]amdv1alpha1.ModuleStatus {}
483488
484489 // for each node, fetch its status of modules configured by given DeviceConfig
485490 for _ , node := range nodes .Items {
486491 // if there is no module configured for given node
487- // the info under that node name will have only status
492+ // the info under that node name will have only status and upgrade start time
488493 // then it will be clear to see which node didn't get module configured
489- devConfig .Status .NodeModuleStatus [node .Name ] = amdv1alpha1.ModuleStatus {Status : dcrh .upgradeMgrHandler .GetNodeStatus (node .Name )}
494+ upgradeStartTime := previousUpgradeTimes [node .Name ]
495+
496+ currentStatus := dcrh .upgradeMgrHandler .GetNodeStatus (node .Name )
497+ if currentStatus == amdv1alpha1 .UpgradeStateFailed || currentStatus == amdv1alpha1 .UpgradeStateCordonFailed || currentStatus == amdv1alpha1 .UpgradeStateUncordonFailed || currentStatus == amdv1alpha1 .UpgradeStateDrainFailed || currentStatus == amdv1alpha1 .UpgradeStateRebootFailed || currentStatus == amdv1alpha1 .UpgradeStateComplete || currentStatus == amdv1alpha1 .UpgradeStateInstallComplete {
498+ upgradeStartTime = ""
499+ } else if upgradeStartTime == "" {
500+ upgradeStartTime = dcrh .upgradeMgrHandler .GetNodeUpgradeStartTime (node .Name )
501+ }
502+ devConfig .Status .NodeModuleStatus [node .Name ] = amdv1alpha1.ModuleStatus {Status : dcrh .upgradeMgrHandler .GetNodeStatus (node .Name ), UpgradeStartTime : upgradeStartTime }
490503
491504 nmc := kmmv1beta1.NodeModulesConfig {}
492505 err := dcrh .client .Get (ctx , types.NamespacedName {Name : node .Name }, & nmc )
@@ -507,6 +520,7 @@ func (dcrh *deviceConfigReconcilerHelper) updateDeviceConfigNodeStatus(ctx conte
507520 KernelVersion : module .Config .KernelVersion ,
508521 LastTransitionTime : module .LastTransitionTime .String (),
509522 Status : dcrh .upgradeMgrHandler .GetNodeStatus (node .Name ),
523+ UpgradeStartTime : upgradeStartTime ,
510524 }
511525 }
512526 }
0 commit comments