Skip to content

Commit

Permalink
feature: make lxcfs configurable supportd in CRI
Browse files Browse the repository at this point in the history
Signed-off-by: Starnop <[email protected]>
  • Loading branch information
starnop committed Sep 7, 2018
1 parent 258ea08 commit 2159116
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cri/annotations/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ const (

// KubernetesRuntime is the runtime
KubernetesRuntime = "io.kubernetes.runtime"

// LxcfsEnabled whether to enable lxcfs for a container
LxcfsEnabled = "io.kubernetes.lxcfs.enabled"
)
10 changes: 10 additions & 0 deletions cri/v1alpha2/cri.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"path/filepath"
"reflect"
goruntime "runtime"
"strconv"
"time"

apitypes "github.com/alibaba/pouch/apis/types"
Expand Down Expand Up @@ -279,6 +280,15 @@ func (c *CriManager) RunPodSandbox(ctx context.Context, r *runtime.RunPodSandbox
NetNSPath: netnsPath,
Runtime: config.Annotations[anno.KubernetesRuntime],
}

if _, ok := config.Annotations[anno.LxcfsEnabled]; ok {
enableLxcfs, err := strconv.ParseBool(config.Annotations[anno.LxcfsEnabled])
if err != nil {
return nil, err
}
sandboxMeta.LxcfsEnabled = enableLxcfs
}

if err := c.SandboxStore.Put(sandboxMeta); err != nil {
return nil, err
}
Expand Down
3 changes: 3 additions & 0 deletions cri/v1alpha2/cri_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ type SandboxMeta struct {

// Runtime is the runtime of sandbox
Runtime string

// Runtime whether to enable lxcfs for a container
LxcfsEnabled bool
}

// Key returns sandbox's id.
Expand Down
2 changes: 2 additions & 0 deletions cri/v1alpha2/cri_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,8 @@ func (c *CriManager) updateCreateConfig(createConfig *apitypes.ContainerCreateCo
createConfig.HostConfig.Runtime = sandboxMeta.Runtime
}

createConfig.HostConfig.EnableLxcfs = sandboxMeta.LxcfsEnabled

if lc := config.GetLinux(); lc != nil {
resources := lc.GetResources()
if resources != nil {
Expand Down

0 comments on commit 2159116

Please sign in to comment.