Skip to content

Commit 26162d2

Browse files
committed
Included node-name derived info in PV name
1 parent c5358b5 commit 26162d2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pkg/storage/pv_creator.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ package storage
2424

2525
import (
2626
"context"
27+
"crypto/sha1"
2728
"encoding/json"
2829
"fmt"
2930
"math/rand"
@@ -137,7 +138,7 @@ func (ls *LocalStorage) createPV(ctx context.Context, apiObject *api.ArangoLocal
137138
continue
138139
}
139140
// Create a volume
140-
pvName := apiObject.GetName() + "-" + name
141+
pvName := strings.ToLower(apiObject.GetName() + "-" + shortHash(info.NodeName) + "-" + name)
141142
volumeMode := v1.PersistentVolumeFilesystem
142143
nodeAff, err := createNodeAffinity(info.NodeName)
143144
if err != nil {
@@ -332,3 +333,9 @@ func (ls *LocalStorage) bindClaimToVolume(claim v1.PersistentVolumeClaim, volume
332333
log.Error().Msg("All attempts to bind PVC to volume failed")
333334
return maskAny(fmt.Errorf("All attempts to bind PVC to volume failed"))
334335
}
336+
337+
// shortHash creates a 6 letter hash of the given name.
338+
func shortHash(name string) string {
339+
h := sha1.Sum([]byte(name))
340+
return fmt.Sprintf("%0x", h)[:6]
341+
}

0 commit comments

Comments
 (0)