Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 61 additions & 47 deletions network/endpoint_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,55 +79,69 @@
return nil, errors.Wrap(err, "failed to get VF device state")
}

// state machine, use devicePresence and problemCode to determine actions
if devicePresence == "True" && problemCode == noError { //nolint
logger.Info("Device enabled and mounted")

if err := disableVFDevice(epInfo.PnPID, plc); err != nil { //nolint
return nil, errors.Wrap(err, "failed to disable VF device")
}

if err := dismountVFDevice(epInfo.PnPID, plc); err != nil { //nolint
return nil, errors.Wrap(err, "failed to dismount VF device")
}

// get new pnp id after VF dismount
pnpDeviceID, err := getPnPDeviceID(epInfo.PnPID, plc) //nolint
if err != nil {
return nil, errors.Wrap(err, "failed to get updated VF device ID")
}

// assign updated PciID back to containerd
epInfo.PnPID = pnpDeviceID
} else if devicePresence == "True" && problemCode == deviceDisabled {
logger.Info("Device disabled")
// device is disabled but not dismounted
if err := dismountVFDevice(epInfo.PnPID, plc); err != nil { //nolint
return nil, errors.Wrap(err, "failed to dismount VF device")
}

// get new pnp id after VF dismount
pnpDeviceID, err := getPnPDeviceID(epInfo.PnPID, plc) //nolint
if err != nil {
return nil, errors.Wrap(err, "failed to get updated VF device ID")
}

// assign updated PciID back to containerd
epInfo.PnPID = pnpDeviceID
} else if devicePresence == "False" {
logger.Info("Device dismounted")
// device is disabled and dismounted, just get the new PciID and assign back to containerd
pnpDeviceID, err := getPnPDeviceID(epInfo.PnPID, plc) //nolint
if err != nil {
return nil, errors.Wrap(err, "failed to get updated VF device ID")
}
// assign updated PciID back to containerd
epInfo.PnPID = pnpDeviceID
} else {
// return unexpected error and log devicePresence, problemCode
return nil, errors.Wrapf(err, "unexpected error with devicePresence %s and problemCode %s", devicePresence, problemCode)
// expect device to be disabled & dismounted by criproxy
if devicePresence == "True" || problemCode == noError {
logger.Info("Unexpected device state before disabling and dismounting VF device", zap.String("devicePresence", devicePresence), zap.String("problemCode", problemCode))
return nil, errors.Wrapf(err, "unexpected device state with devicePresence %s and problemCode %s", devicePresence, problemCode)
}

// device is disabled and dismounted, get the new PciID and assign back to containerd
pnpDeviceID, err := getPnPDeviceID(epInfo.PnPID, plc) //nolint
if err != nil {
return nil, errors.Wrap(err, "failed to get updated VF device ID")
}
// assign updated PciID back to containerd
epInfo.PnPID = pnpDeviceID

// // state machine, use devicePresence and problemCode to determine actions
// if devicePresence == "True" && problemCode == noError { //nolint
// logger.Info("Device enabled and mounted")

// if err := disableVFDevice(epInfo.PnPID, plc); err != nil { //nolint

Check failure on line 100 in network/endpoint_windows.go

View workflow job for this annotation

GitHub Actions / Lint (windows-latest)

commentedOutCode: may want to remove commented-out code (gocritic)
// return nil, errors.Wrap(err, "failed to disable VF device")
// }

// if err := dismountVFDevice(epInfo.PnPID, plc); err != nil { //nolint

Check failure on line 104 in network/endpoint_windows.go

View workflow job for this annotation

GitHub Actions / Lint (windows-latest)

commentedOutCode: may want to remove commented-out code (gocritic)
// return nil, errors.Wrap(err, "failed to dismount VF device")
// }

// // get new pnp id after VF dismount

Check failure on line 108 in network/endpoint_windows.go

View workflow job for this annotation

GitHub Actions / Lint (windows-latest)

commentedOutCode: may want to remove commented-out code (gocritic)
// pnpDeviceID, err := getPnPDeviceID(epInfo.PnPID, plc) //nolint
// if err != nil {
// return nil, errors.Wrap(err, "failed to get updated VF device ID")
// }

// // assign updated PciID back to containerd
// epInfo.PnPID = pnpDeviceID
// } else if devicePresence == "True" && problemCode == deviceDisabled {
// logger.Info("Device disabled")
// // device is disabled but not dismounted
// if err := dismountVFDevice(epInfo.PnPID, plc); err != nil { //nolint
// return nil, errors.Wrap(err, "failed to dismount VF device")
// }

// // get new pnp id after VF dismount

Check failure on line 123 in network/endpoint_windows.go

View workflow job for this annotation

GitHub Actions / Lint (windows-latest)

commentedOutCode: may want to remove commented-out code (gocritic)
// pnpDeviceID, err := getPnPDeviceID(epInfo.PnPID, plc) //nolint
// if err != nil {
// return nil, errors.Wrap(err, "failed to get updated VF device ID")
// }

// // assign updated PciID back to containerd
// epInfo.PnPID = pnpDeviceID
// } else if devicePresence == "False" {
// logger.Info("Device dismounted")
// // device is disabled and dismounted, just get the new PciID and assign back to containerd
// pnpDeviceID, err := getPnPDeviceID(epInfo.PnPID, plc) //nolint
// if err != nil {
// return nil, errors.Wrap(err, "failed to get updated VF device ID")
// }
// // assign updated PciID back to containerd
// epInfo.PnPID = pnpDeviceID
// } else {
// // return unexpected error and log devicePresence, problemCode
// return nil, errors.Wrapf(err, "unexpected error with devicePresence %s and problemCode %s", devicePresence, problemCode)
// }

// Create the endpoint object.
ep := &endpoint{
Id: epInfo.MasterIfName,
Expand Down
Loading