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
4f21b028
Commit
4f21b028
authored
Feb 17, 2017
by
Minhan Xia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initialize directory while creating checkpoint file store
parent
56afb956
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
9 deletions
+31
-9
checkpoint_store.go
pkg/kubelet/dockershim/checkpoint_store.go
+18
-5
checkpoint_store_test.go
pkg/kubelet/dockershim/checkpoint_store_test.go
+2
-1
docker_checkpoint.go
pkg/kubelet/dockershim/docker_checkpoint.go
+6
-2
docker_service.go
pkg/kubelet/dockershim/docker_service.go
+5
-1
No files found.
pkg/kubelet/dockershim/checkpoint_store.go
View file @
4f21b028
...
...
@@ -57,15 +57,19 @@ type FileStore struct {
path
string
}
func
NewFileStore
(
path
string
)
(
CheckpointStore
,
error
)
{
if
err
:=
ensurePath
(
path
);
err
!=
nil
{
return
nil
,
err
}
return
&
FileStore
{
path
:
path
},
nil
}
func
(
fstore
*
FileStore
)
Write
(
key
string
,
data
[]
byte
)
error
{
if
err
:=
validateKey
(
key
);
err
!=
nil
{
return
err
}
if
_
,
err
:=
os
.
Stat
(
fstore
.
path
);
err
!=
nil
{
// if directory already exists, proceed
if
err
=
os
.
MkdirAll
(
fstore
.
path
,
0755
);
err
!=
nil
&&
!
os
.
IsExist
(
err
)
{
return
err
}
if
err
:=
ensurePath
(
fstore
.
path
);
err
!=
nil
{
return
err
}
tmpfile
:=
filepath
.
Join
(
fstore
.
path
,
fmt
.
Sprintf
(
"%s%s%s"
,
tmpPrefix
,
key
,
tmpSuffix
))
if
err
:=
ioutil
.
WriteFile
(
tmpfile
,
data
,
0644
);
err
!=
nil
{
...
...
@@ -113,6 +117,15 @@ func (fstore *FileStore) getCheckpointPath(key string) string {
return
filepath
.
Join
(
fstore
.
path
,
key
)
}
// ensurePath creates input directory if it does not exist
func
ensurePath
(
path
string
)
error
{
if
_
,
err
:=
os
.
Stat
(
path
);
err
!=
nil
{
// MkdirAll returns nil if directory already exists
return
os
.
MkdirAll
(
path
,
0755
)
}
return
nil
}
func
validateKey
(
key
string
)
error
{
if
len
(
key
)
<=
keyMaxLength
&&
keyRegex
.
MatchString
(
key
)
{
return
nil
...
...
pkg/kubelet/dockershim/checkpoint_store_test.go
View file @
4f21b028
...
...
@@ -30,7 +30,8 @@ func TestFileStore(t *testing.T) {
path
,
err
:=
ioutil
.
TempDir
(
""
,
"FileStore"
)
assert
.
NoError
(
t
,
err
)
defer
cleanUpTestPath
(
t
,
path
)
store
:=
&
FileStore
{
path
:
path
}
store
,
err
:=
NewFileStore
(
path
)
assert
.
NoError
(
t
,
err
)
Checkpoints
:=
[]
struct
{
key
string
...
...
pkg/kubelet/dockershim/docker_checkpoint.go
View file @
4f21b028
...
...
@@ -84,8 +84,12 @@ type PersistentCheckpointHandler struct {
store
CheckpointStore
}
func
NewPersistentCheckpointHandler
()
CheckpointHandler
{
return
&
PersistentCheckpointHandler
{
store
:
&
FileStore
{
path
:
filepath
.
Join
(
dockershimRootDir
,
sandboxCheckpointDir
)}}
func
NewPersistentCheckpointHandler
()
(
CheckpointHandler
,
error
)
{
fstore
,
err
:=
NewFileStore
(
filepath
.
Join
(
dockershimRootDir
,
sandboxCheckpointDir
))
if
err
!=
nil
{
return
nil
,
err
}
return
&
PersistentCheckpointHandler
{
store
:
fstore
},
nil
}
func
(
handler
*
PersistentCheckpointHandler
)
CreateCheckpoint
(
podSandboxID
string
,
checkpoint
*
PodSandboxCheckpoint
)
error
{
...
...
pkg/kubelet/dockershim/docker_service.go
View file @
4f21b028
...
...
@@ -147,6 +147,10 @@ var internalLabelKeys []string = []string{containerTypeLabelKey, containerLogPat
func
NewDockerService
(
client
dockertools
.
DockerInterface
,
seccompProfileRoot
string
,
podSandboxImage
string
,
streamingConfig
*
streaming
.
Config
,
pluginSettings
*
NetworkPluginSettings
,
cgroupsName
string
,
kubeCgroupDriver
string
,
execHandler
dockertools
.
ExecHandler
)
(
DockerService
,
error
)
{
c
:=
dockertools
.
NewInstrumentedDockerInterface
(
client
)
checkpointHandler
,
err
:=
NewPersistentCheckpointHandler
()
if
err
!=
nil
{
return
nil
,
err
}
ds
:=
&
dockerService
{
seccompProfileRoot
:
seccompProfileRoot
,
client
:
c
,
...
...
@@ -157,7 +161,7 @@ func NewDockerService(client dockertools.DockerInterface, seccompProfileRoot str
execHandler
:
execHandler
,
},
containerManager
:
cm
.
NewContainerManager
(
cgroupsName
,
client
),
checkpointHandler
:
NewPersistentCheckpointHandler
()
,
checkpointHandler
:
checkpointHandler
,
}
if
streamingConfig
!=
nil
{
var
err
error
...
...
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