Skip to content

Commit db4e408

Browse files
authored
Merge pull request #139 from NearNodeFlash/drive-event
Notify upper layers that a drive failed
2 parents 8108167 + 8eff392 commit db4e408

4 files changed

Lines changed: 71 additions & 11 deletions

File tree

pkg/manager-message-registry/registries/Nnf.1.0.0.go

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/manager-message-registry/registries/Nnf.1.0.0.json

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"Message": "The storage pool '%1' patched, SerialNumber '%2', Namespace '%3' replaced with SerialNumber '%4', Namespace '%5'",
5555
"Severity": "OK",
5656
"MessageSeverity": "OK",
57-
"NumberOfArgs": 1,
57+
"NumberOfArgs": 5,
5858
"ParamTypes": [
5959
"string",
6060
"string",
@@ -77,6 +77,30 @@
7777
"This argument shall contain the namespace id on the new storage device."
7878
],
7979
"Resolution": "None"
80+
},
81+
"NvmeStateChange": {
82+
"Description": "Indicates that an NVMe device has changed state",
83+
"LongDescription": "This message shall be used to indicate that an NVMe device has changed state",
84+
"Message": "The Nvme State changed slot '%1', model '%2', serial '%3'",
85+
"Severity": "Warning",
86+
"MessageSeverity": "Warning",
87+
"NumberOfArgs": 3,
88+
"ParamTypes": [
89+
"number",
90+
"string",
91+
"string"
92+
],
93+
"ArgDescriptions": [
94+
"The slot identifier.",
95+
"The model number.",
96+
"The serial number."
97+
],
98+
"ArgLongDescriptions": [
99+
"This argument shall contain the NVMe slot number.",
100+
"This argument shall contain the NVMe model number.",
101+
"This argument shall contain the NVMe serial number."
102+
],
103+
"Resolution": "None"
80104
}
81105
}
82106
}

pkg/manager-nvme/manager.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,20 @@ type ProvidingVolume struct {
172172
VolumeId string
173173
}
174174

175+
// Calculate a drive's health from its current state
176+
func resourceHealthFromState(state sf.ResourceState) sf.ResourceHealth {
177+
switch state {
178+
case sf.ENABLED_RST:
179+
return sf.OK_RH
180+
case sf.DISABLED_RST:
181+
return sf.WARNING_RH
182+
case sf.UNAVAILABLE_OFFLINE_RST, sf.ABSENT_RST:
183+
return sf.CRITICAL_RH
184+
default:
185+
return sf.CRITICAL_RH
186+
}
187+
}
188+
175189
// TODO: We may want to put this manager under a resource block
176190
// /​redfish/​v1/​ResourceBlocks/​{ResourceBlockId} // <- Rabbit
177191
// /​redfish/​v1/​ResourceBlocks/​{ResourceBlockId}/​Systems/{​ComputerSystemId} // <- Also Rabbit & Computes
@@ -510,7 +524,7 @@ func (s *Storage) getStatus() (stat sf.ResourceStatus) {
510524
stat.State = sf.UNAVAILABLE_OFFLINE_RST
511525
stat.Health = sf.CRITICAL_RH
512526
} else {
513-
stat.Health = sf.OK_RH
527+
stat.Health = resourceHealthFromState(s.state)
514528
stat.State = s.state
515529
}
516530

@@ -645,6 +659,14 @@ func (s *Storage) findVolume(volumeId string) *Volume {
645659
return nil
646660
}
647661

662+
func (s *Storage) notify(newState sf.ResourceState) {
663+
if newState != s.state {
664+
s.state = newState
665+
event.EventManager.Publish(msgreg.NvmeStateChangeNnf(strconv.FormatInt(s.slot, 10), s.modelNumber, s.serialNumber))
666+
}
667+
}
668+
669+
// Getters for common volume operations
648670
func (v *Volume) Id() string { return v.id }
649671
func (v *Volume) GetOdataId() string { return v.storage.OdataId() + "/Volumes/" + v.id }
650672
func (v *Volume) GetCapacityBytes() uint64 { return uint64(v.capacityBytes) }

pkg/manager-nvme/monitor.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,17 @@ func (m *Monitor) checkSmartLog(storage *Storage) {
9090
smartLog, err := storage.device.GetSmartLog()
9191
if err != nil {
9292
log.Error(err, "smartlog request failed", "serial", storage.SerialNumber(), "slot", storage.Slot())
93-
storage.state = sf.DISABLED_RST
94-
}
93+
storage.notify(sf.UNAVAILABLE_OFFLINE_RST)
94+
} else {
9595

96-
// nvme.MangleSmartLog(smartLog)
96+
// nvme.MangleSmartLog(smartLog)
9797

98-
state := nvme.InterpretSmartLog(smartLog)
99-
if state != storage.state {
100-
log.Info("smartlog state change", "old state", storage.state, "new state", state, "serial", storage.SerialNumber(), "slot", storage.Slot())
101-
storage.state = state
98+
state := nvme.InterpretSmartLog(smartLog)
99+
if state != storage.state {
100+
log.Info("smartlog state change", "old state", storage.state, "new state", state, "serial", storage.SerialNumber(), "slot", storage.Slot())
101+
storage.notify(state)
102102

103-
nvme.LogSmartLog(log, smartLog)
103+
nvme.LogSmartLog(log, smartLog)
104+
}
104105
}
105106
}

0 commit comments

Comments
 (0)