Skip to content

Commit

Permalink
add pod name in metadata device spec for dmthin on ocp facd
Browse files Browse the repository at this point in the history
Signed-off-by: shsun_pure <[email protected]>
  • Loading branch information
shsun_pure committed Jul 1, 2024
1 parent 782af0b commit 7623e9c
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
14 changes: 13 additions & 1 deletion drivers/storage/portworx/preflight.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,19 @@ func (u *preFlightPortworx) processPassedChecks(recorder record.EventRecorder) {
if pxutil.IsVsphere(u.cluster) {
cmetaData = DefCmetaVsphere
} else if pxutil.IsPure(u.cluster) {
cmetaData = DefCmetaFACD
var podName string
specsItr:
for _, spec := range *u.cluster.Spec.CloudStorage.DeviceSpecs {
options := strings.Split(spec, ",")
for _, option := range options {
keyValPair := strings.Split(option, "=")
if len(keyValPair) == 2 && keyValPair[0] == "pod" {
podName = option
break specsItr
}
}
}
cmetaData = fmt.Sprintf("%s,%s", DefCmetaFACD, podName)
}
u.cluster.Spec.CloudStorage.SystemMdDeviceSpec = &cmetaData
}
Expand Down
50 changes: 50 additions & 0 deletions drivers/storage/portworx/preflight_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package portworx

import (
"fmt"
"testing"

corev1 "github.com/libopenstorage/operator/pkg/apis/core/v1"
"github.com/stretchr/testify/require"
v1 "k8s.io/api/core/v1"
"k8s.io/client-go/tools/record"
)

func TestDmthinFacdDefCmeta(t *testing.T) {
fakeRecorder := record.NewFakeRecorder(10)

u := &preFlightPortworx{
cluster: &corev1.StorageCluster{
Spec: corev1.StorageClusterSpec{
CommonConfig: corev1.CommonConfig{
Env: []v1.EnvVar{
{
Name: "PURE_FLASHARRAY_SAN_TYPE",
Value: "PURE_FLASHARRAY_SAN_TYPE",
},
},
},
CloudStorage: &corev1.CloudStorageSpec{
CloudStorageCommon: corev1.CloudStorageCommon{
DeviceSpecs: &[]string{"size=49,pod=testpod"},
},
},
},
},
hardFail: true,
}
storageNodes := []*corev1.StorageNode{
{
Status: corev1.NodeStatus{
Checks: []corev1.CheckResult{
{
Type: "status",
},
},
},
},
}
err := u.ProcessPreFlightResults(fakeRecorder, storageNodes)
require.Nil(t, err)
require.Equal(t, fmt.Sprintf("%s,%s", DefCmetaFACD, "pod=testpod"), *u.cluster.Spec.CloudStorage.SystemMdDeviceSpec)
}

0 comments on commit 7623e9c

Please sign in to comment.