@@ -321,16 +321,30 @@ func (c *containerdClient) runIPTablesCommands(ctx context.Context, containerID
321321 return nil
322322}
323323
324- // StressContainer runs stress-ng inside a container.
324+ // StressContainer runs stress-ng to stress a container.
325+ // Mode selection:
326+ // - image == "": direct exec inside the target container
327+ // - image != "" && !injectCgroup: sidecar with /stress-ng in target's cgroup parent
328+ // - image != "" && injectCgroup: sidecar with /cg-inject injecting into target's cgroup
325329func (c * containerdClient ) StressContainer (ctx context.Context , container * ctr.Container ,
326330 stressors []string , image string , pull bool , duration time.Duration , injectCgroup , dryrun bool ) (string , <- chan string , <- chan error , error ) {
327- log .WithField ("id" , container .ID ()).Debug ("stress on containerd container" )
328- if image != "" || pull || injectCgroup {
329- log .WithField ("id" , container .ID ()).Warn ("containerd runtime: sidecar/inject-cgroup stress modes not supported, using direct exec" )
330- }
331+ log .WithFields (log.Fields {
332+ "id" : container .ID (),
333+ "image" : image ,
334+ "inject-cgroup" : injectCgroup ,
335+ }).Debug ("stress on containerd container" )
331336 if dryrun {
332337 return "" , nil , nil , nil
333338 }
339+ if image != "" {
340+ return c .stressSidecar (ctx , container , image , stressors , injectCgroup , pull )
341+ }
342+ return c .stressDirectExec (ctx , container , stressors , duration )
343+ }
344+
345+ // stressDirectExec runs stress-ng directly inside the target container via exec.
346+ func (c * containerdClient ) stressDirectExec (ctx context.Context , container * ctr.Container ,
347+ stressors []string , duration time.Duration ) (string , <- chan string , <- chan error , error ) {
334348 errCh := make (chan error , 1 )
335349 outCh := make (chan string , 1 )
336350 go func () {
0 commit comments