Skip to content

Commit e0f3b67

Browse files
authored
Merge release v0.1.8
Release v0.1.8
2 parents 55114a4 + cf82fae commit e0f3b67

7 files changed

Lines changed: 79 additions & 48 deletions

File tree

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

Lines changed: 11 additions & 2 deletions
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: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,30 @@
5151
"StoragePoolPatched": {
5252
"Description": "Indicates that a storage pool has been patched",
5353
"LongDescription": "This message shall be used to indicate that an existing storage pool has been patched",
54-
"Message": "The storage pool '%1' has been patched",
54+
"Message": "The storage pool '%1' patched, SerialNumber '%2', Namespace '%3' replaced with SerialNumber '%4', Namespace '%5'",
5555
"Severity": "OK",
5656
"MessageSeverity": "OK",
5757
"NumberOfArgs": 1,
5858
"ParamTypes": [
59-
"string"
59+
"string",
60+
"string",
61+
"number",
62+
"string",
63+
"number"
6064
],
6165
"ArgDescriptions": [
62-
"The storage pool identifier."
66+
"The storage pool identifier.",
67+
"The durable name of the storage device that was replaced.",
68+
"The namespace id on the storage device that was replaced.",
69+
"The durable name of the new storage device.",
70+
"The namespace id on the new storage device."
6371
],
6472
"ArgLongDescriptions": [
65-
"This argument shall contain the storage pool resource identifier."
73+
"This argument shall contain the storage pool resource identifier.",
74+
"This argument shall contain the durable name of the storage device that was replaced.",
75+
"This argument shall contain the namespace id on the storage device that was replaced.",
76+
"This argument shall contain the durable name of the new storage device.",
77+
"This argument shall contain the namespace id on the new storage device."
6678
],
6779
"Resolution": "None"
6880
}

pkg/manager-nnf/manager.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,6 @@ func (s *StorageService) patchStoragePool(sp *StoragePool, forceRescan bool) err
220220
return ec.NewErrInternalServerError().WithResourceType(StoragePoolOdataType).WithError(err).WithCause("Failed to update storage pool")
221221
}
222222

223-
event.EventManager.PublishResourceEvent(msgreg.StoragePoolPatchedNnf(sp.id), sp)
224-
225223
return err
226224
}
227225

@@ -630,15 +628,19 @@ func (s *StorageService) EventHandler(e event.Event) error {
630628
}
631629

632630
// Check for storage pool events
633-
if e.Is(msgreg.StoragePoolPatchedNnf("")) {
631+
if e.Is(msgreg.StoragePoolPatchedNnf("", "", "", "", "")) {
634632
// After a storage pool is patched, check for new volumes that need to be attached
635633
log.V(1).Info("Storage Pool Patched")
636634
var storagePoolID string
637-
if err := e.Args(&storagePoolID); err != nil {
635+
var oldStorageSN string
636+
var oldNamespaceID string
637+
var newStorageSN string
638+
var newNamespaceID string
639+
if err := e.Args(&storagePoolID, &oldStorageSN, &oldNamespaceID, &newStorageSN, &newNamespaceID); err != nil {
638640
return ec.NewErrInternalServerError().WithError(err).WithCause("event parameters illformed")
639641
}
640642

641-
log = log.WithValues("poolId", storagePoolID)
643+
log = log.WithValues("poolId", storagePoolID, "oldStorageSN", oldStorageSN, "oldNamespaceId", oldNamespaceID, "newStorageSN", newStorageSN, "newNamespaceId", newNamespaceID)
642644

643645
// We may have multiple storage groups associated with the same storage pool
644646
for _, sg := range s.groups {

pkg/manager-nnf/storage_pool.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import (
2626
"github.com/google/uuid"
2727

2828
nvme2 "github.com/NearNodeFlash/nnf-ec/internal/switchtec/pkg/nvme"
29+
event "github.com/NearNodeFlash/nnf-ec/pkg/manager-event"
30+
msgreg "github.com/NearNodeFlash/nnf-ec/pkg/manager-message-registry/registries"
2931
nvme "github.com/NearNodeFlash/nnf-ec/pkg/manager-nvme"
3032
"github.com/NearNodeFlash/nnf-ec/pkg/persistent"
3133
sf "github.com/NearNodeFlash/nnf-ec/pkg/rfsf/pkg/models"
@@ -208,20 +210,21 @@ func (p *StoragePool) replaceMissingVolumes() error {
208210
return nil
209211
}
210212

211-
// Attempt to locate a storage device that is not providing a volume
212-
// and use it to replace the missing volume
213+
// Attempt to locate a storage device that is not providing a volume in this pool,
214+
// and create a new volume on it to replace the missing volume.
213215
// This is a best effort attempt to replace the missing volume
214-
// and may not be successful if there are no available storage devices
215-
// or if the storage device is not able to provide a volume
216+
// and may not be successful if there are no available storage devices,
217+
// or if the storage device is not able to provide a volume.
216218
// This is not a failure condition, but rather a best effort attempt
217-
// to replace the missing volume
219+
// to replace the missing volume.
218220
// The caller should check the missing volumes list to determine
219221
// if there are any missing volumes that were not replaced
220222
unusedStorages := p.locateUnusedStorage()
221223
if len(unusedStorages) == 0 {
222224
return fmt.Errorf("Unable to find unused storage")
223225
}
224226

227+
// It's all or nothing, we need to replace all the missing volumes or none.
225228
if len(unusedStorages) < len(p.missingVolumes) {
226229
log.V(2).Info("not enough unused storage", "unusedStorageCount", len(unusedStorages), "missingVolumeCount", len(p.missingVolumes))
227230
return fmt.Errorf("Not enough unused storage to replace missing volumes")
@@ -236,22 +239,29 @@ func (p *StoragePool) replaceMissingVolumes() error {
236239
for idx, missingVolume := range p.missingVolumes {
237240
log := log.WithValues("missingVolume", missingVolume)
238241

239-
log.V(2).Info("replace missing volume", "missingVolume", missingVolume)
242+
log.Info("replace missing volume")
240243
storage := unusedStorages[idx]
241244

242245
volume, err := nvme.CreateVolume(storage, p.volumeCapacity)
243246
if err != nil {
244247
log.Error(err, "Failed to create replacement volume")
245248
return fmt.Errorf("Failed to create volume: %v", err)
246249
}
247-
log.V(2).Info("created replacement volume", "volume", volume.Id())
248250
pv := nvme.ProvidingVolume{
249251
Storage: storage,
250252
VolumeId: volume.Id(),
251253
}
254+
log.Info("created replacement volume", "storage", storage.SerialNumber(), "volume", pv.VolumeId)
252255

253256
p.providingVolumes = append(p.providingVolumes, pv)
254257

258+
event.EventManager.PublishResourceEvent(msgreg.StoragePoolPatchedNnf(
259+
p.id,
260+
missingVolume.SerialNumber,
261+
volume.Id(),
262+
pv.Storage.SerialNumber(),
263+
pv.VolumeId), p)
264+
255265
// TODO: Find the serialnumber/volumeid in any other storage pools and
256266
// invalidate that volumeid to prevent reuse. Should probably store
257267
// that new value some how too.

pkg/manager-nvme/manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ func (v *Volume) AttachControllerIfUnattached(controllerIndex uint16) error {
832832
controllerAttached := slices.Contains(attachedControllers, controllerID)
833833

834834
if !controllerAttached {
835-
log.Info("reattaching controller to volume")
835+
log.Info("attaching controller to volume")
836836

837837
if err := v.AttachController(controllerIndex); err != nil {
838838
log.Error(err, "failed to reattach controller to volume")

tools/lvm.sh

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,21 @@ DRIVES=()
4141
drives() {
4242
local NAMESPACE=$1
4343
DRIVES=()
44-
for DRIVE in /dev/nvme*n"$NAMESPACE";
45-
do
46-
# shellcheck disable=SC2086
47-
if [ "$(nvme id-ctrl ${DRIVE} | grep -e KIOXIA -e 'SAMSUNG MZ3LO1T9HCJR')" != "" ];
48-
then
49-
echo " Found drive ${DRIVE}"
50-
NAMESPACEID=$(nvme id-ns ${DRIVE} | grep -E '^NVME Identify Namespace [[:digit:]]+' | awk '{print $4}')
51-
if [ "${NAMESPACEID::-1}" == "$NAMESPACE" ];
52-
then
53-
echo " Found Namespace ${NAMESPACE}"
54-
DRIVES+=("${DRIVE}")
55-
fi
44+
echo "Finding drives for namespace ${NAMESPACE}"
45+
for drive in /dev/disk/by-path/*; do
46+
if [[ $drive =~ pci-0000:(05|06|07|08|09|0a|0b|0d|83|84|85|86|88|89|8a|8b):00\.0-nvme-"$NAMESPACE"$ ]]; then
47+
DRIVES+=("$drive")
5648
fi
5749
done
58-
59-
echo "${#DRIVES[@]}" DRIVES: "${DRIVES[@]}"
50+
if (( "${#DRIVES[@]}" == 0 )); then
51+
echo " No drives found for namespace ${NAMESPACE}"
52+
return
53+
fi
54+
echo " Found drives for namespace ${NAMESPACE}:"
55+
for drive in "${DRIVES[@]}"; do
56+
echo " $drive"
57+
done
58+
echo " Found ${#DRIVES[@]} drives with namespace ${NAMESPACE}"
6059
}
6160

6261
join() {

tools/zpool.sh

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,21 @@ DRIVES=()
4343
drives() {
4444
local NAMESPACE=$1
4545
DRIVES=()
46-
for DRIVE in /dev/nvme*n"$NAMESPACE";
47-
do
48-
# shellcheck disable=SC2086
49-
if [ "$(nvme id-ctrl ${DRIVE} | grep -e KIOXIA -e 'SAMSUNG MZ3LO1T9HCJR')" != "" ];
50-
then
51-
echo " Found drive ${DRIVE}"
52-
NAMESPACEID=$(nvme id-ns ${DRIVE} | grep -E '^NVME Identify Namespace [[:digit:]]+' | awk '{print $4}')
53-
if [ "${NAMESPACEID::-1}" == "$NAMESPACE" ];
54-
then
55-
echo " Found Namespace ${NAMESPACE}"
56-
DRIVES+=("${DRIVE}")
57-
fi
46+
echo "Finding drives for namespace ${NAMESPACE}"
47+
for drive in /dev/disk/by-path/*; do
48+
if [[ $drive =~ pci-0000:(05|06|07|08|09|0a|0b|0d|83|84|85|86|88|89|8a|8b):00\.0-nvme-"$NAMESPACE"$ ]]; then
49+
DRIVES+=("$drive")
5850
fi
5951
done
60-
61-
echo "${#DRIVES[@]}" DRIVES: "${DRIVES[@]}"
52+
if (( "${#DRIVES[@]}" == 0 )); then
53+
echo " No drives found for namespace ${NAMESPACE}"
54+
return
55+
fi
56+
echo " Found drives for namespace ${NAMESPACE}:"
57+
for drive in "${DRIVES[@]}"; do
58+
echo " $drive"
59+
done
60+
echo " Found ${#DRIVES[@]} drives with namespace ${NAMESPACE}"
6261
}
6362

6463
join() {
@@ -70,7 +69,7 @@ join() {
7069

7170
NAME=${2:-"rabbit"}
7271
NAMESPACE=${3:-"1"}
73-
RAID_LEVEL=${4:-"striped"}
72+
RAID_LEVEL=${4:-"raidz2"}
7473

7574
case $1 in
7675
list-drives)

0 commit comments

Comments
 (0)