mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Merge pull request #113255 from claudiubelu/path-filepath-update-kubelet
Replaces path.Operation with filepath.Operation (kubelet)
This commit is contained in:
commit
a668924cb6
@ -18,7 +18,7 @@ package state
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
@ -56,7 +56,7 @@ func NewCheckpointState(stateDir, checkpointName, policyName string, initialCont
|
|||||||
if err := stateCheckpoint.restoreState(); err != nil {
|
if err := stateCheckpoint.restoreState(); err != nil {
|
||||||
//nolint:staticcheck // ST1005 user-facing error message
|
//nolint:staticcheck // ST1005 user-facing error message
|
||||||
return nil, fmt.Errorf("could not restore state from checkpoint: %v, please drain this node and delete the CPU manager checkpoint file %q before restarting Kubelet",
|
return nil, fmt.Errorf("could not restore state from checkpoint: %v, please drain this node and delete the CPU manager checkpoint file %q before restarting Kubelet",
|
||||||
err, path.Join(stateDir, checkpointName))
|
err, filepath.Join(stateDir, checkpointName))
|
||||||
}
|
}
|
||||||
|
|
||||||
return stateCheckpoint, nil
|
return stateCheckpoint, nil
|
||||||
|
@ -19,7 +19,7 @@ package devicemanager
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -72,7 +72,7 @@ func esocketName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNewEndpoint(t *testing.T) {
|
func TestNewEndpoint(t *testing.T) {
|
||||||
socket := path.Join(os.TempDir(), esocketName())
|
socket := filepath.Join(os.TempDir(), esocketName())
|
||||||
|
|
||||||
devs := []*pluginapi.Device{
|
devs := []*pluginapi.Device{
|
||||||
{ID: "ADeviceId", Health: pluginapi.Healthy},
|
{ID: "ADeviceId", Health: pluginapi.Healthy},
|
||||||
@ -83,7 +83,7 @@ func TestNewEndpoint(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRun(t *testing.T) {
|
func TestRun(t *testing.T) {
|
||||||
socket := path.Join(os.TempDir(), esocketName())
|
socket := filepath.Join(os.TempDir(), esocketName())
|
||||||
|
|
||||||
devs := []*pluginapi.Device{
|
devs := []*pluginapi.Device{
|
||||||
{ID: "ADeviceId", Health: pluginapi.Healthy},
|
{ID: "ADeviceId", Health: pluginapi.Healthy},
|
||||||
@ -148,7 +148,7 @@ func TestRun(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAllocate(t *testing.T) {
|
func TestAllocate(t *testing.T) {
|
||||||
socket := path.Join(os.TempDir(), esocketName())
|
socket := filepath.Join(os.TempDir(), esocketName())
|
||||||
devs := []*pluginapi.Device{
|
devs := []*pluginapi.Device{
|
||||||
{ID: "ADeviceId", Health: pluginapi.Healthy},
|
{ID: "ADeviceId", Health: pluginapi.Healthy},
|
||||||
}
|
}
|
||||||
@ -201,7 +201,7 @@ func TestAllocate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetPreferredAllocation(t *testing.T) {
|
func TestGetPreferredAllocation(t *testing.T) {
|
||||||
socket := path.Join(os.TempDir(), esocketName())
|
socket := filepath.Join(os.TempDir(), esocketName())
|
||||||
callbackCount := 0
|
callbackCount := 0
|
||||||
callbackChan := make(chan int)
|
callbackChan := make(chan int)
|
||||||
p, e := esetup(t, []*pluginapi.Device{}, socket, "mock", func(n string, d []pluginapi.Device) {
|
p, e := esetup(t, []*pluginapi.Device{}, socket, "mock", func(n string, d []pluginapi.Device) {
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ func (m *Stub) Register(kubeletEndpoint, resourceName string, pluginSockDir stri
|
|||||||
client := pluginapi.NewRegistrationClient(conn)
|
client := pluginapi.NewRegistrationClient(conn)
|
||||||
reqt := &pluginapi.RegisterRequest{
|
reqt := &pluginapi.RegisterRequest{
|
||||||
Version: pluginapi.Version,
|
Version: pluginapi.Version,
|
||||||
Endpoint: path.Base(m.socket),
|
Endpoint: filepath.Base(m.socket),
|
||||||
ResourceName: resourceName,
|
ResourceName: resourceName,
|
||||||
Options: &pluginapi.DevicePluginOptions{
|
Options: &pluginapi.DevicePluginOptions{
|
||||||
PreStartRequired: m.preStartContainerFlag,
|
PreStartRequired: m.preStartContainerFlag,
|
||||||
|
@ -18,7 +18,7 @@ package state
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
@ -52,7 +52,7 @@ func NewCheckpointState(stateDir, checkpointName, policyName string) (State, err
|
|||||||
if err := stateCheckpoint.restoreState(); err != nil {
|
if err := stateCheckpoint.restoreState(); err != nil {
|
||||||
//nolint:staticcheck // ST1005 user-facing error message
|
//nolint:staticcheck // ST1005 user-facing error message
|
||||||
return nil, fmt.Errorf("could not restore state from checkpoint: %v, please drain this node and delete the memory manager checkpoint file %q before restarting Kubelet",
|
return nil, fmt.Errorf("could not restore state from checkpoint: %v, please drain this node and delete the memory manager checkpoint file %q before restarting Kubelet",
|
||||||
err, path.Join(stateDir, checkpointName))
|
err, filepath.Join(stateDir, checkpointName))
|
||||||
}
|
}
|
||||||
|
|
||||||
return stateCheckpoint, nil
|
return stateCheckpoint, nil
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
sysruntime "runtime"
|
sysruntime "runtime"
|
||||||
"sort"
|
"sort"
|
||||||
@ -1309,7 +1308,7 @@ func (kl *Kubelet) RlimitStats() (*statsapi.RlimitStats, error) {
|
|||||||
// 4. the pod-resources directory
|
// 4. the pod-resources directory
|
||||||
// 5. the checkpoint directory
|
// 5. the checkpoint directory
|
||||||
func (kl *Kubelet) setupDataDirs() error {
|
func (kl *Kubelet) setupDataDirs() error {
|
||||||
kl.rootDirectory = path.Clean(kl.rootDirectory)
|
kl.rootDirectory = filepath.Clean(kl.rootDirectory)
|
||||||
pluginRegistrationDir := kl.getPluginsRegistrationDir()
|
pluginRegistrationDir := kl.getPluginsRegistrationDir()
|
||||||
pluginsDir := kl.getPluginsDir()
|
pluginsDir := kl.getPluginsDir()
|
||||||
if err := os.MkdirAll(kl.getRootDir(), 0750); err != nil {
|
if err := os.MkdirAll(kl.getRootDir(), 0750); err != nil {
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
@ -123,7 +122,7 @@ func (kl *Kubelet) makeBlockVolumes(pod *v1.Pod, container *v1.Container, podVol
|
|||||||
}
|
}
|
||||||
// Get a symbolic link associated to a block device under pod device path
|
// Get a symbolic link associated to a block device under pod device path
|
||||||
dirPath, volName := vol.BlockVolumeMapper.GetPodDeviceMapPath()
|
dirPath, volName := vol.BlockVolumeMapper.GetPodDeviceMapPath()
|
||||||
symlinkPath := path.Join(dirPath, volName)
|
symlinkPath := filepath.Join(dirPath, volName)
|
||||||
if islinkExist, checkErr := blkutil.IsSymlinkExist(symlinkPath); checkErr != nil {
|
if islinkExist, checkErr := blkutil.IsSymlinkExist(symlinkPath); checkErr != nil {
|
||||||
return nil, checkErr
|
return nil, checkErr
|
||||||
} else if islinkExist {
|
} else if islinkExist {
|
||||||
@ -303,7 +302,7 @@ func translateMountPropagation(mountMode *v1.MountPropagationMode) (runtimeapi.M
|
|||||||
|
|
||||||
// getEtcHostsPath returns the full host-side path to a pod's generated /etc/hosts file
|
// getEtcHostsPath returns the full host-side path to a pod's generated /etc/hosts file
|
||||||
func getEtcHostsPath(podDir string) string {
|
func getEtcHostsPath(podDir string) string {
|
||||||
hostsFilePath := path.Join(podDir, "etc-hosts")
|
hostsFilePath := filepath.Join(podDir, "etc-hosts")
|
||||||
// Volume Mounts fail on Windows if it is not of the form C:/
|
// Volume Mounts fail on Windows if it is not of the form C:/
|
||||||
return volumeutil.MakeAbsolutePath(runtime.GOOS, hostsFilePath)
|
return volumeutil.MakeAbsolutePath(runtime.GOOS, hostsFilePath)
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ package kuberuntime
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||||
@ -71,5 +71,5 @@ func logSymlink(containerLogsDir, podFullName, containerName, containerID string
|
|||||||
if len(logPath) > ext4MaxFileNameLen-len(suffix) {
|
if len(logPath) > ext4MaxFileNameLen-len(suffix) {
|
||||||
logPath = logPath[:ext4MaxFileNameLen-len(suffix)]
|
logPath = logPath[:ext4MaxFileNameLen-len(suffix)]
|
||||||
}
|
}
|
||||||
return path.Join(containerLogsDir, logPath+suffix)
|
return filepath.Join(containerLogsDir, logPath+suffix)
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ package kuberuntime
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"path"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -42,7 +42,7 @@ func TestLogSymLink(t *testing.T) {
|
|||||||
containerName := randStringBytes(70)
|
containerName := randStringBytes(70)
|
||||||
dockerID := randStringBytes(80)
|
dockerID := randStringBytes(80)
|
||||||
// The file name cannot exceed 255 characters. Since .log suffix is required, the prefix cannot exceed 251 characters.
|
// The file name cannot exceed 255 characters. Since .log suffix is required, the prefix cannot exceed 251 characters.
|
||||||
expectedPath := path.Join(containerLogsDir, fmt.Sprintf("%s_%s-%s", podFullName, containerName, dockerID)[:251]+".log")
|
expectedPath := filepath.Join(containerLogsDir, fmt.Sprintf("%s_%s-%s", podFullName, containerName, dockerID)[:251]+".log")
|
||||||
as.Equal(expectedPath, logSymlink(containerLogsDir, podFullName, containerName, dockerID))
|
as.Equal(expectedPath, logSymlink(containerLogsDir, podFullName, containerName, dockerID))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +53,6 @@ func TestLegacyLogSymLink(t *testing.T) {
|
|||||||
podName := randStringBytes(128)
|
podName := randStringBytes(128)
|
||||||
podNamespace := randStringBytes(10)
|
podNamespace := randStringBytes(10)
|
||||||
// The file name cannot exceed 255 characters. Since .log suffix is required, the prefix cannot exceed 251 characters.
|
// The file name cannot exceed 255 characters. Since .log suffix is required, the prefix cannot exceed 251 characters.
|
||||||
expectedPath := path.Join(legacyContainerLogsDir, fmt.Sprintf("%s_%s_%s-%s", podName, podNamespace, containerName, containerID)[:251]+".log")
|
expectedPath := filepath.Join(legacyContainerLogsDir, fmt.Sprintf("%s_%s_%s-%s", podName, podNamespace, containerName, containerID)[:251]+".log")
|
||||||
as.Equal(expectedPath, legacyLogSymlink(containerID, containerName, podName, podNamespace))
|
as.Equal(expectedPath, legacyLogSymlink(containerID, containerName, podName, podNamespace))
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ package stats
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ func filterTerminatedContainerInfoAndAssembleByPodCgroupKey(containerInfo map[st
|
|||||||
podCgroupKey = internalCgroupName[len(internalCgroupName)-1]
|
podCgroupKey = internalCgroupName[len(internalCgroupName)-1]
|
||||||
} else {
|
} else {
|
||||||
// Take last component only.
|
// Take last component only.
|
||||||
podCgroupKey = path.Base(key)
|
podCgroupKey = filepath.Base(key)
|
||||||
}
|
}
|
||||||
cinfosByPodCgroupKey[podCgroupKey] = cinfo
|
cinfosByPodCgroupKey[podCgroupKey] = cinfo
|
||||||
if !isPodManagedContainer(&cinfo) {
|
if !isPodManagedContainer(&cinfo) {
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -899,7 +899,7 @@ func getCRICadvisorStats(infos map[string]cadvisorapiv2.ContainerInfo) (map[stri
|
|||||||
|
|
||||||
func extractIDFromCgroupPath(cgroupPath string) string {
|
func extractIDFromCgroupPath(cgroupPath string) string {
|
||||||
// case0 == cgroupfs: "/kubepods/burstable/pod2fc932ce-fdcc-454b-97bd-aadfdeb4c340/9be25294016e2dc0340dd605ce1f57b492039b267a6a618a7ad2a7a58a740f32"
|
// case0 == cgroupfs: "/kubepods/burstable/pod2fc932ce-fdcc-454b-97bd-aadfdeb4c340/9be25294016e2dc0340dd605ce1f57b492039b267a6a618a7ad2a7a58a740f32"
|
||||||
id := path.Base(cgroupPath)
|
id := filepath.Base(cgroupPath)
|
||||||
|
|
||||||
// case1 == systemd: "/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod2fc932ce_fdcc_454b_97bd_aadfdeb4c340.slice/cri-containerd-aaefb9d8feed2d453b543f6d928cede7a4dbefa6a0ae7c9b990dd234c56e93b9.scope"
|
// case1 == systemd: "/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod2fc932ce_fdcc_454b_97bd_aadfdeb4c340.slice/cri-containerd-aaefb9d8feed2d453b543f6d928cede7a4dbefa6a0ae7c9b990dd234c56e93b9.scope"
|
||||||
// trim anything before the final '-' and suffix .scope
|
// trim anything before the final '-' and suffix .scope
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -2306,8 +2305,8 @@ func TestSyncStates(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "when two pods are using same volume and both are deleted",
|
name: "when two pods are using same volume and both are deleted",
|
||||||
volumePaths: []string{
|
volumePaths: []string{
|
||||||
path.Join("pod1", "volumes", "fake-plugin", "pvc-abcdef"),
|
filepath.Join("pod1", "volumes", "fake-plugin", "pvc-abcdef"),
|
||||||
path.Join("pod2", "volumes", "fake-plugin", "pvc-abcdef"),
|
filepath.Join("pod2", "volumes", "fake-plugin", "pvc-abcdef"),
|
||||||
},
|
},
|
||||||
createMountPoint: true,
|
createMountPoint: true,
|
||||||
podInfos: []podInfo{},
|
podInfos: []podInfo{},
|
||||||
@ -2322,8 +2321,8 @@ func TestSyncStates(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "when two pods are using same volume and one of them is deleted",
|
name: "when two pods are using same volume and one of them is deleted",
|
||||||
volumePaths: []string{
|
volumePaths: []string{
|
||||||
path.Join("pod1uid", "volumes", "fake-plugin", "volume-name"),
|
filepath.Join("pod1uid", "volumes", "fake-plugin", "volume-name"),
|
||||||
path.Join("pod2uid", "volumes", "fake-plugin", "volume-name"),
|
filepath.Join("pod2uid", "volumes", "fake-plugin", "volume-name"),
|
||||||
},
|
},
|
||||||
createMountPoint: true,
|
createMountPoint: true,
|
||||||
podInfos: []podInfo{defaultPodInfo},
|
podInfos: []podInfo{defaultPodInfo},
|
||||||
@ -2342,7 +2341,7 @@ func TestSyncStates(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "when reconstruction fails for a volume, volumes should be cleaned up",
|
name: "when reconstruction fails for a volume, volumes should be cleaned up",
|
||||||
volumePaths: []string{
|
volumePaths: []string{
|
||||||
path.Join("pod1", "volumes", "fake-plugin", "pvc-abcdef"),
|
filepath.Join("pod1", "volumes", "fake-plugin", "pvc-abcdef"),
|
||||||
},
|
},
|
||||||
createMountPoint: false,
|
createMountPoint: false,
|
||||||
podInfos: []podInfo{},
|
podInfos: []podInfo{},
|
||||||
@ -2359,7 +2358,7 @@ func TestSyncStates(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "when volume exists in dsow, volume should be recorded in skipped during reconstruction",
|
name: "when volume exists in dsow, volume should be recorded in skipped during reconstruction",
|
||||||
volumePaths: []string{
|
volumePaths: []string{
|
||||||
path.Join("pod1uid", "volumes", "fake-plugin", "volume-name"),
|
filepath.Join("pod1uid", "volumes", "fake-plugin", "volume-name"),
|
||||||
},
|
},
|
||||||
createMountPoint: true,
|
createMountPoint: true,
|
||||||
podInfos: []podInfo{defaultPodInfo},
|
podInfos: []podInfo{defaultPodInfo},
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -133,16 +132,16 @@ func getVolumesFromPodDir(podDir string) ([]podVolume, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
podName := podsDirInfo[i].Name()
|
podName := podsDirInfo[i].Name()
|
||||||
podDir := path.Join(podDir, podName)
|
podDir := filepath.Join(podDir, podName)
|
||||||
|
|
||||||
// Find filesystem volume information
|
// Find filesystem volume information
|
||||||
// ex. filesystem volume: /pods/{podUid}/volume/{escapeQualifiedPluginName}/{volumeName}
|
// ex. filesystem volume: /pods/{podUid}/volume/{escapeQualifiedPluginName}/{volumeName}
|
||||||
volumesDirs := map[v1.PersistentVolumeMode]string{
|
volumesDirs := map[v1.PersistentVolumeMode]string{
|
||||||
v1.PersistentVolumeFilesystem: path.Join(podDir, config.DefaultKubeletVolumesDirName),
|
v1.PersistentVolumeFilesystem: filepath.Join(podDir, config.DefaultKubeletVolumesDirName),
|
||||||
}
|
}
|
||||||
// Find block volume information
|
// Find block volume information
|
||||||
// ex. block volume: /pods/{podUid}/volumeDevices/{escapeQualifiedPluginName}/{volumeName}
|
// ex. block volume: /pods/{podUid}/volumeDevices/{escapeQualifiedPluginName}/{volumeName}
|
||||||
volumesDirs[v1.PersistentVolumeBlock] = path.Join(podDir, config.DefaultKubeletVolumeDevicesDirName)
|
volumesDirs[v1.PersistentVolumeBlock] = filepath.Join(podDir, config.DefaultKubeletVolumeDevicesDirName)
|
||||||
|
|
||||||
for volumeMode, volumesDir := range volumesDirs {
|
for volumeMode, volumesDir := range volumesDirs {
|
||||||
var volumesDirInfo []fs.DirEntry
|
var volumesDirInfo []fs.DirEntry
|
||||||
@ -152,7 +151,7 @@ func getVolumesFromPodDir(podDir string) ([]podVolume, error) {
|
|||||||
}
|
}
|
||||||
for _, volumeDir := range volumesDirInfo {
|
for _, volumeDir := range volumesDirInfo {
|
||||||
pluginName := volumeDir.Name()
|
pluginName := volumeDir.Name()
|
||||||
volumePluginPath := path.Join(volumesDir, pluginName)
|
volumePluginPath := filepath.Join(volumesDir, pluginName)
|
||||||
volumePluginDirs, err := utilpath.ReadDirNoStat(volumePluginPath)
|
volumePluginDirs, err := utilpath.ReadDirNoStat(volumePluginPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.ErrorS(err, "Could not read volume plugin directory", "volumePluginPath", volumePluginPath)
|
klog.ErrorS(err, "Could not read volume plugin directory", "volumePluginPath", volumePluginPath)
|
||||||
@ -160,7 +159,7 @@ func getVolumesFromPodDir(podDir string) ([]podVolume, error) {
|
|||||||
}
|
}
|
||||||
unescapePluginName := utilstrings.UnescapeQualifiedName(pluginName)
|
unescapePluginName := utilstrings.UnescapeQualifiedName(pluginName)
|
||||||
for _, volumeName := range volumePluginDirs {
|
for _, volumeName := range volumePluginDirs {
|
||||||
volumePath := path.Join(volumePluginPath, volumeName)
|
volumePath := filepath.Join(volumePluginPath, volumeName)
|
||||||
klog.V(5).InfoS("Volume path from volume plugin directory", "podName", podName, "volumePath", volumePath)
|
klog.V(5).InfoS("Volume path from volume plugin directory", "podName", podName, "volumePath", volumePath)
|
||||||
volumes = append(volumes, podVolume{
|
volumes = append(volumes, podVolume{
|
||||||
podName: volumetypes.UniquePodName(podName),
|
podName: volumetypes.UniquePodName(podName),
|
||||||
|
@ -19,7 +19,6 @@ package reconciler
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
@ -48,8 +47,8 @@ func TestReconstructVolumes(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "when two pods are using same volume and both are deleted",
|
name: "when two pods are using same volume and both are deleted",
|
||||||
volumePaths: []string{
|
volumePaths: []string{
|
||||||
path.Join("pod1", "volumes", "fake-plugin", "pvc-abcdef"),
|
filepath.Join("pod1", "volumes", "fake-plugin", "pvc-abcdef"),
|
||||||
path.Join("pod2", "volumes", "fake-plugin", "pvc-abcdef"),
|
filepath.Join("pod2", "volumes", "fake-plugin", "pvc-abcdef"),
|
||||||
},
|
},
|
||||||
expectedVolumesNeedReportedInUse: []string{"fake-plugin/pvc-abcdef", "fake-plugin/pvc-abcdef"},
|
expectedVolumesNeedReportedInUse: []string{"fake-plugin/pvc-abcdef", "fake-plugin/pvc-abcdef"},
|
||||||
expectedVolumesNeedDevicePath: []string{"fake-plugin/pvc-abcdef", "fake-plugin/pvc-abcdef"},
|
expectedVolumesNeedDevicePath: []string{"fake-plugin/pvc-abcdef", "fake-plugin/pvc-abcdef"},
|
||||||
@ -77,7 +76,7 @@ func TestReconstructVolumes(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "when reconstruction fails for a volume, volumes should be cleaned up",
|
name: "when reconstruction fails for a volume, volumes should be cleaned up",
|
||||||
volumePaths: []string{
|
volumePaths: []string{
|
||||||
path.Join("pod1", "volumes", "missing-plugin", "pvc-abcdef"),
|
filepath.Join("pod1", "volumes", "missing-plugin", "pvc-abcdef"),
|
||||||
},
|
},
|
||||||
expectedVolumesNeedReportedInUse: []string{},
|
expectedVolumesNeedReportedInUse: []string{},
|
||||||
expectedVolumesNeedDevicePath: []string{},
|
expectedVolumesNeedDevicePath: []string{},
|
||||||
@ -271,14 +270,14 @@ func TestReconstructVolumesMount(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "reconstructed volume is mounted",
|
name: "reconstructed volume is mounted",
|
||||||
volumePath: path.Join("pod1uid", "volumes", "fake-plugin", "volumename"),
|
volumePath: filepath.Join("pod1uid", "volumes", "fake-plugin", "volumename"),
|
||||||
|
|
||||||
expectMount: true,
|
expectMount: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "reconstructed volume fails to mount",
|
name: "reconstructed volume fails to mount",
|
||||||
// FailOnSetupVolumeName: MountDevice succeeds, SetUp fails
|
// FailOnSetupVolumeName: MountDevice succeeds, SetUp fails
|
||||||
volumePath: path.Join("pod1uid", "volumes", "fake-plugin", volumetesting.FailOnSetupVolumeName),
|
volumePath: filepath.Join("pod1uid", "volumes", "fake-plugin", volumetesting.FailOnSetupVolumeName),
|
||||||
expectMount: false,
|
expectMount: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user