@@ -444,8 +444,9 @@ func cloneConnState(connState *schema.ConnState) *schema.ConnState {
444444 return & clone
445445}
446446
447- // snapshotChangedConnectionsForUndo records original states for connections
448- // changed by setup-profiles so undo can restore them, if needed.
447+ // snapshotChangedConnectionsForUndo records original states for persisted
448+ // connections that setup-profiles changed or dropped so undo can restore them,
449+ // if needed.
449450func snapshotChangedConnectionsForUndo (task * state.Task , instanceName string , changedConns map [string ]* schema.ConnState ) error {
450451 if len (changedConns ) == 0 {
451452 return nil
@@ -480,8 +481,8 @@ func snapshotChangedConnectionsForUndo(task *state.Task, instanceName string, ch
480481 return nil
481482}
482483
483- // restoreConnectionsForSetupProfiles restores connection states saved on a
484- // setup-profiles task.
484+ // restoreConnectionsForSetupProfiles restores connection states saved by
485+ // snapshotChangedConnectionsForUndo on a setup-profiles task.
485486func restoreConnectionsForSetupProfiles (task * state.Task ) error {
486487 var connectionSnapshot map [string ]* schema.ConnState
487488 err := task .Get ("changed-connection-snapshot" , & connectionSnapshot )
@@ -512,8 +513,12 @@ func restoreConnectionsForSetupProfiles(task *state.Task) error {
512513// affecting a given snap.
513514//
514515// The return value is the list of reloaded connection IDs, plus the original
515- // connection states whose persisted state was changed.
516- func (m * InterfaceManager ) reloadConnections (snapName string ) (reloadedConnectionIDs []string , changedConns map [string ]* schema.ConnState , err error ) {
516+ // connection states whose persisted state was changed or dropped.
517+ func (m * InterfaceManager ) reloadConnections (snapName string ) (
518+ reloadedConnectionIDs []string ,
519+ changedOrDroppedConns map [string ]* schema.ConnState ,
520+ err error ,
521+ ) {
517522 conns , err := getConns (m .state )
518523 if err != nil {
519524 return nil , nil , err
@@ -542,7 +547,7 @@ func (m *InterfaceManager) reloadConnections(snapName string) (reloadedConnectio
542547 }
543548
544549 connStateChanged := false
545- changedConns = make (map [string ]* schema.ConnState )
550+ changedOrDroppedConns = make (map [string ]* schema.ConnState )
546551
547552 var reloadedConnections []string
548553ConnsLoop:
@@ -587,7 +592,7 @@ ConnsLoop:
587592 continue ConnsLoop
588593 }
589594 }
590- changedConns [connId ] = cloneConnState (connState )
595+ changedOrDroppedConns [connId ] = cloneConnState (connState )
591596 delete (conns , connId )
592597 connStateChanged = true
593598 }
@@ -652,7 +657,7 @@ ConnsLoop:
652657 reloadedConnections = append (reloadedConnections , connId )
653658
654659 if updateStaticAttrs {
655- changedConns [connId ] = cloneConnState (connState )
660+ changedOrDroppedConns [connId ] = cloneConnState (connState )
656661 connState .StaticPlugAttrs = staticPlugAttrs
657662 connState .StaticSlotAttrs = staticSlotAttrs
658663 connStateChanged = true
@@ -663,7 +668,7 @@ ConnsLoop:
663668 setConns (m .state , conns )
664669 }
665670
666- return reloadedConnections , changedConns , nil
671+ return reloadedConnections , changedOrDroppedConns , nil
667672}
668673
669674// removeConnections disconnects all connections of the snap in the repo. It should only be used if the snap
0 commit comments