mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-02 09:47:06 +00:00
fix-nfs-storage-ipv6_add_square_brackets
This commit is contained in:
@@ -18,6 +18,7 @@ package nfs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
@@ -121,7 +122,10 @@ func (plugin *nfsPlugin) newMounterInternal(spec *volume.Spec, pod *v1.Pod, moun
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// wrap ipv6 into `[ ]`
|
||||||
|
if net.ParseIP(source.Server).To16() != nil {
|
||||||
|
source.Server = fmt.Sprintf("[%s]", source.Server)
|
||||||
|
}
|
||||||
return &nfsMounter{
|
return &nfsMounter{
|
||||||
nfs: &nfs{
|
nfs: &nfs{
|
||||||
volName: spec.Name(),
|
volName: spec.Name(),
|
||||||
|
@@ -181,6 +181,14 @@ func TestPluginVolume(t *testing.T) {
|
|||||||
doTestPlugin(t, volume.NewSpecFromVolume(vol))
|
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) {
|
func TestPluginPersistentVolume(t *testing.T) {
|
||||||
vol := &v1.PersistentVolume{
|
vol := &v1.PersistentVolume{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Reference in New Issue
Block a user