fix-nfs-storage-ipv6_add_square_brackets
This commit is contained in:
parent
e6b4fa3811
commit
5b52146614
@ -18,6 +18,7 @@ package nfs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"runtime"
|
||||
"time"
|
||||
@ -121,7 +122,10 @@ func (plugin *nfsPlugin) newMounterInternal(spec *volume.Spec, pod *v1.Pod, moun
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// wrap ipv6 into `[ ]`
|
||||
if net.ParseIP(source.Server).To16() != nil {
|
||||
source.Server = fmt.Sprintf("[%s]", source.Server)
|
||||
}
|
||||
return &nfsMounter{
|
||||
nfs: &nfs{
|
||||
volName: spec.Name(),
|
||||
|
@ -181,6 +181,14 @@ func TestPluginVolume(t *testing.T) {
|
||||
doTestPlugin(t, volume.NewSpecFromVolume(vol))
|
||||
}
|
||||
|
||||
func TestIPV6VolumeSource(t *testing.T) {
|
||||
vol := &v1.Volume{
|
||||
Name: "vol1",
|
||||
VolumeSource: v1.VolumeSource{NFS: &v1.NFSVolumeSource{Server: "0:0:0:0:0:0:0:1", Path: "/somepath", ReadOnly: false}},
|
||||
}
|
||||
doTestPlugin(t, volume.NewSpecFromVolume(vol))
|
||||
}
|
||||
|
||||
func TestPluginPersistentVolume(t *testing.T) {
|
||||
vol := &v1.PersistentVolume{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
|
Loading…
Reference in New Issue
Block a user