daemon: inline some variables when emitting events
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
8d404ac408
commit
10a3a3bc49
8 changed files with 22 additions and 37 deletions
|
@ -21,12 +21,10 @@ func (i *ImageService) LogImageEvent(imageID, refName, action string) {
|
|||
if refName != "" {
|
||||
attributes["name"] = refName
|
||||
}
|
||||
actor := events.Actor{
|
||||
i.eventsService.Log(action, events.ImageEventType, events.Actor{
|
||||
ID: imageID,
|
||||
Attributes: attributes,
|
||||
}
|
||||
|
||||
i.eventsService.Log(action, events.ImageEventType, actor)
|
||||
})
|
||||
}
|
||||
|
||||
// copyAttributes guarantees that labels are not mutated by event triggers.
|
||||
|
|
|
@ -137,11 +137,9 @@ func (daemon *Daemon) ContainerExecCreate(name string, config *types.ExecConfig)
|
|||
}
|
||||
|
||||
daemon.registerExecCommand(cntr, execConfig)
|
||||
|
||||
attributes := map[string]string{
|
||||
daemon.LogContainerEventWithAttributes(cntr, "exec_create: "+execConfig.Entrypoint+" "+strings.Join(execConfig.Args, " "), map[string]string{
|
||||
"execID": execConfig.ID,
|
||||
}
|
||||
daemon.LogContainerEventWithAttributes(cntr, "exec_create: "+execConfig.Entrypoint+" "+strings.Join(execConfig.Args, " "), attributes)
|
||||
})
|
||||
|
||||
return execConfig.ID, nil
|
||||
}
|
||||
|
@ -175,10 +173,9 @@ func (daemon *Daemon) ContainerExecStart(ctx context.Context, name string, optio
|
|||
ec.Unlock()
|
||||
|
||||
log.G(ctx).Debugf("starting exec command %s in container %s", ec.ID, ec.Container.ID)
|
||||
attributes := map[string]string{
|
||||
daemon.LogContainerEventWithAttributes(ec.Container, "exec_start: "+ec.Entrypoint+" "+strings.Join(ec.Args, " "), map[string]string{
|
||||
"execID": ec.ID,
|
||||
}
|
||||
daemon.LogContainerEventWithAttributes(ec.Container, "exec_start: "+ec.Entrypoint+" "+strings.Join(ec.Args, " "), attributes)
|
||||
})
|
||||
|
||||
defer func() {
|
||||
if err != nil {
|
||||
|
@ -311,10 +308,9 @@ func (daemon *Daemon) ContainerExecStart(ctx context.Context, name string, optio
|
|||
if _, ok := err.(term.EscapeError); !ok {
|
||||
return errdefs.System(errors.Wrap(err, "exec attach failed"))
|
||||
}
|
||||
attributes := map[string]string{
|
||||
daemon.LogContainerEventWithAttributes(ec.Container, "exec_detach", map[string]string{
|
||||
"execID": ec.ID,
|
||||
}
|
||||
daemon.LogContainerEventWithAttributes(ec.Container, "exec_detach", attributes)
|
||||
})
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -87,10 +87,9 @@ func (p *cmdProbe) run(ctx context.Context, d *Daemon, cntr *container.Container
|
|||
execConfig.Env = container.ReplaceOrAppendEnvValues(cntr.CreateDaemonEnvironment(execConfig.Tty, linkedEnv), execConfig.Env)
|
||||
|
||||
d.registerExecCommand(cntr, execConfig)
|
||||
attributes := map[string]string{
|
||||
d.LogContainerEventWithAttributes(cntr, "exec_create: "+execConfig.Entrypoint+" "+strings.Join(execConfig.Args, " "), map[string]string{
|
||||
"execID": execConfig.ID,
|
||||
}
|
||||
d.LogContainerEventWithAttributes(cntr, "exec_create: "+execConfig.Entrypoint+" "+strings.Join(execConfig.Args, " "), attributes)
|
||||
})
|
||||
|
||||
output := &limitedBuffer{}
|
||||
probeCtx, cancelProbe := context.WithCancel(ctx)
|
||||
|
|
|
@ -243,18 +243,15 @@ func (i *ImageService) removeImageRef(ref reference.Named) (reference.Named, err
|
|||
// daemon's event service. An "Untagged" types.ImageDeleteResponseItem is added to the
|
||||
// given list of records.
|
||||
func (i *ImageService) removeAllReferencesToImageID(imgID image.ID, records *[]types.ImageDeleteResponseItem) error {
|
||||
imageRefs := i.referenceStore.References(imgID.Digest())
|
||||
|
||||
for _, imageRef := range imageRefs {
|
||||
for _, imageRef := range i.referenceStore.References(imgID.Digest()) {
|
||||
parsedRef, err := i.removeImageRef(imageRef)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
untaggedRecord := types.ImageDeleteResponseItem{Untagged: reference.FamiliarString(parsedRef)}
|
||||
|
||||
i.LogImageEvent(imgID.String(), imgID.String(), "untag")
|
||||
*records = append(*records, untaggedRecord)
|
||||
*records = append(*records, types.ImageDeleteResponseItem{
|
||||
Untagged: reference.FamiliarString(parsedRef),
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -21,12 +21,10 @@ func (i *ImageService) LogImageEvent(imageID, refName, action string) {
|
|||
if refName != "" {
|
||||
attributes["name"] = refName
|
||||
}
|
||||
actor := events.Actor{
|
||||
i.eventsService.Log(action, events.ImageEventType, events.Actor{
|
||||
ID: imageID,
|
||||
Attributes: attributes,
|
||||
}
|
||||
|
||||
i.eventsService.Log(action, events.ImageEventType, actor)
|
||||
})
|
||||
}
|
||||
|
||||
// copyAttributes guarantees that labels are not mutated by event triggers.
|
||||
|
|
|
@ -219,11 +219,10 @@ func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei
|
|||
}()
|
||||
}
|
||||
}
|
||||
attributes := map[string]string{
|
||||
daemon.LogContainerEventWithAttributes(c, "exec_die", map[string]string{
|
||||
"execID": ei.ProcessID,
|
||||
"exitCode": strconv.Itoa(exitCode),
|
||||
}
|
||||
daemon.LogContainerEventWithAttributes(c, "exec_die", attributes)
|
||||
})
|
||||
case libcontainerdtypes.EventStart:
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
|
|
|
@ -25,11 +25,10 @@ func (daemon *Daemon) ContainerResize(name string, height, width int) error {
|
|||
}
|
||||
|
||||
if err = tsk.Resize(context.Background(), uint32(width), uint32(height)); err == nil {
|
||||
attributes := map[string]string{
|
||||
daemon.LogContainerEventWithAttributes(container, "resize", map[string]string{
|
||||
"height": strconv.Itoa(height),
|
||||
"width": strconv.Itoa(width),
|
||||
}
|
||||
daemon.LogContainerEventWithAttributes(container, "resize", attributes)
|
||||
})
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -73,14 +73,13 @@ func (daemon *Daemon) setupMounts(c *container.Container) ([]container.Mount, er
|
|||
mnt.ReadOnlyForceRecursive = m.Spec.BindOptions.ReadOnlyForceRecursive
|
||||
}
|
||||
if m.Volume != nil {
|
||||
attributes := map[string]string{
|
||||
daemon.LogVolumeEvent(m.Volume.Name(), "mount", map[string]string{
|
||||
"driver": m.Volume.DriverName(),
|
||||
"container": c.ID,
|
||||
"destination": m.Destination,
|
||||
"read/write": strconv.FormatBool(m.RW),
|
||||
"propagation": string(m.Propagation),
|
||||
}
|
||||
daemon.LogVolumeEvent(m.Volume.Name(), "mount", attributes)
|
||||
})
|
||||
}
|
||||
mounts = append(mounts, mnt)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue