Attempt to create data path during Node creation
@@ -20,6 +20,8 @@ import (
"github.com/longhorn/longhorn-manager/util"
longhorn "github.com/longhorn/longhorn-manager/k8s/pkg/apis/longhorn/v1alpha1"
+
+ iscsi_util "github.com/longhorn/go-iscsi-helper/util"
)
const (
@@ -867,6 +869,16 @@ func (s *DataStore) CreateDefaultNode(name string) (*longhorn.Node, error) {
return nil, err
}
+ // Attempt to create the specified Default Data Path on the disk, in case it doesn't exist.
+ nsPath := iscsi_util.GetHostNamespacePath(util.HostProcPath)
+ nsExec, err := iscsi_util.NewNamespaceExecutor(nsPath)
+ if err != nil {
+ return nil, err
+ }
+ if _, err := nsExec.Execute("mkdir", []string{"-p", pathSetting.Value}); err != nil {
+ return nil, errors.Wrapf(err, "error creating data path %v on host", pathSetting.Value)
+ }
+
diskInfo, err := util.GetDiskInfo(pathSetting.Value)
if err != nil {
return nil, err
