@@ -41,6 +41,8 @@ import (
4141type Config struct {
4242 // Supported platforms
4343 Platforms []string `toml:"platforms"`
44+ // SchedCore enabled linux core scheduling
45+ SchedCore bool `toml:"sched_core"`
4446}
4547
4648func init () {
@@ -55,7 +57,8 @@ func init() {
5557 Platforms : defaultPlatforms (),
5658 },
5759 InitFn : func (ic * plugin.InitContext ) (interface {}, error ) {
58- supportedPlatforms , err := parsePlatforms (ic .Config .(* Config ).Platforms )
60+ config := ic .Config .(* Config )
61+ supportedPlatforms , err := parsePlatforms (config .Platforms )
5962 if err != nil {
6063 return nil , err
6164 }
@@ -78,26 +81,45 @@ func init() {
7881 cs := metadata .NewContainerStore (m .(* metadata.DB ))
7982 events := ep .(* exchange.Exchange )
8083
81- return New (ic .Context , ic .Root , ic .State , ic .Address , ic .TTRPCAddress , events , cs )
84+ return New (ic .Context , & ManagerConfig {
85+ Root : ic .Root ,
86+ State : ic .State ,
87+ Address : ic .Address ,
88+ TTRPCAddress : ic .TTRPCAddress ,
89+ Events : events ,
90+ Store : cs ,
91+ SchedCore : config .SchedCore ,
92+ })
8293 },
8394 })
8495}
8596
97+ type ManagerConfig struct {
98+ Root string
99+ State string
100+ Store containers.Store
101+ Events * exchange.Exchange
102+ Address string
103+ TTRPCAddress string
104+ SchedCore bool
105+ }
106+
86107// New task manager for v2 shims
87- func New (ctx context.Context , root , state , containerdAddress , containerdTTRPCAddress string , events * exchange. Exchange , cs containers. Store ) (* TaskManager , error ) {
88- for _ , d := range []string {root , state } {
108+ func New (ctx context.Context , config * ManagerConfig ) (* TaskManager , error ) {
109+ for _ , d := range []string {config . Root , config . State } {
89110 if err := os .MkdirAll (d , 0711 ); err != nil {
90111 return nil , err
91112 }
92113 }
93114 m := & TaskManager {
94- root : root ,
95- state : state ,
96- containerdAddress : containerdAddress ,
97- containerdTTRPCAddress : containerdTTRPCAddress ,
115+ root : config .Root ,
116+ state : config .State ,
117+ containerdAddress : config .Address ,
118+ containerdTTRPCAddress : config .TTRPCAddress ,
119+ schedCore : config .SchedCore ,
98120 tasks : runtime .NewTaskList (),
99- events : events ,
100- containers : cs ,
121+ events : config . Events ,
122+ containers : config . Store ,
101123 }
102124 if err := m .loadExistingTasks (ctx ); err != nil {
103125 return nil , err
@@ -111,6 +133,7 @@ type TaskManager struct {
111133 state string
112134 containerdAddress string
113135 containerdTTRPCAddress string
136+ schedCore bool
114137
115138 tasks * runtime.TaskList
116139 events * exchange.Exchange
@@ -167,7 +190,12 @@ func (m *TaskManager) startShim(ctx context.Context, bundle *Bundle, id string,
167190 topts = opts .RuntimeOptions
168191 }
169192
170- b := shimBinary (bundle , opts .Runtime , m .containerdAddress , m .containerdTTRPCAddress )
193+ b := shimBinary (bundle , shimBinaryConfig {
194+ runtime : opts .Runtime ,
195+ address : m .containerdAddress ,
196+ ttrpcAddress : m .containerdTTRPCAddress ,
197+ schedCore : m .schedCore ,
198+ })
171199 shim , err := b .Start (ctx , topts , func () {
172200 log .G (ctx ).WithField ("id" , id ).Info ("shim disconnected" )
173201
@@ -303,7 +331,13 @@ func (m *TaskManager) loadTasks(ctx context.Context) error {
303331 bundle .Delete ()
304332 continue
305333 }
306- binaryCall := shimBinary (bundle , container .Runtime .Name , m .containerdAddress , m .containerdTTRPCAddress )
334+ binaryCall := shimBinary (bundle ,
335+ shimBinaryConfig {
336+ runtime : container .Runtime .Name ,
337+ address : m .containerdAddress ,
338+ ttrpcAddress : m .containerdTTRPCAddress ,
339+ schedCore : m .schedCore ,
340+ })
307341 shim , err := loadShim (ctx , bundle , func () {
308342 log .G (ctx ).WithField ("id" , id ).Info ("shim disconnected" )
309343
0 commit comments