@@ -103,40 +103,24 @@ func (rp *netResourcePool) Probe() bool {
103103 }
104104 cachedPfLinkStatus [pfName ] = pfIsUp
105105 }
106- pfIsUpLog = fmt .Sprintf ("PF %s" , pfName )
107- if pfIsUp {
108- pfIsUpLog = fmt .Sprintf ("%s is UP, " , pfIsUpLog )
109- } else {
110- pfIsUpLog = fmt .Sprintf ("%s is DOWN, " , pfIsUpLog )
111- }
106+ pfIsUpLog = fmt .Sprintf ("PF %s is %s," , pfName , map [bool ]string {true : "Up" , false : "Down" }[pfIsUp ])
112107 }
113108
114109 deviceExists := true
115110 deviceExistsLog := ""
116111 if rp .config .CheckHealthOnDeviceExist {
117112 deviceExists = netDev .DeviceExists ()
118- deviceExistsLog = fmt .Sprintf ("Device %s" , netDev .GetPciAddr ())
119- if deviceExists {
120- deviceExistsLog = fmt .Sprintf ("%s is existing, " , deviceExistsLog )
121- } else {
122- deviceExistsLog = fmt .Sprintf ("%s is missing, " , deviceExistsLog )
123- }
113+ deviceExistsLog = fmt .Sprintf ("Device %s is %s," , netDev .GetPciAddr (),
114+ map [bool ]string {true : "existing" , false : "missing" }[deviceExists ])
124115 }
125116
126117 if pfIsUp && deviceExists && ! currentHealth {
127- glog .Infof ("%s%sdevice was unhealthy, marking device %s as healthy" , pfIsUpLog , deviceExistsLog , id )
118+ glog .Infof ("%s %s device was unhealthy, marking device %s as healthy" , pfIsUpLog , deviceExistsLog , id )
128119 device .SetHealth (true )
129120 changes = true
130- } else if ! pfIsUp && deviceExists && currentHealth {
131- glog .Infof ("%s%sdevice was healthy, marking device %s as unhealthy" , pfIsUpLog , deviceExistsLog , id )
132- device .SetHealth (false )
133- changes = true
134- } else if pfIsUp && ! deviceExists && currentHealth {
135- glog .Infof ("%s%sdevice was healthy, marking device %s as unhealthy" , pfIsUpLog , deviceExistsLog , id )
136- device .SetHealth (false )
137- changes = true
138- } else if ! pfIsUp && ! deviceExists && currentHealth {
139- glog .Infof ("%s%sdevice was healthy, marking device %s as unhealthy" , pfIsUpLog , deviceExistsLog , id )
121+ } else if (! pfIsUp || ! deviceExists ) && currentHealth {
122+ // If either the PF is down or the device is missing:
123+ glog .Infof ("%s %s device was healthy, marking device %s as unhealthy" , pfIsUpLog , deviceExistsLog , id )
140124 device .SetHealth (false )
141125 changes = true
142126 }
0 commit comments