@@ -12,7 +12,6 @@ import (
1212 "path/filepath"
1313 "reflect"
1414 goruntime "runtime"
15- "slices"
1615 "strconv"
1716 "strings"
1817 "sync"
@@ -1014,20 +1013,13 @@ func (dn *Daemon) update(oldConfig, newConfig *mcfgv1.MachineConfig, skipCertifi
10141013 logSystem ("Starting update from %s to %s: %+v" , oldConfigName , newConfigName , diff )
10151014
10161015 diffFileSet := ctrlcommon .CalculateConfigFileDiffs (& oldIgnConfig , & newIgnConfig )
1017- // Get the added and updated units
1018- unitDiff := ctrlcommon .GetChangedConfigUnitsByType (& oldIgnConfig , & newIgnConfig )
1019- addedOrChangedUnits := slices .Concat (unitDiff .Added , unitDiff .Updated )
1020- // Get the names of all units changed in some way (added, removed, or updated)
1021- var allChangedUnitNames []string
1022- for _ , unit := range append (addedOrChangedUnits , unitDiff .Removed ... ) {
1023- allChangedUnitNames = append (allChangedUnitNames , unit .Name )
1024- }
1016+ diffUnitSet := ctrlcommon .CalculateConfigUnitDiffs (& oldIgnConfig , & newIgnConfig )
10251017
10261018 var nodeDisruptionActions []opv1.NodeDisruptionPolicyStatusAction
10271019 var actions []string
10281020 // Node Disruption Policies cannot be used during firstboot as API is not accessible.
10291021 if ! firstBoot {
1030- nodeDisruptionActions , err = dn .calculatePostConfigChangeNodeDisruptionAction (diff , diffFileSet , allChangedUnitNames )
1022+ nodeDisruptionActions , err = dn .calculatePostConfigChangeNodeDisruptionAction (diff , diffFileSet , diffUnitSet )
10311023 } else {
10321024 actions , err = calculatePostConfigChangeAction (diff , diffFileSet )
10331025 klog .Infof ("Skipping node disruption polciies as node is executing first boot." )
@@ -1133,13 +1125,13 @@ func (dn *Daemon) update(oldConfig, newConfig *mcfgv1.MachineConfig, skipCertifi
11331125 }
11341126
11351127 // update files on disk that need updating
1136- if err := dn .updateFiles (oldIgnConfig , newIgnConfig , addedOrChangedUnits , skipCertificateWrite ); err != nil {
1128+ if err := dn .updateFiles (oldIgnConfig , newIgnConfig , skipCertificateWrite ); err != nil {
11371129 return err
11381130 }
11391131
11401132 defer func () {
11411133 if retErr != nil {
1142- if err := dn .updateFiles (newIgnConfig , oldIgnConfig , addedOrChangedUnits , skipCertificateWrite ); err != nil {
1134+ if err := dn .updateFiles (newIgnConfig , oldIgnConfig , skipCertificateWrite ); err != nil {
11431135 errs := kubeErrs .NewAggregate ([]error {err , retErr })
11441136 retErr = fmt .Errorf ("error rolling back files writes: %w" , errs )
11451137 return
@@ -1274,18 +1266,15 @@ func (dn *Daemon) updateHypershift(oldConfig, newConfig *mcfgv1.MachineConfig, d
12741266 return fmt .Errorf ("parsing new Ignition config failed: %w" , err )
12751267 }
12761268
1277- unitDiff := ctrlcommon .GetChangedConfigUnitsByType (& oldIgnConfig , & newIgnConfig )
1278- addedOrChangedUnits := slices .Concat (unitDiff .Added , unitDiff .Updated )
1279-
12801269 // update files on disk that need updating
12811270 // We should't skip the certificate write in HyperShift since it does not run the extra daemon process
1282- if err := dn .updateFiles (oldIgnConfig , newIgnConfig , addedOrChangedUnits , false ); err != nil {
1271+ if err := dn .updateFiles (oldIgnConfig , newIgnConfig , false ); err != nil {
12831272 return err
12841273 }
12851274
12861275 defer func () {
12871276 if retErr != nil {
1288- if err := dn .updateFiles (newIgnConfig , oldIgnConfig , addedOrChangedUnits , false ); err != nil {
1277+ if err := dn .updateFiles (newIgnConfig , oldIgnConfig , false ); err != nil {
12891278 errs := kubeErrs .NewAggregate ([]error {err , retErr })
12901279 retErr = fmt .Errorf ("error rolling back files writes: %w" , errs )
12911280 return
@@ -1810,12 +1799,12 @@ func (dn *CoreOSDaemon) getKernelPackagesForTargetRelease() (releaseKernelPackag
18101799// whatever has been written is picked up by the appropriate daemons, if
18111800// required. in particular, a daemon-reload and restart for any unit files
18121801// touched.
1813- func (dn * Daemon ) updateFiles (oldIgnConfig , newIgnConfig ign3types.Config , addedOrChangedUnits []ign3types. Unit , skipCertificateWrite bool ) error {
1802+ func (dn * Daemon ) updateFiles (oldIgnConfig , newIgnConfig ign3types.Config , skipCertificateWrite bool ) error {
18141803 klog .Info ("Updating files" )
18151804 if err := dn .writeFiles (newIgnConfig .Storage .Files , skipCertificateWrite ); err != nil {
18161805 return err
18171806 }
1818- if err := dn .writeUnits (addedOrChangedUnits ); err != nil {
1807+ if err := dn .writeUnits (newIgnConfig . Systemd . Units ); err != nil {
18191808 return err
18201809 }
18211810 return dn .deleteStaleData (oldIgnConfig , newIgnConfig )
0 commit comments