Skip to content

Commit fe4e30c

Browse files
authored
Merge pull request containerd#1859 from dmcgowan/fix-snapshot-logs
Update snapshot and content related log messages
2 parents 53c892d + b28d7cd commit fe4e30c

File tree

9 files changed

+36
-32
lines changed

9 files changed

+36
-32
lines changed

metadata/db.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func (m *DB) Init(ctx context.Context) error {
138138
if err := m.migrate(tx); err != nil {
139139
return errors.Wrapf(err, "failed to migrate to %s.%d", m.schema, m.version)
140140
}
141-
log.G(ctx).WithField("d", time.Now().Sub(t0)).Debugf("database migration to %s.%d finished", m.schema, m.version)
141+
log.G(ctx).WithField("d", time.Now().Sub(t0)).Debugf("finished database migration to %s.%d", m.schema, m.version)
142142
}
143143
}
144144

@@ -269,7 +269,7 @@ func (m *DB) GarbageCollect(ctx context.Context) (stats GCStats, err error) {
269269
stats.SnapshotD = map[string]time.Duration{}
270270
wg.Add(len(m.dirtySS))
271271
for snapshotterName := range m.dirtySS {
272-
log.G(ctx).WithField("snapshotter", snapshotterName).Debug("scheduling snapshotter cleanup")
272+
log.G(ctx).WithField("snapshotter", snapshotterName).Debug("schedule snapshotter cleanup")
273273
go func(snapshotterName string) {
274274
st1 := time.Now()
275275
m.cleanupSnapshotter(snapshotterName)
@@ -286,7 +286,7 @@ func (m *DB) GarbageCollect(ctx context.Context) (stats GCStats, err error) {
286286

287287
if m.dirtyCS {
288288
wg.Add(1)
289-
log.G(ctx).Debug("scheduling content cleanup")
289+
log.G(ctx).Debug("schedule content cleanup")
290290
go func() {
291291
ct1 := time.Now()
292292
m.cleanupContent()

metadata/gc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ func remove(ctx context.Context, tx *bolt.Tx, node gc.Node) error {
301301
cbkt = cbkt.Bucket(bucketKeyObjectBlob)
302302
}
303303
if cbkt != nil {
304-
log.G(ctx).WithField("key", node.Key).Debug("delete content")
304+
log.G(ctx).WithField("key", node.Key).Debug("remove content")
305305
return cbkt.DeleteBucket([]byte(node.Key))
306306
}
307307
case ResourceSnapshot:
@@ -313,7 +313,7 @@ func remove(ctx context.Context, tx *bolt.Tx, node gc.Node) error {
313313
}
314314
ssbkt := sbkt.Bucket([]byte(parts[0]))
315315
if ssbkt != nil {
316-
log.G(ctx).WithField("key", parts[1]).WithField("snapshotter", parts[0]).Debug("delete snapshot")
316+
log.G(ctx).WithField("key", parts[1]).WithField("snapshotter", parts[0]).Debug("remove snapshot")
317317
return ssbkt.DeleteBucket([]byte(parts[1]))
318318
}
319319
}

metadata/snapshot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ func (s *snapshotter) pruneBranch(ctx context.Context, node *treeNode) error {
723723
if !errdefs.IsFailedPrecondition(err) {
724724
return err
725725
}
726-
logger.WithError(err).WithField("key", node.info.Name).Warnf("snapshot removal failed")
726+
logger.WithError(err).WithField("key", node.info.Name).Warnf("failed to remove snapshot")
727727
} else {
728728
logger.WithField("key", node.info.Name).Debug("removed snapshot")
729729
}

services/content/service.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ func (s *service) List(req *api.ListContentRequest, session api.Content_ListServ
141141
}
142142

143143
func (s *service) Delete(ctx context.Context, req *api.DeleteContentRequest) (*ptypes.Empty, error) {
144+
log.G(ctx).WithField("digest", req.Digest).Debugf("delete content")
144145
if err := req.Digest.Validate(); err != nil {
145146
return nil, status.Errorf(codes.InvalidArgument, err.Error())
146147
}

services/images/service.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/containerd/containerd/errdefs"
1010
"github.com/containerd/containerd/events"
1111
"github.com/containerd/containerd/images"
12+
"github.com/containerd/containerd/log"
1213
"github.com/containerd/containerd/metadata"
1314
"github.com/containerd/containerd/plugin"
1415
ptypes "github.com/gogo/protobuf/types"
@@ -94,6 +95,7 @@ func (s *service) List(ctx context.Context, req *imagesapi.ListImagesRequest) (*
9495
}
9596

9697
func (s *service) Create(ctx context.Context, req *imagesapi.CreateImageRequest) (*imagesapi.CreateImageResponse, error) {
98+
log.G(ctx).WithField("name", req.Image.Name).WithField("target", req.Image.Target.Digest).Debugf("create image")
9799
if req.Image.Name == "" {
98100
return nil, status.Errorf(codes.InvalidArgument, "Image.Name required")
99101
}
@@ -164,6 +166,7 @@ func (s *service) Update(ctx context.Context, req *imagesapi.UpdateImageRequest)
164166
}
165167

166168
func (s *service) Delete(ctx context.Context, req *imagesapi.DeleteImageRequest) (*ptypes.Empty, error) {
169+
log.G(ctx).WithField("name", req.Name).Debugf("delete image")
167170
if err := s.withStoreUpdate(ctx, func(ctx context.Context, store images.Store) error {
168171
return errdefs.ToGRPC(store.Delete(ctx, req.Name))
169172
}); err != nil {

services/snapshots/service.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (s *service) Register(gs *grpc.Server) error {
6666
}
6767

6868
func (s *service) Prepare(ctx context.Context, pr *snapshotsapi.PrepareSnapshotRequest) (*snapshotsapi.PrepareSnapshotResponse, error) {
69-
log.G(ctx).WithField("parent", pr.Parent).WithField("key", pr.Key).Debugf("Preparing snapshot")
69+
log.G(ctx).WithField("parent", pr.Parent).WithField("key", pr.Key).Debugf("prepare snapshot")
7070
sn, err := s.getSnapshotter(pr.Snapshotter)
7171
if err != nil {
7272
return nil, err
@@ -93,7 +93,7 @@ func (s *service) Prepare(ctx context.Context, pr *snapshotsapi.PrepareSnapshotR
9393
}
9494

9595
func (s *service) View(ctx context.Context, pr *snapshotsapi.ViewSnapshotRequest) (*snapshotsapi.ViewSnapshotResponse, error) {
96-
log.G(ctx).WithField("parent", pr.Parent).WithField("key", pr.Key).Debugf("Preparing view snapshot")
96+
log.G(ctx).WithField("parent", pr.Parent).WithField("key", pr.Key).Debugf("prepare view snapshot")
9797
sn, err := s.getSnapshotter(pr.Snapshotter)
9898
if err != nil {
9999
return nil, err
@@ -112,7 +112,7 @@ func (s *service) View(ctx context.Context, pr *snapshotsapi.ViewSnapshotRequest
112112
}
113113

114114
func (s *service) Mounts(ctx context.Context, mr *snapshotsapi.MountsRequest) (*snapshotsapi.MountsResponse, error) {
115-
log.G(ctx).WithField("key", mr.Key).Debugf("Getting snapshot mounts")
115+
log.G(ctx).WithField("key", mr.Key).Debugf("get snapshot mounts")
116116
sn, err := s.getSnapshotter(mr.Snapshotter)
117117
if err != nil {
118118
return nil, err
@@ -128,7 +128,7 @@ func (s *service) Mounts(ctx context.Context, mr *snapshotsapi.MountsRequest) (*
128128
}
129129

130130
func (s *service) Commit(ctx context.Context, cr *snapshotsapi.CommitSnapshotRequest) (*ptypes.Empty, error) {
131-
log.G(ctx).WithField("key", cr.Key).WithField("name", cr.Name).Debugf("Committing snapshot")
131+
log.G(ctx).WithField("key", cr.Key).WithField("name", cr.Name).Debugf("commit snapshot")
132132
sn, err := s.getSnapshotter(cr.Snapshotter)
133133
if err != nil {
134134
return nil, err
@@ -152,7 +152,7 @@ func (s *service) Commit(ctx context.Context, cr *snapshotsapi.CommitSnapshotReq
152152
}
153153

154154
func (s *service) Remove(ctx context.Context, rr *snapshotsapi.RemoveSnapshotRequest) (*ptypes.Empty, error) {
155-
log.G(ctx).WithField("key", rr.Key).Debugf("Removing snapshot")
155+
log.G(ctx).WithField("key", rr.Key).Debugf("remove snapshot")
156156
sn, err := s.getSnapshotter(rr.Snapshotter)
157157
if err != nil {
158158
return nil, err
@@ -171,7 +171,7 @@ func (s *service) Remove(ctx context.Context, rr *snapshotsapi.RemoveSnapshotReq
171171
}
172172

173173
func (s *service) Stat(ctx context.Context, sr *snapshotsapi.StatSnapshotRequest) (*snapshotsapi.StatSnapshotResponse, error) {
174-
log.G(ctx).WithField("key", sr.Key).Debugf("Statting snapshot")
174+
log.G(ctx).WithField("key", sr.Key).Debugf("stat snapshot")
175175
sn, err := s.getSnapshotter(sr.Snapshotter)
176176
if err != nil {
177177
return nil, err
@@ -186,7 +186,7 @@ func (s *service) Stat(ctx context.Context, sr *snapshotsapi.StatSnapshotRequest
186186
}
187187

188188
func (s *service) Update(ctx context.Context, sr *snapshotsapi.UpdateSnapshotRequest) (*snapshotsapi.UpdateSnapshotResponse, error) {
189-
log.G(ctx).WithField("key", sr.Info.Name).Debugf("Updating snapshot")
189+
log.G(ctx).WithField("key", sr.Info.Name).Debugf("update snapshot")
190190
sn, err := s.getSnapshotter(sr.Snapshotter)
191191
if err != nil {
192192
return nil, err

snapshots/btrfs/btrfs.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func (b *snapshotter) makeSnapshot(ctx context.Context, kind snapshots.Kind, key
168168
defer func() {
169169
if err != nil && t != nil {
170170
if rerr := t.Rollback(); rerr != nil {
171-
log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction")
171+
log.G(ctx).WithError(rerr).Warn("failed to rollback transaction")
172172
}
173173
}
174174
}()
@@ -203,7 +203,7 @@ func (b *snapshotter) makeSnapshot(ctx context.Context, kind snapshots.Kind, key
203203
t = nil
204204
if err != nil {
205205
if derr := btrfs.SubvolDelete(target); derr != nil {
206-
log.G(ctx).WithError(derr).WithField("subvolume", target).Error("Failed to delete subvolume")
206+
log.G(ctx).WithError(derr).WithField("subvolume", target).Error("failed to delete subvolume")
207207
}
208208
return nil, err
209209
}
@@ -245,7 +245,7 @@ func (b *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap
245245
defer func() {
246246
if err != nil && t != nil {
247247
if rerr := t.Rollback(); rerr != nil {
248-
log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction")
248+
log.G(ctx).WithError(rerr).Warn("failed to rollback transaction")
249249
}
250250
}
251251
}()
@@ -266,14 +266,14 @@ func (b *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap
266266
t = nil
267267
if err != nil {
268268
if derr := btrfs.SubvolDelete(target); derr != nil {
269-
log.G(ctx).WithError(derr).WithField("subvolume", target).Error("Failed to delete subvolume")
269+
log.G(ctx).WithError(derr).WithField("subvolume", target).Error("failed to delete subvolume")
270270
}
271271
return err
272272
}
273273

274274
if derr := btrfs.SubvolDelete(source); derr != nil {
275275
// Log as warning, only needed for cleanup, will not cause name collision
276-
log.G(ctx).WithError(derr).WithField("subvolume", source).Warn("Failed to delete subvolume")
276+
log.G(ctx).WithError(derr).WithField("subvolume", source).Warn("failed to delete subvolume")
277277
}
278278

279279
return nil
@@ -313,13 +313,13 @@ func (b *snapshotter) Remove(ctx context.Context, key string) (err error) {
313313
defer func() {
314314
if err != nil && t != nil {
315315
if rerr := t.Rollback(); rerr != nil {
316-
log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction")
316+
log.G(ctx).WithError(rerr).Warn("failed to rollback transaction")
317317
}
318318
}
319319

320320
if removed != "" {
321321
if derr := btrfs.SubvolDelete(removed); derr != nil {
322-
log.G(ctx).WithError(derr).WithField("subvolume", removed).Warn("Failed to delete subvolume")
322+
log.G(ctx).WithError(derr).WithField("subvolume", removed).Warn("failed to delete subvolume")
323323
}
324324
}
325325
}()
@@ -361,7 +361,7 @@ func (b *snapshotter) Remove(ctx context.Context, key string) (err error) {
361361
logrus.ErrorKey: err1,
362362
"subvolume": source,
363363
"renamed": removed,
364-
}).Error("Failed to restore subvolume from renamed")
364+
}).Error("failed to restore subvolume from renamed")
365365
// Keep removed to allow for manual restore
366366
removed = ""
367367
}

snapshots/naive/naive.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap
157157

158158
if _, err := storage.CommitActive(ctx, key, name, snapshots.Usage(usage), opts...); err != nil {
159159
if rerr := t.Rollback(); rerr != nil {
160-
log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction")
160+
log.G(ctx).WithError(rerr).Warn("failed to rollback transaction")
161161
}
162162
return errors.Wrap(err, "failed to commit snapshot")
163163
}
@@ -174,7 +174,7 @@ func (o *snapshotter) Remove(ctx context.Context, key string) (err error) {
174174
defer func() {
175175
if err != nil && t != nil {
176176
if rerr := t.Rollback(); rerr != nil {
177-
log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction")
177+
log.G(ctx).WithError(rerr).Warn("failed to rollback transaction")
178178
}
179179
}
180180
}()
@@ -199,15 +199,15 @@ func (o *snapshotter) Remove(ctx context.Context, key string) (err error) {
199199
if renamed != "" {
200200
if err1 := os.Rename(renamed, path); err1 != nil {
201201
// May cause inconsistent data on disk
202-
log.G(ctx).WithError(err1).WithField("path", renamed).Errorf("Failed to rename after failed commit")
202+
log.G(ctx).WithError(err1).WithField("path", renamed).Errorf("failed to rename after failed commit")
203203
}
204204
}
205205
return errors.Wrap(err, "failed to commit")
206206
}
207207
if renamed != "" {
208208
if err := os.RemoveAll(renamed); err != nil {
209209
// Must be cleaned up, any "rm-*" could be removed if no active transactions
210-
log.G(ctx).WithError(err).WithField("path", renamed).Warnf("Failed to remove root filesystem")
210+
log.G(ctx).WithError(err).WithField("path", renamed).Warnf("failed to remove root filesystem")
211211
}
212212
}
213213

@@ -259,7 +259,7 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
259259
s, err := storage.CreateSnapshot(ctx, kind, key, parent, opts...)
260260
if err != nil {
261261
if rerr := t.Rollback(); rerr != nil {
262-
log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction")
262+
log.G(ctx).WithError(rerr).Warn("failed to rollback transaction")
263263
}
264264
return nil, errors.Wrap(err, "failed to create snapshot")
265265
}
@@ -275,7 +275,7 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
275275
path = o.getSnapshotDir(s.ID)
276276
if err := os.Rename(td, path); err != nil {
277277
if rerr := t.Rollback(); rerr != nil {
278-
log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction")
278+
log.G(ctx).WithError(rerr).Warn("failed to rollback transaction")
279279
}
280280
return nil, errors.Wrap(err, "failed to rename")
281281
}

snapshots/overlay/overlay.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap
172172
defer func() {
173173
if err != nil {
174174
if rerr := t.Rollback(); rerr != nil {
175-
log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction")
175+
log.G(ctx).WithError(rerr).Warn("failed to rollback transaction")
176176
}
177177
}
178178
}()
@@ -204,7 +204,7 @@ func (o *snapshotter) Remove(ctx context.Context, key string) (err error) {
204204
defer func() {
205205
if err != nil && t != nil {
206206
if rerr := t.Rollback(); rerr != nil {
207-
log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction")
207+
log.G(ctx).WithError(rerr).Warn("failed to rollback transaction")
208208
}
209209
}
210210
}()
@@ -225,13 +225,13 @@ func (o *snapshotter) Remove(ctx context.Context, key string) (err error) {
225225
if err != nil {
226226
if err1 := os.Rename(renamed, path); err1 != nil {
227227
// May cause inconsistent data on disk
228-
log.G(ctx).WithError(err1).WithField("path", renamed).Errorf("Failed to rename after failed commit")
228+
log.G(ctx).WithError(err1).WithField("path", renamed).Errorf("failed to rename after failed commit")
229229
}
230230
return errors.Wrap(err, "failed to commit")
231231
}
232232
if err := os.RemoveAll(renamed); err != nil {
233233
// Must be cleaned up, any "rm-*" could be removed if no active transactions
234-
log.G(ctx).WithError(err).WithField("path", renamed).Warnf("Failed to remove root filesystem")
234+
log.G(ctx).WithError(err).WithField("path", renamed).Warnf("failed to remove root filesystem")
235235
}
236236

237237
return nil
@@ -291,7 +291,7 @@ func (o *snapshotter) createSnapshot(ctx context.Context, kind snapshots.Kind, k
291291
defer func() {
292292
if isRollback {
293293
if rerr := t.Rollback(); rerr != nil {
294-
log.G(ctx).WithError(rerr).Warn("Failure rolling back transaction")
294+
log.G(ctx).WithError(rerr).Warn("failed to rollback transaction")
295295
}
296296
}
297297
}()

0 commit comments

Comments
 (0)