Skip to content

Commit 461e64e

Browse files
committed
pkg/snapshot: replace direct uses of logrus for containerd/log
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent f5dd997 commit 461e64e

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

pkg/snapshot/diskquota/prjquota.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ import (
2727
"strings"
2828
"sync"
2929

30-
"github.com/sirupsen/logrus"
31-
3230
"github.com/containerd/containerd/v2/core/mount"
31+
"github.com/containerd/log"
3332
"github.com/docker/go-units"
3433
)
3534

@@ -145,7 +144,7 @@ func (quota *PrjQuotaDriver) setQuota(quotaID uint32, blockLimit uint64, mountPo
145144
blockLimitStr := strconv.FormatUint(blockLimit, 10)
146145

147146
// ext4 set project quota limit
148-
// logrus.Infof("setquota -P %s 0 %s 0 0 %s", quotaIDStr, blockLimitStr, mountPoint)
147+
// log.L.Infof("setquota -P %s 0 %s 0 0 %s", quotaIDStr, blockLimitStr, mountPoint)
149148
stdout, stderr, err := ExecSync("setquota", "-P", quotaIDStr, "0", blockLimitStr, "0", "0", mountPoint)
150149
if err != nil {
151150
return fmt.Errorf("failed to set quota, mountpoint: (%s), quota id: (%d), quota: (%d kbytes), stdout: (%s), stderr: (%s): %w",
@@ -203,7 +202,7 @@ func (quota *PrjQuotaDriver) GetNextQuotaID() (quotaID uint32, err error) {
203202
if id <= QuotaMaxID {
204203
break
205204
}
206-
logrus.Infof("reach the maximum, try to reuse quotaID")
205+
log.L.Infof("reach the maximum, try to reuse quotaID")
207206
quota.QuotaIDs, quota.LastID, err = loadQuotaIDs("-Pan")
208207
if err != nil {
209208
return 0, fmt.Errorf("failed to load quota list: %w", err)
@@ -227,7 +226,7 @@ func (quota *PrjQuotaDriver) SetFileAttr(dir string, quotaID uint32) error {
227226
if err != nil {
228227
return fmt.Errorf("failed to set file(%s) quota id(%s), stdout: (%s), stderr: (%s): %w", dir, strID, stdout, stderr, err)
229228
}
230-
logrus.Debugf("set quota id (%s) to file (%s) attr", strID, dir)
229+
log.L.Debugf("set quota id (%s) to file (%s) attr", strID, dir)
231230

232231
return nil
233232
}

pkg/snapshot/overlay.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import (
3636
mylog "github.com/containerd/accelerated-container-image/internal/log"
3737
"github.com/containerd/accelerated-container-image/pkg/metrics"
3838
"github.com/data-accelerator/zdfs"
39-
"github.com/sirupsen/logrus"
4039

4140
"github.com/containerd/containerd/v2/core/mount"
4241
"github.com/containerd/containerd/v2/core/snapshots"
@@ -249,7 +248,7 @@ func NewSnapshotter(bootConfig *BootConfig, opts ...Opt) (snapshots.Snapshotter,
249248
}
250249

251250
if bootConfig.MirrorRegistry != nil {
252-
logrus.Infof("mirror Registry: %+v", bootConfig.MirrorRegistry)
251+
log.L.Infof("mirror Registry: %+v", bootConfig.MirrorRegistry)
253252
}
254253

255254
return &snapshotter{
@@ -679,7 +678,7 @@ func (o *snapshotter) Prepare(ctx context.Context, key, parent string, opts ...s
679678
if retErr != nil {
680679
metrics.GRPCErrCount.WithLabelValues("Prepare").Inc()
681680
} else {
682-
log.G(ctx).WithFields(logrus.Fields{
681+
log.G(ctx).WithFields(log.Fields{
683682
"d": time.Since(start),
684683
"key": key,
685684
"parent": parent,
@@ -717,7 +716,7 @@ func (o *snapshotter) Mounts(ctx context.Context, key string) (_ []mount.Mount,
717716
if retErr != nil {
718717
metrics.GRPCErrCount.WithLabelValues("Mounts").Inc()
719718
} else {
720-
log.G(ctx).WithFields(logrus.Fields{
719+
log.G(ctx).WithFields(log.Fields{
721720
"d": time.Since(start),
722721
"key": key,
723722
}).Infof("Mounts")
@@ -792,7 +791,7 @@ func (o *snapshotter) Commit(ctx context.Context, name, key string, opts ...snap
792791
if retErr != nil {
793792
metrics.GRPCErrCount.WithLabelValues("Commit").Inc()
794793
} else {
795-
log.G(ctx).WithFields(logrus.Fields{
794+
log.G(ctx).WithFields(log.Fields{
796795
"d": time.Since(start),
797796
"name": name,
798797
"key": key,

pkg/snapshot/storage.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import (
4646
"github.com/containerd/log"
4747
"github.com/moby/sys/mountinfo"
4848
specs "github.com/opencontainers/image-spec/specs-go/v1"
49-
"github.com/sirupsen/logrus"
5049
"golang.org/x/sys/unix"
5150
)
5251

@@ -135,7 +134,7 @@ func (o *snapshotter) parseAndCheckMounted(ctx context.Context, r io.Reader, mat
135134
numFields := len(fields)
136135
if numFields < 10 {
137136
// should be at least 10 fields
138-
logrus.Warnf("Parsing '%s' failed: not enough fields (%d)", text, numFields)
137+
log.G(ctx).Warnf("Parsing '%s' failed: not enough fields (%d)", text, numFields)
139138
continue
140139
}
141140

0 commit comments

Comments
 (0)