Skip to content

Commit b2d9db2

Browse files
committed
windows: Use runtime event topic constants
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
1 parent 5c8e0ef commit b2d9db2

File tree

2 files changed

+47
-40
lines changed

2 files changed

+47
-40
lines changed

windows/runtime.go

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,13 @@ func (r *windowsRuntime) Delete(ctx context.Context, t runtime.Task) (*runtime.E
194194
wt.cleanup()
195195
r.tasks.Delete(ctx, t)
196196

197-
r.emitter.Post(events.WithTopic(ctx, "/tasks/delete"), &eventsapi.TaskDelete{
198-
ContainerID: wt.id,
199-
Pid: wt.pid,
200-
ExitStatus: rtExit.Status,
201-
ExitedAt: rtExit.Timestamp,
202-
})
197+
r.emitter.Post(events.WithTopic(ctx, runtime.TaskDeleteEventTopic),
198+
&eventsapi.TaskDelete{
199+
ContainerID: wt.id,
200+
Pid: wt.pid,
201+
ExitStatus: rtExit.Status,
202+
ExitedAt: rtExit.Timestamp,
203+
})
203204

204205
if needServicing {
205206
ns, _ := namespaces.Namespace(ctx)
@@ -311,18 +312,19 @@ func (r *windowsRuntime) newTask(ctx context.Context, namespace, id string, spec
311312
})
312313
}
313314

314-
r.emitter.Post(events.WithTopic(ctx, "/tasks/create"), &eventsapi.TaskCreate{
315-
ContainerID: id,
316-
IO: &eventsapi.TaskIO{
317-
Stdin: io.Stdin,
318-
Stdout: io.Stdout,
319-
Stderr: io.Stderr,
320-
Terminal: io.Terminal,
321-
},
322-
Pid: t.pid,
323-
Rootfs: rootfs,
324-
// TODO: what should be in Bundle for windows?
325-
})
315+
r.emitter.Post(events.WithTopic(ctx, runtime.TaskCreateEventTopic),
316+
&eventsapi.TaskCreate{
317+
ContainerID: id,
318+
IO: &eventsapi.TaskIO{
319+
Stdin: io.Stdin,
320+
Stdout: io.Stdout,
321+
Stderr: io.Stderr,
322+
Terminal: io.Terminal,
323+
},
324+
Pid: t.pid,
325+
Rootfs: rootfs,
326+
// TODO: what should be in Bundle for windows?
327+
})
326328

327329
return t, nil
328330
}

windows/task.go

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ func (t *task) Start(ctx context.Context) error {
112112
return err
113113
}
114114

115-
t.emitter.Post(events.WithTopic(ctx, "/tasks/start"), &eventsapi.TaskStart{
116-
ContainerID: t.id,
117-
Pid: t.pid,
118-
})
115+
t.emitter.Post(events.WithTopic(ctx, runtime.TaskStartEventTopic),
116+
&eventsapi.TaskStart{
117+
ContainerID: t.id,
118+
Pid: t.pid,
119+
})
119120

120121
return nil
121122
}
@@ -129,9 +130,10 @@ func (t *task) Pause(ctx context.Context) error {
129130
t.Unlock()
130131
}
131132
if err == nil {
132-
t.emitter.Post(events.WithTopic(ctx, "/tasks/paused"), &eventsapi.TaskPaused{
133-
ContainerID: t.id,
134-
})
133+
t.emitter.Post(events.WithTopic(ctx, runtime.TaskPausedEventTopic),
134+
&eventsapi.TaskPaused{
135+
ContainerID: t.id,
136+
})
135137
}
136138
return errors.Wrap(err, "hcsshim failed to pause task")
137139
}
@@ -148,9 +150,10 @@ func (t *task) Resume(ctx context.Context) error {
148150
t.Unlock()
149151
}
150152
if err == nil {
151-
t.emitter.Post(events.WithTopic(ctx, "/tasks/resumed"), &eventsapi.TaskResumed{
152-
ContainerID: t.id,
153-
})
153+
t.emitter.Post(events.WithTopic(ctx, runtime.TaskResumedEventTopic),
154+
&eventsapi.TaskResumed{
155+
ContainerID: t.id,
156+
})
154157
}
155158
return errors.Wrap(err, "hcsshim failed to resume task")
156159
}
@@ -192,11 +195,12 @@ func (t *task) Exec(ctx context.Context, id string, opts runtime.ExecOpts) (runt
192195
return nil, err
193196
}
194197

195-
t.emitter.Post(events.WithTopic(ctx, "/tasks/exec-added"), &eventsapi.TaskExecAdded{
196-
ContainerID: t.id,
197-
ExecID: id,
198-
Pid: p.Pid(),
199-
})
198+
t.emitter.Post(events.WithTopic(ctx, runtime.TaskExecAddedEventTopic),
199+
&eventsapi.TaskExecAdded{
200+
ContainerID: t.id,
201+
ExecID: id,
202+
Pid: p.Pid(),
203+
})
200204

201205
return p, nil
202206
}
@@ -354,13 +358,14 @@ func (t *task) newProcess(ctx context.Context, id string, conf *hcsshim.ProcessC
354358
}
355359
wp.exitCode = uint32(ec)
356360

357-
t.emitter.Post(events.WithTopic(ctx, "/tasks/exit"), &eventsapi.TaskExit{
358-
ContainerID: t.id,
359-
ID: id,
360-
Pid: pid,
361-
ExitStatus: wp.exitCode,
362-
ExitedAt: wp.exitTime,
363-
})
361+
t.emitter.Post(events.WithTopic(ctx, runtime.TaskExitEventTopic),
362+
&eventsapi.TaskExit{
363+
ContainerID: t.id,
364+
ID: id,
365+
Pid: pid,
366+
ExitStatus: wp.exitCode,
367+
ExitedAt: wp.exitTime,
368+
})
364369

365370
close(wp.exitCh)
366371
// Ensure io's are closed

0 commit comments

Comments
 (0)