@@ -2557,12 +2557,17 @@ func (dn *Daemon) updateLayeredOS(config *mcfgv1.MachineConfig) error {
25572557 return dn .InplaceUpdateViaNewContainer (newURL )
25582558 }
25592559
2560- isOsImagePresent := false
2560+ isPisConfigured , err := dn .isPinnedImageSetConfigured ()
2561+ if err != nil {
2562+ // Ignore the error and default to remote pull
2563+ klog .Errorf ("Failed to determine if pinned image set is configured: %v" , err )
2564+ }
25612565
2562- // not set during firstboot
2563- if dn .fgHandler != nil && dn .fgHandler .Enabled (features .FeatureGatePinnedImages ) {
2564- isOsImagePresent , err = isImagePresent (newURL )
2565- if err != nil {
2566+ // If PIS is configured check if the image is locally present. If so, rebase using
2567+ // the local image
2568+ isOsImagePresent := false
2569+ if isPisConfigured {
2570+ if isOsImagePresent , err = isImagePresent (newURL ); err != nil {
25662571 return err
25672572 }
25682573 }
@@ -2595,6 +2600,29 @@ func (dn *Daemon) updateLayeredOS(config *mcfgv1.MachineConfig) error {
25952600 return nil
25962601}
25972602
2603+ func (dn * Daemon ) isPinnedImageSetConfigured () (bool , error ) {
2604+ if dn .fgHandler == nil || ! dn .fgHandler .Enabled (features .FeatureGatePinnedImages ) || dn .node == nil || dn .mcpLister == nil {
2605+ // Two options:
2606+ // - PIS is not enabled
2607+ // - MCD first boot run: No connection to the cluster and node not populated -> Cannot check PIS config
2608+ return false , nil
2609+ }
2610+
2611+ // PIS is enabled. Check if it's configured in any of its pools
2612+ pools , _ , err := helpers .GetPoolsForNode (dn .mcpLister , dn .node )
2613+ if err != nil {
2614+ return false , fmt .Errorf ("failed to get pools for node %q: %w" , dn .node .Name , err )
2615+ }
2616+
2617+ for _ , pool := range pools {
2618+ if pool .Spec .PinnedImageSets != nil && len (pool .Spec .PinnedImageSets ) > 0 {
2619+ return true , nil
2620+ }
2621+ }
2622+ // No pools with PIS configured
2623+ return false , nil
2624+ }
2625+
25982626// Synchronously invoke a command, writing its stdout to our stdout,
25992627// and gathering stderr into a buffer which will be returned in err
26002628// in case of error.
0 commit comments