Skip to content

Commit 2ef0aea

Browse files
author
zhangyue
committed
fix: add more events
Signed-off-by: zhangyue <[email protected]>
1 parent 7ff4bc0 commit 2ef0aea

File tree

8 files changed

+18
-5
lines changed

8 files changed

+18
-5
lines changed

daemon/mgr/container.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,8 @@ func (mgr *ContainerManager) Restart(ctx context.Context, name string, timeout i
980980
c.RestartCount++
981981

982982
logrus.Debugf("container %s restartCount is %d", c.ID, c.RestartCount)
983+
mgr.LogContainerEvent(ctx, c, "restart")
984+
983985
return c.Write(mgr.Store)
984986
}
985987

@@ -1445,6 +1447,7 @@ func (mgr *ContainerManager) Top(ctx context.Context, name string, psArgs string
14451447
if err != nil {
14461448
return nil, errors.Wrapf(err, "failed parsePSOutput")
14471449
}
1450+
mgr.LogContainerEvent(ctx, c, "top")
14481451

14491452
return procList, nil
14501453
}
@@ -1463,6 +1466,7 @@ func (mgr *ContainerManager) Resize(ctx context.Context, name string, opts types
14631466
return fmt.Errorf("failed to resize container %s: container is not running", c.ID)
14641467
}
14651468

1469+
mgr.LogContainerEvent(ctx, c, "resize")
14661470
return mgr.Client.ResizeContainer(ctx, c.ID, opts)
14671471
}
14681472

daemon/mgr/container_commit.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func (mgr *ContainerManager) Commit(ctx context.Context, name string, options *t
8080
// pouch can see the new image reference.
8181
logrus.Warnf("failed to update image store: %s", err)
8282
}
83+
mgr.LogContainerEvent(ctx, c, "commit")
8384

8485
// return 12 bits image id as a result
8586
imageID := imageDigest.Hex()

daemon/mgr/container_copy.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ func (mgr *ContainerManager) ArchivePath(ctx context.Context, name, path string)
154154
c.Unlock()
155155
return err
156156
})
157+
mgr.LogContainerEvent(ctx, c, "archive-path")
157158

158159
return content, stat, nil
159160
}
@@ -224,6 +225,8 @@ func (mgr *ContainerManager) ExtractToDir(ctx context.Context, name, path string
224225
NoOverwriteDirNonDir: noOverwriteDirNonDir,
225226
}
226227

228+
mgr.LogContainerEvent(ctx, c, "extract-to-dir")
229+
227230
return chrootarchive.Untar(content, resolvedPath, opts)
228231
}
229232

daemon/mgr/container_exec.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (mgr *ContainerManager) CreateExec(ctx context.Context, name string, config
4343
}
4444

4545
mgr.ExecProcesses.Put(execid, execConfig)
46-
46+
mgr.LogContainerEvent(ctx, c, "exec_create")
4747
return execid, nil
4848
}
4949

@@ -164,6 +164,7 @@ func (mgr *ContainerManager) StartExec(ctx context.Context, execid string, cfg *
164164
}); err != nil {
165165
return err
166166
}
167+
mgr.LogContainerEvent(ctx, c, "exec_start")
167168
return <-attachErrCh
168169
}
169170

daemon/mgr/image.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func (mgr *ImageManager) PushImage(ctx context.Context, name, tag string, authCo
263263
} else {
264264
ref = reference.WithTag(ref, tag)
265265
}
266-
266+
mgr.LogImageEvent(ctx, ref.String(), ref.String(), "push")
267267
return mgr.client.PushImage(ctx, ref.String(), authConfig, out)
268268
}
269269

@@ -458,7 +458,7 @@ func (mgr *ImageManager) RemoveImage(ctx context.Context, idOrRef string, force
458458
// the searchable reference has different locator without force.
459459
// It's different reference from locator aspect.
460460
if !force && !uniqueLocatorReference(mgr.localStore.GetReferences(id)) {
461-
return fmt.Errorf("Unable to remove the image %q (must force) - image has serveral references", idOrRef)
461+
return fmt.Errorf("unable to remove the image %q (must force) - image has serveral references", idOrRef)
462462
}
463463

464464
for _, ref := range mgr.localStore.GetPrimaryReferences(id) {
@@ -479,7 +479,7 @@ func (mgr *ImageManager) RemoveImage(ctx context.Context, idOrRef string, force
479479
if err := mgr.localStore.RemoveReference(id, primaryRef); err != nil {
480480
return err
481481
}
482-
482+
mgr.LogImageEvent(ctx, namedRef.String(), namedRef.String(), "delete")
483483
return mgr.client.RemoveImage(ctx, primaryRef.String())
484484
}
485485

@@ -530,6 +530,7 @@ func (mgr *ImageManager) AddTag(ctx context.Context, sourceImage string, targetT
530530
Name: tagRef.String(),
531531
Target: ctrdImg.Target(),
532532
})
533+
mgr.LogImageEvent(ctx, sourceImage, tagRef.String(), "tag")
533534
return err
534535
}
535536

daemon/mgr/image_load.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,6 @@ func (mgr *ImageManager) LoadImage(ctx context.Context, imageName string, tarstr
6262
if merrs.Size() != 0 {
6363
return fmt.Errorf("fails to load image: %v", merrs.Error())
6464
}
65+
mgr.LogImageEvent(ctx, imageName, imageName, "load")
6566
return nil
6667
}

daemon/mgr/image_save.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func (mgr *ImageManager) SaveImage(ctx context.Context, idOrRef string) (io.Read
1818
if err != nil {
1919
return nil, err
2020
}
21+
mgr.LogImageEvent(ctx, idOrRef, ref.String(), "save")
2122

2223
return exportedStream, nil
2324
}

daemon/mgr/volume.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ func (vm *VolumeManager) Attach(ctx context.Context, name string, options map[st
185185
}
186186
}
187187

188+
vm.LogVolumeEvent(ctx, name, "attach", map[string]string{"driver": v.Driver()})
188189
return vm.core.AttachVolume(id, options)
189190
}
190191

@@ -220,6 +221,6 @@ func (vm *VolumeManager) Detach(ctx context.Context, name string, options map[st
220221
}
221222
}
222223
}
223-
224+
vm.LogVolumeEvent(ctx, name, "detach", map[string]string{"driver": v.Driver()})
224225
return vm.core.DetachVolume(id, options)
225226
}

0 commit comments

Comments
 (0)