Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
528c0342
Commit
528c0342
authored
Jul 14, 2017
by
Slava Semushin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kubelet: remove code for handling old pod/containers paths.
parent
cb712e41
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
77 deletions
+2
-77
kubelet_getters.go
pkg/kubelet/kubelet_getters.go
+2
-34
kubelet_getters_test.go
pkg/kubelet/kubelet_getters_test.go
+0
-43
No files found.
pkg/kubelet/kubelet_getters.go
View file @
528c0342
...
...
@@ -71,23 +71,7 @@ func (kl *Kubelet) GetPodDir(podUID types.UID) string {
// getPodDir returns the full path to the per-pod directory for the pod with
// the given UID.
func
(
kl
*
Kubelet
)
getPodDir
(
podUID
types
.
UID
)
string
{
// Backwards compat. The "old" stuff should be removed before 1.0
// release. The thinking here is this:
// !old && !new = use new
// !old && new = use new
// old && !new = use old
// old && new = use new (but warn)
oldPath
:=
filepath
.
Join
(
kl
.
getRootDir
(),
string
(
podUID
))
oldExists
:=
dirExists
(
oldPath
)
newPath
:=
filepath
.
Join
(
kl
.
getPodsDir
(),
string
(
podUID
))
newExists
:=
dirExists
(
newPath
)
if
oldExists
&&
!
newExists
{
return
oldPath
}
if
oldExists
{
glog
.
Warningf
(
"Data dir for pod %q exists in both old and new form, using new"
,
podUID
)
}
return
newPath
return
filepath
.
Join
(
kl
.
getPodsDir
(),
string
(
podUID
))
}
// getPodVolumesDir returns the full path to the per-pod data directory under
...
...
@@ -122,23 +106,7 @@ func (kl *Kubelet) getPodPluginDir(podUID types.UID, pluginName string) string {
// which container data is held for the specified pod. This directory may not
// exist if the pod or container does not exist.
func
(
kl
*
Kubelet
)
getPodContainerDir
(
podUID
types
.
UID
,
ctrName
string
)
string
{
// Backwards compat. The "old" stuff should be removed before 1.0
// release. The thinking here is this:
// !old && !new = use new
// !old && new = use new
// old && !new = use old
// old && new = use new (but warn)
oldPath
:=
filepath
.
Join
(
kl
.
getPodDir
(
podUID
),
ctrName
)
oldExists
:=
dirExists
(
oldPath
)
newPath
:=
filepath
.
Join
(
kl
.
getPodDir
(
podUID
),
options
.
DefaultKubeletContainersDirName
,
ctrName
)
newExists
:=
dirExists
(
newPath
)
if
oldExists
&&
!
newExists
{
return
oldPath
}
if
oldExists
{
glog
.
Warningf
(
"Data dir for pod %q, container %q exists in both old and new form, using new"
,
podUID
,
ctrName
)
}
return
newPath
return
filepath
.
Join
(
kl
.
getPodDir
(
podUID
),
options
.
DefaultKubeletContainersDirName
,
ctrName
)
}
// GetPods returns all pods bound to the kubelet and their spec, and the mirror
...
...
pkg/kubelet/kubelet_getters_test.go
View file @
528c0342
...
...
@@ -17,13 +17,10 @@ limitations under the License.
package
kubelet
import
(
"fmt"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func
TestKubeletDirs
(
t
*
testing
.
T
)
{
...
...
@@ -70,43 +67,3 @@ func TestKubeletDirs(t *testing.T) {
exp
=
filepath
.
Join
(
root
,
"pods/abc123/containers/def456"
)
assert
.
Equal
(
t
,
exp
,
got
)
}
func
TestKubeletDirsCompat
(
t
*
testing
.
T
)
{
testKubelet
:=
newTestKubelet
(
t
,
false
/* controllerAttachDetachEnabled */
)
defer
testKubelet
.
Cleanup
()
kubelet
:=
testKubelet
.
kubelet
root
:=
kubelet
.
rootDirectory
require
.
NoError
(
t
,
os
.
MkdirAll
(
root
,
0750
),
"can't mkdir(%q)"
,
root
)
// Old-style pod dir.
require
.
NoError
(
t
,
os
.
MkdirAll
(
fmt
.
Sprintf
(
"%s/oldpod"
,
root
),
0750
),
"can't mkdir(%q)"
,
root
)
// New-style pod dir.
require
.
NoError
(
t
,
os
.
MkdirAll
(
fmt
.
Sprintf
(
"%s/pods/newpod"
,
root
),
0750
),
"can't mkdir(%q)"
,
root
)
// Both-style pod dir.
require
.
NoError
(
t
,
os
.
MkdirAll
(
fmt
.
Sprintf
(
"%s/bothpod"
,
root
),
0750
),
"can't mkdir(%q)"
,
root
)
require
.
NoError
(
t
,
os
.
MkdirAll
(
fmt
.
Sprintf
(
"%s/pods/bothpod"
,
root
),
0750
),
"can't mkdir(%q)"
,
root
)
assert
.
Equal
(
t
,
filepath
.
Join
(
root
,
"oldpod"
),
kubelet
.
getPodDir
(
"oldpod"
))
assert
.
Equal
(
t
,
filepath
.
Join
(
root
,
"pods/newpod"
),
kubelet
.
getPodDir
(
"newpod"
))
assert
.
Equal
(
t
,
filepath
.
Join
(
root
,
"pods/bothpod"
),
kubelet
.
getPodDir
(
"bothpod"
))
assert
.
Equal
(
t
,
filepath
.
Join
(
root
,
"pods/neitherpod"
),
kubelet
.
getPodDir
(
"neitherpod"
))
root
=
kubelet
.
getPodDir
(
"newpod"
)
// Old-style container dir.
require
.
NoError
(
t
,
os
.
MkdirAll
(
fmt
.
Sprintf
(
"%s/oldctr"
,
root
),
0750
),
"can't mkdir(%q)"
,
root
)
// New-style container dir.
require
.
NoError
(
t
,
os
.
MkdirAll
(
fmt
.
Sprintf
(
"%s/containers/newctr"
,
root
),
0750
),
"can't mkdir(%q)"
,
root
)
// Both-style container dir.
require
.
NoError
(
t
,
os
.
MkdirAll
(
fmt
.
Sprintf
(
"%s/bothctr"
,
root
),
0750
),
"can't mkdir(%q)"
,
root
)
require
.
NoError
(
t
,
os
.
MkdirAll
(
fmt
.
Sprintf
(
"%s/containers/bothctr"
,
root
),
0750
),
"can't mkdir(%q)"
,
root
)
assert
.
Equal
(
t
,
filepath
.
Join
(
root
,
"oldctr"
),
kubelet
.
getPodContainerDir
(
"newpod"
,
"oldctr"
))
assert
.
Equal
(
t
,
filepath
.
Join
(
root
,
"containers/newctr"
),
kubelet
.
getPodContainerDir
(
"newpod"
,
"newctr"
))
assert
.
Equal
(
t
,
filepath
.
Join
(
root
,
"containers/bothctr"
),
kubelet
.
getPodContainerDir
(
"newpod"
,
"bothctr"
))
assert
.
Equal
(
t
,
filepath
.
Join
(
root
,
"containers/neitherctr"
),
kubelet
.
getPodContainerDir
(
"newpod"
,
"neitherctr"
))
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment