@@ -79,55 +79,69 @@ func (nw *network) getEndpointWithVFDevice(plc platform.ExecClient, epInfo *Endp
7979 return nil , errors .Wrap (err , "failed to get VF device state" )
8080 }
8181
82- // state machine, use devicePresence and problemCode to determine actions
83- if devicePresence == "True" && problemCode == noError { //nolint
84- logger .Info ("Device enabled and mounted" )
85-
86- if err := disableVFDevice (epInfo .PnPID , plc ); err != nil { //nolint
87- return nil , errors .Wrap (err , "failed to disable VF device" )
88- }
89-
90- if err := dismountVFDevice (epInfo .PnPID , plc ); err != nil { //nolint
91- return nil , errors .Wrap (err , "failed to dismount VF device" )
92- }
93-
94- // get new pnp id after VF dismount
95- pnpDeviceID , err := getPnPDeviceID (epInfo .PnPID , plc ) //nolint
96- if err != nil {
97- return nil , errors .Wrap (err , "failed to get updated VF device ID" )
98- }
99-
100- // assign updated PciID back to containerd
101- epInfo .PnPID = pnpDeviceID
102- } else if devicePresence == "True" && problemCode == deviceDisabled {
103- logger .Info ("Device disabled" )
104- // device is disabled but not dismounted
105- if err := dismountVFDevice (epInfo .PnPID , plc ); err != nil { //nolint
106- return nil , errors .Wrap (err , "failed to dismount VF device" )
107- }
108-
109- // get new pnp id after VF dismount
110- pnpDeviceID , err := getPnPDeviceID (epInfo .PnPID , plc ) //nolint
111- if err != nil {
112- return nil , errors .Wrap (err , "failed to get updated VF device ID" )
113- }
114-
115- // assign updated PciID back to containerd
116- epInfo .PnPID = pnpDeviceID
117- } else if devicePresence == "False" {
118- logger .Info ("Device dismounted" )
119- // device is disabled and dismounted, just get the new PciID and assign back to containerd
120- pnpDeviceID , err := getPnPDeviceID (epInfo .PnPID , plc ) //nolint
121- if err != nil {
122- return nil , errors .Wrap (err , "failed to get updated VF device ID" )
123- }
124- // assign updated PciID back to containerd
125- epInfo .PnPID = pnpDeviceID
126- } else {
127- // return unexpected error and log devicePresence, problemCode
128- return nil , errors .Wrapf (err , "unexpected error with devicePresence %s and problemCode %s" , devicePresence , problemCode )
82+ // expect device to be disabled & dismounted by criproxy
83+ if devicePresence == "True" || problemCode == noError {
84+ logger .Info ("Unexpected device state before disabling and dismounting VF device" , zap .String ("devicePresence" , devicePresence ), zap .String ("problemCode" , problemCode ))
85+ return nil , errors .Wrapf (err , "unexpected device state with devicePresence %s and problemCode %s" , devicePresence , problemCode )
12986 }
13087
88+ // device is disabled and dismounted, get the new PciID and assign back to containerd
89+ pnpDeviceID , err := getPnPDeviceID (epInfo .PnPID , plc ) //nolint
90+ if err != nil {
91+ return nil , errors .Wrap (err , "failed to get updated VF device ID" )
92+ }
93+ // assign updated PciID back to containerd
94+ epInfo .PnPID = pnpDeviceID
95+
96+ // // state machine, use devicePresence and problemCode to determine actions
97+ // if devicePresence == "True" && problemCode == noError { //nolint
98+ // logger.Info("Device enabled and mounted")
99+
100+ // if err := disableVFDevice(epInfo.PnPID, plc); err != nil { //nolint
101+ // return nil, errors.Wrap(err, "failed to disable VF device")
102+ // }
103+
104+ // if err := dismountVFDevice(epInfo.PnPID, plc); err != nil { //nolint
105+ // return nil, errors.Wrap(err, "failed to dismount VF device")
106+ // }
107+
108+ // // get new pnp id after VF dismount
109+ // pnpDeviceID, err := getPnPDeviceID(epInfo.PnPID, plc) //nolint
110+ // if err != nil {
111+ // return nil, errors.Wrap(err, "failed to get updated VF device ID")
112+ // }
113+
114+ // // assign updated PciID back to containerd
115+ // epInfo.PnPID = pnpDeviceID
116+ // } else if devicePresence == "True" && problemCode == deviceDisabled {
117+ // logger.Info("Device disabled")
118+ // // device is disabled but not dismounted
119+ // if err := dismountVFDevice(epInfo.PnPID, plc); err != nil { //nolint
120+ // return nil, errors.Wrap(err, "failed to dismount VF device")
121+ // }
122+
123+ // // get new pnp id after VF dismount
124+ // pnpDeviceID, err := getPnPDeviceID(epInfo.PnPID, plc) //nolint
125+ // if err != nil {
126+ // return nil, errors.Wrap(err, "failed to get updated VF device ID")
127+ // }
128+
129+ // // assign updated PciID back to containerd
130+ // epInfo.PnPID = pnpDeviceID
131+ // } else if devicePresence == "False" {
132+ // logger.Info("Device dismounted")
133+ // // device is disabled and dismounted, just get the new PciID and assign back to containerd
134+ // pnpDeviceID, err := getPnPDeviceID(epInfo.PnPID, plc) //nolint
135+ // if err != nil {
136+ // return nil, errors.Wrap(err, "failed to get updated VF device ID")
137+ // }
138+ // // assign updated PciID back to containerd
139+ // epInfo.PnPID = pnpDeviceID
140+ // } else {
141+ // // return unexpected error and log devicePresence, problemCode
142+ // return nil, errors.Wrapf(err, "unexpected error with devicePresence %s and problemCode %s", devicePresence, problemCode)
143+ // }
144+
131145 // Create the endpoint object.
132146 ep := & endpoint {
133147 Id : epInfo .MasterIfName ,
0 commit comments