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
124def22
Commit
124def22
authored
Feb 24, 2020
by
Darren Shepherd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update vendor
parent
4d32fe99
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
221 additions
and
45 deletions
+221
-45
go.mod
go.mod
+3
-3
go.sum
go.sum
+4
-4
container.go
vendor/github.com/containerd/containerd/container.go
+11
-0
container_create.go
.../github.com/containerd/cri/pkg/server/container_create.go
+32
-3
helpers.go
vendor/github.com/containerd/cri/pkg/server/helpers.go
+34
-26
sandbox_run.go
vendor/github.com/containerd/cri/pkg/server/sandbox_run.go
+20
-3
service.go
vendor/github.com/containerd/cri/pkg/server/service.go
+4
-2
container.go
...ithub.com/containerd/cri/pkg/store/container/container.go
+8
-1
metadata.go
...github.com/containerd/cri/pkg/store/container/metadata.go
+2
-0
label.go
vendor/github.com/containerd/cri/pkg/store/label/label.go
+90
-0
metadata.go
...r/github.com/containerd/cri/pkg/store/sandbox/metadata.go
+2
-0
sandbox.go
...or/github.com/containerd/cri/pkg/store/sandbox/sandbox.go
+8
-1
modules.txt
vendor/modules.txt
+3
-2
No files found.
go.mod
View file @
124def22
...
@@ -7,9 +7,9 @@ replace (
...
@@ -7,9 +7,9 @@ replace (
github.com/containerd/btrfs => github.com/containerd/btrfs v0.0.0-20181101203652-af5082808c83
github.com/containerd/btrfs => github.com/containerd/btrfs v0.0.0-20181101203652-af5082808c83
github.com/containerd/cgroups => github.com/containerd/cgroups v0.0.0-20190717030353-c4b9ac5c7601
github.com/containerd/cgroups => github.com/containerd/cgroups v0.0.0-20190717030353-c4b9ac5c7601
github.com/containerd/console => github.com/containerd/console v0.0.0-20181022165439-0650fd9eeb50
github.com/containerd/console => github.com/containerd/console v0.0.0-20181022165439-0650fd9eeb50
github.com/containerd/containerd => github.com/rancher/containerd v1.3.3-k3s
1
github.com/containerd/containerd => github.com/rancher/containerd v1.3.3-k3s
2
github.com/containerd/continuity => github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02
github.com/containerd/continuity => github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02
github.com/containerd/cri => github.com/rancher/cri v1.3.0-k3s.
3
github.com/containerd/cri => github.com/rancher/cri v1.3.0-k3s.
4
github.com/containerd/fifo => github.com/containerd/fifo v0.0.0-20190816180239-bda0ff6ed73c
github.com/containerd/fifo => github.com/containerd/fifo v0.0.0-20190816180239-bda0ff6ed73c
github.com/containerd/go-runc => github.com/containerd/go-runc v0.0.0-20190911050354-e029b79d8cda
github.com/containerd/go-runc => github.com/containerd/go-runc v0.0.0-20190911050354-e029b79d8cda
github.com/containerd/typeurl => github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd
github.com/containerd/typeurl => github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd
...
@@ -94,6 +94,7 @@ require (
...
@@ -94,6 +94,7 @@ require (
github.com/mattn/go-sqlite3 v1.13.0
github.com/mattn/go-sqlite3 v1.13.0
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/opencontainers/runc v1.0.0-rc9
github.com/opencontainers/runc v1.0.0-rc9
github.com/opencontainers/selinux v1.3.1-0.20190929122143-5215b1806f52
github.com/pkg/errors v0.8.1
github.com/pkg/errors v0.8.1
github.com/rakelkar/gonetsh v0.0.0-20190719023240-501daadcadf8 // indirect
github.com/rakelkar/gonetsh v0.0.0-20190719023240-501daadcadf8 // indirect
github.com/rancher/dynamiclistener v0.2.0
github.com/rancher/dynamiclistener v0.2.0
...
@@ -122,6 +123,5 @@ require (
...
@@ -122,6 +123,5 @@ require (
k8s.io/component-base v0.0.0
k8s.io/component-base v0.0.0
k8s.io/cri-api v0.0.0
k8s.io/cri-api v0.0.0
k8s.io/klog v1.0.0
k8s.io/klog v1.0.0
k8s.io/kubelet v0.0.0
k8s.io/kubernetes v1.16.0
k8s.io/kubernetes v1.16.0
)
)
go.sum
View file @
124def22
...
@@ -708,10 +708,10 @@ github.com/quasilyte/go-consistent v0.0.0-20190521200055-c6f3937de18c/go.mod h1:
...
@@ -708,10 +708,10 @@ github.com/quasilyte/go-consistent v0.0.0-20190521200055-c6f3937de18c/go.mod h1:
github.com/quobyte/api v0.1.2/go.mod h1:jL7lIHrmqQ7yh05OJ+eEEdHr0u/kmT1Ff9iHd+4H6VI=
github.com/quobyte/api v0.1.2/go.mod h1:jL7lIHrmqQ7yh05OJ+eEEdHr0u/kmT1Ff9iHd+4H6VI=
github.com/rakelkar/gonetsh v0.0.0-20190719023240-501daadcadf8 h1:83l9gPhYtgxODlZKU0Odq4pQuDcMZEVgAh364+PV3OU=
github.com/rakelkar/gonetsh v0.0.0-20190719023240-501daadcadf8 h1:83l9gPhYtgxODlZKU0Odq4pQuDcMZEVgAh364+PV3OU=
github.com/rakelkar/gonetsh v0.0.0-20190719023240-501daadcadf8/go.mod h1:4XHkfaUj+URzGO9sohoAgt2V9Y8nIW7fugpu0E6gShk=
github.com/rakelkar/gonetsh v0.0.0-20190719023240-501daadcadf8/go.mod h1:4XHkfaUj+URzGO9sohoAgt2V9Y8nIW7fugpu0E6gShk=
github.com/rancher/containerd v1.3.3-k3s
1 h1:j8NGZdXKsZd2ne0XQg6OBfMJ/NkY/Qri6QhscGrJp2M
=
github.com/rancher/containerd v1.3.3-k3s
2 h1:RZr+TqFt7+YsrSYkyytlhW4HmneWeFNM7IymNOoGW6A
=
github.com/rancher/containerd v1.3.3-k3s
1
/go.mod h1:ZMfzmqce2Z+QSEqdHMfeJs1TZ/UeJ1aDrazjpQT4ehM=
github.com/rancher/containerd v1.3.3-k3s
2
/go.mod h1:ZMfzmqce2Z+QSEqdHMfeJs1TZ/UeJ1aDrazjpQT4ehM=
github.com/rancher/cri v1.3.0-k3s.
3 h1:j/Sq2LMyg6gBn2MS1j5dEudpdL+UYVH7ubbewUCXkS0
=
github.com/rancher/cri v1.3.0-k3s.
4 h1:BXER8109dxgNw4qq8HHOCJ+3sHO+9AA1cwZTOLlqoTo
=
github.com/rancher/cri v1.3.0-k3s.
3
/go.mod h1:Ht5T1dIKzm+4NExmb7wDVG6qR+j0xeXIjjhCv1d9geY=
github.com/rancher/cri v1.3.0-k3s.
4
/go.mod h1:Ht5T1dIKzm+4NExmb7wDVG6qR+j0xeXIjjhCv1d9geY=
github.com/rancher/cri-tools v1.17.0-k3s1 h1:jfu97FowbraTDc7b6fxWtO+dq+DU2oW+ABBQSEFiRb0=
github.com/rancher/cri-tools v1.17.0-k3s1 h1:jfu97FowbraTDc7b6fxWtO+dq+DU2oW+ABBQSEFiRb0=
github.com/rancher/cri-tools v1.17.0-k3s1/go.mod h1:bRTZttsvk+nCG8tSFs8D6UUx8CkMXR5TAsRLS0fXAqI=
github.com/rancher/cri-tools v1.17.0-k3s1/go.mod h1:bRTZttsvk+nCG8tSFs8D6UUx8CkMXR5TAsRLS0fXAqI=
github.com/rancher/dynamiclistener v0.2.0 h1:KucYwJXVVGhZ/NndfMCeQoCafT/VN7kvqSGgmlX8Lxk=
github.com/rancher/dynamiclistener v0.2.0 h1:KucYwJXVVGhZ/NndfMCeQoCafT/VN7kvqSGgmlX8Lxk=
...
...
vendor/github.com/containerd/containerd/container.go
View file @
124def22
...
@@ -36,6 +36,7 @@ import (
...
@@ -36,6 +36,7 @@ import (
prototypes
"github.com/gogo/protobuf/types"
prototypes
"github.com/gogo/protobuf/types"
ver
"github.com/opencontainers/image-spec/specs-go"
ver
"github.com/opencontainers/image-spec/specs-go"
ocispec
"github.com/opencontainers/image-spec/specs-go/v1"
ocispec
"github.com/opencontainers/image-spec/specs-go/v1"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/pkg/errors"
"github.com/pkg/errors"
)
)
...
@@ -242,7 +243,17 @@ func (c *container) NewTask(ctx context.Context, ioCreate cio.Creator, opts ...N
...
@@ -242,7 +243,17 @@ func (c *container) NewTask(ctx context.Context, ioCreate cio.Creator, opts ...N
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
spec
,
err
:=
c
.
Spec
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
for
_
,
m
:=
range
mounts
{
for
_
,
m
:=
range
mounts
{
if
spec
.
Linux
!=
nil
&&
spec
.
Linux
.
MountLabel
!=
""
{
context
:=
label
.
FormatMountLabel
(
""
,
spec
.
Linux
.
MountLabel
)
if
context
!=
""
{
m
.
Options
=
append
(
m
.
Options
,
context
)
}
}
request
.
Rootfs
=
append
(
request
.
Rootfs
,
&
types
.
Mount
{
request
.
Rootfs
=
append
(
request
.
Rootfs
,
&
types
.
Mount
{
Type
:
m
.
Type
,
Type
:
m
.
Type
,
Source
:
m
.
Source
,
Source
:
m
.
Source
,
...
...
vendor/github.com/containerd/cri/pkg/server/container_create.go
View file @
124def22
...
@@ -39,6 +39,7 @@ import (
...
@@ -39,6 +39,7 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/davecgh/go-spew/spew"
imagespec
"github.com/opencontainers/image-spec/specs-go/v1"
imagespec
"github.com/opencontainers/image-spec/specs-go/v1"
runtimespec
"github.com/opencontainers/runtime-spec/specs-go"
runtimespec
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/pkg/errors"
"github.com/pkg/errors"
"golang.org/x/net/context"
"golang.org/x/net/context"
runtime
"k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
runtime
"k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
...
@@ -173,6 +174,18 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
...
@@ -173,6 +174,18 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
return
nil
,
errors
.
Wrapf
(
err
,
"failed to generate container %q spec"
,
id
)
return
nil
,
errors
.
Wrapf
(
err
,
"failed to generate container %q spec"
,
id
)
}
}
meta
.
ProcessLabel
=
spec
.
Process
.
SelinuxLabel
if
config
.
GetLinux
()
.
GetSecurityContext
()
.
GetPrivileged
()
{
// If privileged don't set the SELinux label but still record it on the container so
// the unused MCS label can be release later
spec
.
Process
.
SelinuxLabel
=
""
}
defer
func
()
{
if
retErr
!=
nil
{
_
=
label
.
ReleaseLabel
(
spec
.
Process
.
SelinuxLabel
)
}
}()
log
.
G
(
ctx
)
.
Debugf
(
"Container %q spec: %#+v"
,
id
,
spew
.
NewFormatter
(
spec
))
log
.
G
(
ctx
)
.
Debugf
(
"Container %q spec: %#+v"
,
id
,
spew
.
NewFormatter
(
spec
))
// Set snapshotter before any other options.
// Set snapshotter before any other options.
...
@@ -324,7 +337,7 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
...
@@ -324,7 +337,7 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
func
(
c
*
criService
)
generateContainerSpec
(
id
string
,
sandboxID
string
,
sandboxPid
uint32
,
config
*
runtime
.
ContainerConfig
,
func
(
c
*
criService
)
generateContainerSpec
(
id
string
,
sandboxID
string
,
sandboxPid
uint32
,
config
*
runtime
.
ContainerConfig
,
sandboxConfig
*
runtime
.
PodSandboxConfig
,
imageConfig
*
imagespec
.
ImageConfig
,
extraMounts
[]
*
runtime
.
Mount
,
sandboxConfig
*
runtime
.
PodSandboxConfig
,
imageConfig
*
imagespec
.
ImageConfig
,
extraMounts
[]
*
runtime
.
Mount
,
ociRuntime
config
.
Runtime
)
(
*
runtimespec
.
Spec
,
error
)
{
ociRuntime
config
.
Runtime
)
(
retSpec
*
runtimespec
.
Spec
,
retErr
error
)
{
specOpts
:=
[]
oci
.
SpecOpts
{
specOpts
:=
[]
oci
.
SpecOpts
{
customopts
.
WithoutRunMount
,
customopts
.
WithoutRunMount
,
...
@@ -366,11 +379,27 @@ func (c *criService) generateContainerSpec(id string, sandboxID string, sandboxP
...
@@ -366,11 +379,27 @@ func (c *criService) generateContainerSpec(id string, sandboxID string, sandboxP
specOpts
=
append
(
specOpts
,
oci
.
WithEnv
(
env
))
specOpts
=
append
(
specOpts
,
oci
.
WithEnv
(
env
))
securityContext
:=
config
.
GetLinux
()
.
GetSecurityContext
()
securityContext
:=
config
.
GetLinux
()
.
GetSecurityContext
()
selinuxOpt
:=
securityContext
.
GetSelinuxOptions
()
labelOptions
:=
toLabel
(
securityContext
.
GetSelinuxOptions
())
processLabel
,
mountLabel
,
err
:=
initSelinuxOpts
(
selinuxOpt
)
if
len
(
labelOptions
)
==
0
{
// Use pod level SELinux config
if
sandbox
,
err
:=
c
.
sandboxStore
.
Get
(
sandboxID
);
err
==
nil
{
labelOptions
,
err
=
label
.
DupSecOpt
(
sandbox
.
ProcessLabel
)
if
err
!=
nil
{
return
nil
,
err
}
}
}
processLabel
,
mountLabel
,
err
:=
label
.
InitLabels
(
labelOptions
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"failed to init selinux options %+v"
,
securityContext
.
GetSelinuxOptions
())
return
nil
,
errors
.
Wrapf
(
err
,
"failed to init selinux options %+v"
,
securityContext
.
GetSelinuxOptions
())
}
}
defer
func
()
{
if
retErr
!=
nil
{
_
=
label
.
ReleaseLabel
(
processLabel
)
}
}()
specOpts
=
append
(
specOpts
,
customopts
.
WithMounts
(
c
.
os
,
config
,
extraMounts
,
mountLabel
))
specOpts
=
append
(
specOpts
,
customopts
.
WithMounts
(
c
.
os
,
config
,
extraMounts
,
mountLabel
))
if
!
c
.
config
.
DisableProcMount
{
if
!
c
.
config
.
DisableProcMount
{
...
...
vendor/github.com/containerd/cri/pkg/server/helpers.go
View file @
124def22
...
@@ -298,47 +298,55 @@ func (c *criService) ensureImageExists(ctx context.Context, ref string, config *
...
@@ -298,47 +298,55 @@ func (c *criService) ensureImageExists(ctx context.Context, ref string, config *
return
&
newImage
,
nil
return
&
newImage
,
nil
}
}
func
initSelinuxOpts
(
selinuxOpt
*
runtime
.
SELinuxOption
)
(
string
,
string
,
error
)
{
func
toLabel
(
selinuxOptions
*
runtime
.
SELinuxOption
)
(
labels
[]
string
)
{
if
selinuxOpt
==
nil
{
if
selinuxOpt
ions
==
nil
{
return
""
,
""
,
nil
return
nil
}
}
// Should ignored selinuxOpts if they are incomplete.
if
selinuxOptions
.
User
!=
""
{
if
selinuxOpt
.
GetUser
()
==
""
||
labels
=
append
(
labels
,
"user:"
+
selinuxOptions
.
User
)
selinuxOpt
.
GetRole
()
==
""
||
selinuxOpt
.
GetType
()
==
""
{
return
""
,
""
,
nil
}
}
if
selinuxOptions
.
Role
!=
""
{
// make sure the format of "level" is correct.
labels
=
append
(
labels
,
"role:"
+
selinuxOptions
.
Role
)
ok
,
err
:=
checkSelinuxLevel
(
selinuxOpt
.
GetLevel
())
}
if
err
!=
nil
||
!
ok
{
if
selinuxOptions
.
Type
!=
""
{
return
""
,
""
,
err
labels
=
append
(
labels
,
"type:"
+
selinuxOptions
.
Type
)
}
if
selinuxOptions
.
Level
!=
""
{
labels
=
append
(
labels
,
"level:"
+
selinuxOptions
.
Level
)
}
}
labelOpts
:=
fmt
.
Sprintf
(
"%s:%s:%s:%s"
,
return
selinuxOpt
.
GetUser
(),
}
selinuxOpt
.
GetRole
(),
selinuxOpt
.
GetType
(),
selinuxOpt
.
GetLevel
())
options
,
err
:=
label
.
DupSecOpt
(
labelOpts
)
func
initLabelsFromOpt
(
selinuxOpts
*
runtime
.
SELinuxOption
)
(
string
,
string
,
error
)
{
if
err
!=
nil
{
return
initLabels
(
toLabel
(
selinuxOpts
))
return
""
,
""
,
err
}
func
initLabels
(
options
[]
string
)
(
string
,
string
,
error
)
{
for
_
,
opt
:=
range
options
{
if
strings
.
HasPrefix
(
opt
,
"level:"
)
{
if
err
:=
checkSelinuxLevel
(
strings
.
TrimPrefix
(
opt
,
"level:"
));
err
!=
nil
{
return
""
,
""
,
err
}
}
}
}
return
label
.
InitLabels
(
options
)
return
label
.
InitLabels
(
options
)
}
}
func
checkSelinuxLevel
(
level
string
)
(
bool
,
error
)
{
func
checkSelinuxLevel
(
level
string
)
error
{
if
len
(
level
)
==
0
{
if
len
(
level
)
==
0
{
return
true
,
nil
return
nil
}
}
matched
,
err
:=
regexp
.
MatchString
(
`^s\d(-s\d)??(:c\d{1,4}((.c\d{1,4})?,c\d{1,4})*(.c\d{1,4})?(,c\d{1,4}(.c\d{1,4})?)*)?$`
,
level
)
matched
,
err
:=
regexp
.
MatchString
(
`^s\d(-s\d)??(:c\d{1,4}((.c\d{1,4})?,c\d{1,4})*(.c\d{1,4})?(,c\d{1,4}(.c\d{1,4})?)*)?$`
,
level
)
if
err
!=
nil
||
!
matched
{
if
err
!=
nil
{
return
false
,
errors
.
Wrapf
(
err
,
"the format of 'level' %q is not correct"
,
level
)
return
errors
.
Wrapf
(
err
,
"the format of 'level' %q is not correct"
,
level
)
}
if
!
matched
{
return
fmt
.
Errorf
(
"the format of 'level' %q is not correct"
,
level
)
}
}
return
true
,
nil
return
nil
}
}
// isInCRIMounts checks whether a destination is in CRI mount list.
// isInCRIMounts checks whether a destination is in CRI mount list.
...
...
vendor/github.com/containerd/cri/pkg/server/sandbox_run.go
View file @
124def22
...
@@ -34,6 +34,7 @@ import (
...
@@ -34,6 +34,7 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/davecgh/go-spew/spew"
imagespec
"github.com/opencontainers/image-spec/specs-go/v1"
imagespec
"github.com/opencontainers/image-spec/specs-go/v1"
runtimespec
"github.com/opencontainers/runtime-spec/specs-go"
runtimespec
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/pkg/errors"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
"golang.org/x/net/context"
...
@@ -158,6 +159,18 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
...
@@ -158,6 +159,18 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
return
nil
,
errors
.
Wrap
(
err
,
"failed to generate sandbox container spec"
)
return
nil
,
errors
.
Wrap
(
err
,
"failed to generate sandbox container spec"
)
}
}
log
.
G
(
ctx
)
.
Debugf
(
"Sandbox container %q spec: %#+v"
,
id
,
spew
.
NewFormatter
(
spec
))
log
.
G
(
ctx
)
.
Debugf
(
"Sandbox container %q spec: %#+v"
,
id
,
spew
.
NewFormatter
(
spec
))
sandbox
.
ProcessLabel
=
spec
.
Process
.
SelinuxLabel
defer
func
()
{
if
retErr
!=
nil
{
_
=
label
.
ReleaseLabel
(
sandbox
.
ProcessLabel
)
}
}()
if
securityContext
.
GetPrivileged
()
{
// If privileged don't set selinux label, but we still record the MCS label so that
// the unused label can be freed later.
spec
.
Process
.
SelinuxLabel
=
""
}
var
specOpts
[]
oci
.
SpecOpts
var
specOpts
[]
oci
.
SpecOpts
userstr
,
err
:=
generateUserString
(
userstr
,
err
:=
generateUserString
(
...
@@ -328,7 +341,7 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
...
@@ -328,7 +341,7 @@ func (c *criService) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
}
}
func
(
c
*
criService
)
generateSandboxContainerSpec
(
id
string
,
config
*
runtime
.
PodSandboxConfig
,
func
(
c
*
criService
)
generateSandboxContainerSpec
(
id
string
,
config
*
runtime
.
PodSandboxConfig
,
imageConfig
*
imagespec
.
ImageConfig
,
nsPath
string
,
runtimePodAnnotations
[]
string
)
(
*
runtimespec
.
Spec
,
error
)
{
imageConfig
*
imagespec
.
ImageConfig
,
nsPath
string
,
runtimePodAnnotations
[]
string
)
(
retSpec
*
runtimespec
.
Spec
,
retErr
error
)
{
// Creates a spec Generator with the default spec.
// Creates a spec Generator with the default spec.
// TODO(random-liu): [P1] Compare the default settings with docker and containerd default.
// TODO(random-liu): [P1] Compare the default settings with docker and containerd default.
specOpts
:=
[]
oci
.
SpecOpts
{
specOpts
:=
[]
oci
.
SpecOpts
{
...
@@ -403,11 +416,15 @@ func (c *criService) generateSandboxContainerSpec(id string, config *runtime.Pod
...
@@ -403,11 +416,15 @@ func (c *criService) generateSandboxContainerSpec(id string, config *runtime.Pod
},
},
}))
}))
selinuxOpt
:=
securityContext
.
GetSelinuxOptions
()
processLabel
,
mountLabel
,
err
:=
initLabelsFromOpt
(
securityContext
.
GetSelinuxOptions
())
processLabel
,
mountLabel
,
err
:=
initSelinuxOpts
(
selinuxOpt
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"failed to init selinux options %+v"
,
securityContext
.
GetSelinuxOptions
())
return
nil
,
errors
.
Wrapf
(
err
,
"failed to init selinux options %+v"
,
securityContext
.
GetSelinuxOptions
())
}
}
defer
func
()
{
if
retErr
!=
nil
&&
processLabel
!=
""
{
_
=
label
.
ReleaseLabel
(
processLabel
)
}
}()
supplementalGroups
:=
securityContext
.
GetSupplementalGroups
()
supplementalGroups
:=
securityContext
.
GetSupplementalGroups
()
specOpts
=
append
(
specOpts
,
specOpts
=
append
(
specOpts
,
...
...
vendor/github.com/containerd/cri/pkg/server/service.go
View file @
124def22
...
@@ -25,6 +25,7 @@ import (
...
@@ -25,6 +25,7 @@ import (
"github.com/containerd/containerd"
"github.com/containerd/containerd"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/plugin"
"github.com/containerd/cri/pkg/store/label"
cni
"github.com/containerd/go-cni"
cni
"github.com/containerd/go-cni"
runcapparmor
"github.com/opencontainers/runc/libcontainer/apparmor"
runcapparmor
"github.com/opencontainers/runc/libcontainer/apparmor"
runcseccomp
"github.com/opencontainers/runc/libcontainer/seccomp"
runcseccomp
"github.com/opencontainers/runc/libcontainer/seccomp"
...
@@ -104,14 +105,15 @@ type criService struct {
...
@@ -104,14 +105,15 @@ type criService struct {
// NewCRIService returns a new instance of CRIService
// NewCRIService returns a new instance of CRIService
func
NewCRIService
(
config
criconfig
.
Config
,
client
*
containerd
.
Client
)
(
CRIService
,
error
)
{
func
NewCRIService
(
config
criconfig
.
Config
,
client
*
containerd
.
Client
)
(
CRIService
,
error
)
{
var
err
error
var
err
error
labels
:=
label
.
NewStore
()
c
:=
&
criService
{
c
:=
&
criService
{
config
:
config
,
config
:
config
,
client
:
client
,
client
:
client
,
apparmorEnabled
:
runcapparmor
.
IsEnabled
()
&&
!
config
.
DisableApparmor
,
apparmorEnabled
:
runcapparmor
.
IsEnabled
()
&&
!
config
.
DisableApparmor
,
seccompEnabled
:
runcseccomp
.
IsEnabled
(),
seccompEnabled
:
runcseccomp
.
IsEnabled
(),
os
:
osinterface
.
RealOS
{},
os
:
osinterface
.
RealOS
{},
sandboxStore
:
sandboxstore
.
NewStore
(),
sandboxStore
:
sandboxstore
.
NewStore
(
labels
),
containerStore
:
containerstore
.
NewStore
(),
containerStore
:
containerstore
.
NewStore
(
labels
),
imageStore
:
imagestore
.
NewStore
(
client
),
imageStore
:
imagestore
.
NewStore
(
client
),
snapshotStore
:
snapshotstore
.
NewStore
(),
snapshotStore
:
snapshotstore
.
NewStore
(),
sandboxNameIndex
:
registrar
.
NewRegistrar
(),
sandboxNameIndex
:
registrar
.
NewRegistrar
(),
...
...
vendor/github.com/containerd/cri/pkg/store/container/container.go
View file @
124def22
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"sync"
"sync"
"github.com/containerd/containerd"
"github.com/containerd/containerd"
"github.com/containerd/cri/pkg/store/label"
"github.com/docker/docker/pkg/truncindex"
"github.com/docker/docker/pkg/truncindex"
runtime
"k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
runtime
"k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
...
@@ -101,13 +102,15 @@ type Store struct {
...
@@ -101,13 +102,15 @@ type Store struct {
lock
sync
.
RWMutex
lock
sync
.
RWMutex
containers
map
[
string
]
Container
containers
map
[
string
]
Container
idIndex
*
truncindex
.
TruncIndex
idIndex
*
truncindex
.
TruncIndex
labels
*
label
.
Store
}
}
// NewStore creates a container store.
// NewStore creates a container store.
func
NewStore
()
*
Store
{
func
NewStore
(
labels
*
label
.
Store
)
*
Store
{
return
&
Store
{
return
&
Store
{
containers
:
make
(
map
[
string
]
Container
),
containers
:
make
(
map
[
string
]
Container
),
idIndex
:
truncindex
.
NewTruncIndex
([]
string
{}),
idIndex
:
truncindex
.
NewTruncIndex
([]
string
{}),
labels
:
labels
,
}
}
}
}
...
@@ -119,6 +122,9 @@ func (s *Store) Add(c Container) error {
...
@@ -119,6 +122,9 @@ func (s *Store) Add(c Container) error {
if
_
,
ok
:=
s
.
containers
[
c
.
ID
];
ok
{
if
_
,
ok
:=
s
.
containers
[
c
.
ID
];
ok
{
return
store
.
ErrAlreadyExist
return
store
.
ErrAlreadyExist
}
}
if
err
:=
s
.
labels
.
Reserve
(
c
.
ProcessLabel
);
err
!=
nil
{
return
err
}
if
err
:=
s
.
idIndex
.
Add
(
c
.
ID
);
err
!=
nil
{
if
err
:=
s
.
idIndex
.
Add
(
c
.
ID
);
err
!=
nil
{
return
err
return
err
}
}
...
@@ -165,6 +171,7 @@ func (s *Store) Delete(id string) {
...
@@ -165,6 +171,7 @@ func (s *Store) Delete(id string) {
// So we need to return if there are error.
// So we need to return if there are error.
return
return
}
}
s
.
labels
.
Release
(
s
.
containers
[
id
]
.
ProcessLabel
)
s
.
idIndex
.
Delete
(
id
)
// nolint: errcheck
s
.
idIndex
.
Delete
(
id
)
// nolint: errcheck
delete
(
s
.
containers
,
id
)
delete
(
s
.
containers
,
id
)
}
}
vendor/github.com/containerd/cri/pkg/store/container/metadata.go
View file @
124def22
...
@@ -61,6 +61,8 @@ type Metadata struct {
...
@@ -61,6 +61,8 @@ type Metadata struct {
// StopSignal is the system call signal that will be sent to the container to exit.
// StopSignal is the system call signal that will be sent to the container to exit.
// TODO(random-liu): Add integration test for stop signal.
// TODO(random-liu): Add integration test for stop signal.
StopSignal
string
StopSignal
string
// ProcessLabel is the SELinux process label for the container
ProcessLabel
string
}
}
// MarshalJSON encodes Metadata into bytes in json format.
// MarshalJSON encodes Metadata into bytes in json format.
...
...
vendor/github.com/containerd/cri/pkg/store/label/label.go
0 → 100644
View file @
124def22
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package
label
import
(
"sync"
"github.com/opencontainers/selinux/go-selinux"
)
type
Store
struct
{
sync
.
Mutex
levels
map
[
string
]
int
Releaser
func
(
string
)
Reserver
func
(
string
)
}
func
NewStore
()
*
Store
{
return
&
Store
{
levels
:
map
[
string
]
int
{},
Releaser
:
selinux
.
ReleaseLabel
,
Reserver
:
selinux
.
ReserveLabel
,
}
}
func
(
s
*
Store
)
Reserve
(
label
string
)
error
{
s
.
Lock
()
defer
s
.
Unlock
()
context
,
err
:=
selinux
.
NewContext
(
label
)
if
err
!=
nil
{
return
err
}
level
:=
context
[
"level"
]
// no reason to count empty
if
level
==
""
{
return
nil
}
if
_
,
ok
:=
s
.
levels
[
level
];
!
ok
{
s
.
Reserver
(
label
)
}
s
.
levels
[
level
]
++
return
nil
}
func
(
s
*
Store
)
Release
(
label
string
)
{
s
.
Lock
()
defer
s
.
Unlock
()
context
,
err
:=
selinux
.
NewContext
(
label
)
if
err
!=
nil
{
return
}
level
:=
context
[
"level"
]
if
level
==
""
{
return
}
count
,
ok
:=
s
.
levels
[
level
]
if
!
ok
{
return
}
switch
{
case
count
==
1
:
s
.
Releaser
(
label
)
delete
(
s
.
levels
,
level
)
case
count
<
1
:
delete
(
s
.
levels
,
level
)
case
count
>
1
:
s
.
levels
[
level
]
=
count
-
1
}
}
vendor/github.com/containerd/cri/pkg/store/sandbox/metadata.go
View file @
124def22
...
@@ -61,6 +61,8 @@ type Metadata struct {
...
@@ -61,6 +61,8 @@ type Metadata struct {
RuntimeHandler
string
RuntimeHandler
string
// CNIresult resulting configuration for attached network namespace interfaces
// CNIresult resulting configuration for attached network namespace interfaces
CNIResult
*
cni
.
CNIResult
CNIResult
*
cni
.
CNIResult
// ProcessLabel is the SELinux process label for the container
ProcessLabel
string
}
}
// MarshalJSON encodes Metadata into bytes in json format.
// MarshalJSON encodes Metadata into bytes in json format.
...
...
vendor/github.com/containerd/cri/pkg/store/sandbox/sandbox.go
View file @
124def22
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"sync"
"sync"
"github.com/containerd/containerd"
"github.com/containerd/containerd"
"github.com/containerd/cri/pkg/store/label"
"github.com/docker/docker/pkg/truncindex"
"github.com/docker/docker/pkg/truncindex"
"github.com/containerd/cri/pkg/netns"
"github.com/containerd/cri/pkg/netns"
...
@@ -62,13 +63,15 @@ type Store struct {
...
@@ -62,13 +63,15 @@ type Store struct {
lock
sync
.
RWMutex
lock
sync
.
RWMutex
sandboxes
map
[
string
]
Sandbox
sandboxes
map
[
string
]
Sandbox
idIndex
*
truncindex
.
TruncIndex
idIndex
*
truncindex
.
TruncIndex
labels
*
label
.
Store
}
}
// NewStore creates a sandbox store.
// NewStore creates a sandbox store.
func
NewStore
()
*
Store
{
func
NewStore
(
labels
*
label
.
Store
)
*
Store
{
return
&
Store
{
return
&
Store
{
sandboxes
:
make
(
map
[
string
]
Sandbox
),
sandboxes
:
make
(
map
[
string
]
Sandbox
),
idIndex
:
truncindex
.
NewTruncIndex
([]
string
{}),
idIndex
:
truncindex
.
NewTruncIndex
([]
string
{}),
labels
:
labels
,
}
}
}
}
...
@@ -79,6 +82,9 @@ func (s *Store) Add(sb Sandbox) error {
...
@@ -79,6 +82,9 @@ func (s *Store) Add(sb Sandbox) error {
if
_
,
ok
:=
s
.
sandboxes
[
sb
.
ID
];
ok
{
if
_
,
ok
:=
s
.
sandboxes
[
sb
.
ID
];
ok
{
return
store
.
ErrAlreadyExist
return
store
.
ErrAlreadyExist
}
}
if
err
:=
s
.
labels
.
Reserve
(
sb
.
ProcessLabel
);
err
!=
nil
{
return
err
}
if
err
:=
s
.
idIndex
.
Add
(
sb
.
ID
);
err
!=
nil
{
if
err
:=
s
.
idIndex
.
Add
(
sb
.
ID
);
err
!=
nil
{
return
err
return
err
}
}
...
@@ -125,6 +131,7 @@ func (s *Store) Delete(id string) {
...
@@ -125,6 +131,7 @@ func (s *Store) Delete(id string) {
// So we need to return if there are error.
// So we need to return if there are error.
return
return
}
}
s
.
labels
.
Release
(
s
.
sandboxes
[
id
]
.
ProcessLabel
)
s
.
idIndex
.
Delete
(
id
)
// nolint: errcheck
s
.
idIndex
.
Delete
(
id
)
// nolint: errcheck
delete
(
s
.
sandboxes
,
id
)
delete
(
s
.
sandboxes
,
id
)
}
}
vendor/modules.txt
View file @
124def22
...
@@ -151,7 +151,7 @@ github.com/container-storage-interface/spec/lib/go/csi
...
@@ -151,7 +151,7 @@ github.com/container-storage-interface/spec/lib/go/csi
github.com/containerd/cgroups
github.com/containerd/cgroups
# github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1 => github.com/containerd/console v0.0.0-20181022165439-0650fd9eeb50
# github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1 => github.com/containerd/console v0.0.0-20181022165439-0650fd9eeb50
github.com/containerd/console
github.com/containerd/console
# github.com/containerd/containerd v1.3.0-beta.2.0.20190828155532-0293cbd26c69 => github.com/rancher/containerd v1.3.3-k3s
1
# github.com/containerd/containerd v1.3.0-beta.2.0.20190828155532-0293cbd26c69 => github.com/rancher/containerd v1.3.3-k3s
2
github.com/containerd/containerd
github.com/containerd/containerd
github.com/containerd/containerd/api/events
github.com/containerd/containerd/api/events
github.com/containerd/containerd/api/services/containers/v1
github.com/containerd/containerd/api/services/containers/v1
...
@@ -288,7 +288,7 @@ github.com/containerd/continuity/pathdriver
...
@@ -288,7 +288,7 @@ github.com/containerd/continuity/pathdriver
github.com/containerd/continuity/proto
github.com/containerd/continuity/proto
github.com/containerd/continuity/syscallx
github.com/containerd/continuity/syscallx
github.com/containerd/continuity/sysx
github.com/containerd/continuity/sysx
# github.com/containerd/cri v0.0.0-00010101000000-000000000000 => github.com/rancher/cri v1.3.0-k3s.
3
# github.com/containerd/cri v0.0.0-00010101000000-000000000000 => github.com/rancher/cri v1.3.0-k3s.
4
github.com/containerd/cri
github.com/containerd/cri
github.com/containerd/cri/pkg/annotations
github.com/containerd/cri/pkg/annotations
github.com/containerd/cri/pkg/api/runtimeoptions/v1
github.com/containerd/cri/pkg/api/runtimeoptions/v1
...
@@ -306,6 +306,7 @@ github.com/containerd/cri/pkg/server/io
...
@@ -306,6 +306,7 @@ github.com/containerd/cri/pkg/server/io
github.com/containerd/cri/pkg/store
github.com/containerd/cri/pkg/store
github.com/containerd/cri/pkg/store/container
github.com/containerd/cri/pkg/store/container
github.com/containerd/cri/pkg/store/image
github.com/containerd/cri/pkg/store/image
github.com/containerd/cri/pkg/store/label
github.com/containerd/cri/pkg/store/sandbox
github.com/containerd/cri/pkg/store/sandbox
github.com/containerd/cri/pkg/store/snapshot
github.com/containerd/cri/pkg/store/snapshot
github.com/containerd/cri/pkg/util
github.com/containerd/cri/pkg/util
...
...
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