commit
98f48d485d
@ -23,9 +23,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
internalapi "github.com/containerd/containerd/integration/cri-api/pkg/apis"
|
internalapi "github.com/containerd/containerd/integration/cri-api/pkg/apis"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/pkg/cri/util"
|
"github.com/containerd/containerd/pkg/cri/util"
|
||||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||||
)
|
)
|
||||||
@ -63,7 +62,7 @@ func (w *criWorker) getFailures() int {
|
|||||||
func (w *criWorker) run(ctx, tctx context.Context) {
|
func (w *criWorker) run(ctx, tctx context.Context) {
|
||||||
defer func() {
|
defer func() {
|
||||||
w.wg.Done()
|
w.wg.Done()
|
||||||
logrus.Infof("worker %d finished", w.id)
|
log.L.Infof("worker %d finished", w.id)
|
||||||
}()
|
}()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -74,13 +73,13 @@ func (w *criWorker) run(ctx, tctx context.Context) {
|
|||||||
|
|
||||||
w.count++
|
w.count++
|
||||||
id := w.getID()
|
id := w.getID()
|
||||||
logrus.Debugf("starting container %s", id)
|
log.L.Debugf("starting container %s", id)
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
if err := w.runSandbox(tctx, ctx, id); err != nil {
|
if err := w.runSandbox(tctx, ctx, id); err != nil {
|
||||||
if err != context.DeadlineExceeded ||
|
if err != context.DeadlineExceeded ||
|
||||||
!strings.Contains(err.Error(), context.DeadlineExceeded.Error()) {
|
!strings.Contains(err.Error(), context.DeadlineExceeded.Error()) {
|
||||||
w.failures++
|
w.failures++
|
||||||
logrus.WithError(err).Errorf("running container %s", id)
|
log.L.WithError(err).Errorf("running container %s", id)
|
||||||
errCounter.WithValues(err.Error()).Inc()
|
errCounter.WithValues(err.Error()).Inc()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,9 @@ import (
|
|||||||
|
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
"github.com/containerd/containerd/cio"
|
"github.com/containerd/containerd/cio"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/namespaces"
|
"github.com/containerd/containerd/namespaces"
|
||||||
"github.com/containerd/containerd/oci"
|
"github.com/containerd/containerd/oci"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -76,12 +76,12 @@ var densityCommand = cli.Command{
|
|||||||
if err := cleanup(ctx, client); err != nil {
|
if err := cleanup(ctx, client); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logrus.Infof("pulling %s", config.Image)
|
log.L.Infof("pulling %s", config.Image)
|
||||||
image, err := client.Pull(ctx, config.Image, containerd.WithPullUnpack, containerd.WithPullSnapshotter(config.Snapshotter))
|
image, err := client.Pull(ctx, config.Image, containerd.WithPullUnpack, containerd.WithPullSnapshotter(config.Snapshotter))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logrus.Info("generating spec from image")
|
log.L.Info("generating spec from image")
|
||||||
|
|
||||||
s := make(chan os.Signal, 1)
|
s := make(chan os.Signal, 1)
|
||||||
signal.Notify(s, syscall.SIGTERM, syscall.SIGINT)
|
signal.Notify(s, syscall.SIGTERM, syscall.SIGINT)
|
||||||
|
@ -25,9 +25,9 @@ import (
|
|||||||
|
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
"github.com/containerd/containerd/cio"
|
"github.com/containerd/containerd/cio"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/oci"
|
"github.com/containerd/containerd/oci"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type execWorker struct {
|
type execWorker struct {
|
||||||
@ -37,7 +37,7 @@ type execWorker struct {
|
|||||||
func (w *execWorker) exec(ctx, tctx context.Context) {
|
func (w *execWorker) exec(ctx, tctx context.Context) {
|
||||||
defer func() {
|
defer func() {
|
||||||
w.wg.Done()
|
w.wg.Done()
|
||||||
logrus.Infof("worker %d finished", w.id)
|
log.L.Infof("worker %d finished", w.id)
|
||||||
}()
|
}()
|
||||||
id := fmt.Sprintf("exec-container-%d", w.id)
|
id := fmt.Sprintf("exec-container-%d", w.id)
|
||||||
c, err := w.client.NewContainer(ctx, id,
|
c, err := w.client.NewContainer(ctx, id,
|
||||||
@ -46,32 +46,32 @@ func (w *execWorker) exec(ctx, tctx context.Context) {
|
|||||||
containerd.WithNewSpec(oci.WithImageConfig(w.image), oci.WithUsername("games"), oci.WithProcessArgs("sleep", "30d")),
|
containerd.WithNewSpec(oci.WithImageConfig(w.image), oci.WithUsername("games"), oci.WithProcessArgs("sleep", "30d")),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Error("create exec container")
|
log.L.WithError(err).Error("create exec container")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer c.Delete(ctx, containerd.WithSnapshotCleanup)
|
defer c.Delete(ctx, containerd.WithSnapshotCleanup)
|
||||||
|
|
||||||
task, err := c.NewTask(ctx, cio.NullIO)
|
task, err := c.NewTask(ctx, cio.NullIO)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Error("create exec container's task")
|
log.L.WithError(err).Error("create exec container's task")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer task.Delete(ctx, containerd.WithProcessKill)
|
defer task.Delete(ctx, containerd.WithProcessKill)
|
||||||
|
|
||||||
statusC, err := task.Wait(ctx)
|
statusC, err := task.Wait(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Error("wait exec container's task")
|
log.L.WithError(err).Error("wait exec container's task")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := task.Start(ctx); err != nil {
|
if err := task.Start(ctx); err != nil {
|
||||||
logrus.WithError(err).Error("exec container start failure")
|
log.L.WithError(err).Error("exec container start failure")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
spec, err := c.Spec(ctx)
|
spec, err := c.Spec(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Error("failed to get spec")
|
log.L.WithError(err).Error("failed to get spec")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ func (w *execWorker) exec(ctx, tctx context.Context) {
|
|||||||
select {
|
select {
|
||||||
case <-tctx.Done():
|
case <-tctx.Done():
|
||||||
if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
|
if err := task.Kill(ctx, syscall.SIGKILL); err != nil {
|
||||||
logrus.WithError(err).Error("kill exec container's task")
|
log.L.WithError(err).Error("kill exec container's task")
|
||||||
}
|
}
|
||||||
<-statusC
|
<-statusC
|
||||||
return
|
return
|
||||||
@ -91,14 +91,14 @@ func (w *execWorker) exec(ctx, tctx context.Context) {
|
|||||||
|
|
||||||
w.count++
|
w.count++
|
||||||
id := w.getID()
|
id := w.getID()
|
||||||
logrus.Debugf("starting exec %s", id)
|
log.L.Debugf("starting exec %s", id)
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
if err := w.runExec(ctx, task, id, pspec); err != nil {
|
if err := w.runExec(ctx, task, id, pspec); err != nil {
|
||||||
if err != context.DeadlineExceeded ||
|
if err != context.DeadlineExceeded ||
|
||||||
!strings.Contains(err.Error(), context.DeadlineExceeded.Error()) {
|
!strings.Contains(err.Error(), context.DeadlineExceeded.Error()) {
|
||||||
w.failures++
|
w.failures++
|
||||||
logrus.WithError(err).Errorf("running exec %s", id)
|
log.L.WithError(err).Errorf("running exec %s", id)
|
||||||
errCounter.WithValues(err.Error()).Inc()
|
errCounter.WithValues(err.Error()).Inc()
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
|
@ -30,10 +30,10 @@ import (
|
|||||||
|
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
"github.com/containerd/containerd/integration/remote"
|
"github.com/containerd/containerd/integration/remote"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/namespaces"
|
"github.com/containerd/containerd/namespaces"
|
||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
metrics "github.com/docker/go-metrics"
|
metrics "github.com/docker/go-metrics"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -177,10 +177,14 @@ func main() {
|
|||||||
}
|
}
|
||||||
app.Before = func(context *cli.Context) error {
|
app.Before = func(context *cli.Context) error {
|
||||||
if context.GlobalBool("json") {
|
if context.GlobalBool("json") {
|
||||||
logrus.SetLevel(logrus.WarnLevel)
|
if err := log.SetLevel("warn"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if context.GlobalBool("debug") {
|
if context.GlobalBool("debug") {
|
||||||
logrus.SetLevel(logrus.DebugLevel)
|
if err := log.SetLevel("debug"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -241,7 +245,7 @@ func serve(c config) error {
|
|||||||
ReadHeaderTimeout: 5 * time.Minute, // "G112: Potential Slowloris Attack (gosec)"; not a real concern for our use, so setting a long timeout.
|
ReadHeaderTimeout: 5 * time.Minute, // "G112: Potential Slowloris Attack (gosec)"; not a real concern for our use, so setting a long timeout.
|
||||||
}
|
}
|
||||||
if err := srv.ListenAndServe(); err != nil {
|
if err := srv.ListenAndServe(); err != nil {
|
||||||
logrus.WithError(err).Error("listen and serve")
|
log.L.WithError(err).Error("listen and serve")
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
checkBinarySizes()
|
checkBinarySizes()
|
||||||
@ -287,7 +291,7 @@ func criTest(c config) error {
|
|||||||
workers []worker
|
workers []worker
|
||||||
r = &run{}
|
r = &run{}
|
||||||
)
|
)
|
||||||
logrus.Info("starting stress test run...")
|
log.L.Info("starting stress test run...")
|
||||||
// create the workers along with their spec
|
// create the workers along with their spec
|
||||||
for i := 0; i < c.Concurrency; i++ {
|
for i := 0; i < c.Concurrency; i++ {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
@ -312,9 +316,9 @@ func criTest(c config) error {
|
|||||||
r.end()
|
r.end()
|
||||||
|
|
||||||
results := r.gather(workers)
|
results := r.gather(workers)
|
||||||
logrus.Infof("ending test run in %0.3f seconds", results.Seconds)
|
log.L.Infof("ending test run in %0.3f seconds", results.Seconds)
|
||||||
|
|
||||||
logrus.WithField("failures", r.failures).Infof(
|
log.L.WithField("failures", r.failures).Infof(
|
||||||
"create/start/delete %d containers in %0.3f seconds (%0.3f c/sec) or (%0.3f sec/c)",
|
"create/start/delete %d containers in %0.3f seconds (%0.3f c/sec) or (%0.3f sec/c)",
|
||||||
results.Total,
|
results.Total,
|
||||||
results.Seconds,
|
results.Seconds,
|
||||||
@ -345,7 +349,7 @@ func test(c config) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Infof("pulling %s", c.Image)
|
log.L.Infof("pulling %s", c.Image)
|
||||||
image, err := client.Pull(ctx, c.Image, containerd.WithPullUnpack, containerd.WithPullSnapshotter(c.Snapshotter))
|
image, err := client.Pull(ctx, c.Image, containerd.WithPullUnpack, containerd.WithPullSnapshotter(c.Snapshotter))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -367,7 +371,7 @@ func test(c config) error {
|
|||||||
workers []worker
|
workers []worker
|
||||||
r = &run{}
|
r = &run{}
|
||||||
)
|
)
|
||||||
logrus.Info("starting stress test run...")
|
log.L.Info("starting stress test run...")
|
||||||
// create the workers along with their spec
|
// create the workers along with their spec
|
||||||
for i := 0; i < c.Concurrency; i++ {
|
for i := 0; i < c.Concurrency; i++ {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
@ -414,9 +418,9 @@ func test(c config) error {
|
|||||||
results.ExecTotal = exec.count
|
results.ExecTotal = exec.count
|
||||||
results.ExecFailures = exec.failures
|
results.ExecFailures = exec.failures
|
||||||
}
|
}
|
||||||
logrus.Infof("ending test run in %0.3f seconds", results.Seconds)
|
log.L.Infof("ending test run in %0.3f seconds", results.Seconds)
|
||||||
|
|
||||||
logrus.WithField("failures", r.failures).Infof(
|
log.L.WithField("failures", r.failures).Infof(
|
||||||
"create/start/delete %d containers in %0.3f seconds (%0.3f c/sec) or (%0.3f sec/c)",
|
"create/start/delete %d containers in %0.3f seconds (%0.3f c/sec) or (%0.3f sec/c)",
|
||||||
results.Total,
|
results.Total,
|
||||||
results.Seconds,
|
results.Seconds,
|
||||||
|
@ -19,7 +19,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/containerd/containerd/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultPath = "/usr/local/bin/"
|
const defaultPath = "/usr/local/bin/"
|
||||||
@ -37,12 +37,12 @@ func checkBinarySizes() {
|
|||||||
for _, name := range binaries {
|
for _, name := range binaries {
|
||||||
fi, err := os.Stat(name)
|
fi, err := os.Stat(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Error("stat binary")
|
log.L.WithError(err).Error("stat binary")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if fi.IsDir() {
|
if fi.IsDir() {
|
||||||
logrus.Error(name, "is not a file")
|
log.L.Error(name, "is not a file")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ import (
|
|||||||
|
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
"github.com/containerd/containerd/cio"
|
"github.com/containerd/containerd/cio"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/oci"
|
"github.com/containerd/containerd/oci"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ctrWorker struct {
|
type ctrWorker struct {
|
||||||
@ -44,7 +44,7 @@ type ctrWorker struct {
|
|||||||
func (w *ctrWorker) run(ctx, tctx context.Context) {
|
func (w *ctrWorker) run(ctx, tctx context.Context) {
|
||||||
defer func() {
|
defer func() {
|
||||||
w.wg.Done()
|
w.wg.Done()
|
||||||
logrus.Infof("worker %d finished", w.id)
|
log.L.Infof("worker %d finished", w.id)
|
||||||
}()
|
}()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -55,13 +55,13 @@ func (w *ctrWorker) run(ctx, tctx context.Context) {
|
|||||||
|
|
||||||
w.count++
|
w.count++
|
||||||
id := w.getID()
|
id := w.getID()
|
||||||
logrus.Debugf("starting container %s", id)
|
log.L.Debugf("starting container %s", id)
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
if err := w.runContainer(ctx, id); err != nil {
|
if err := w.runContainer(ctx, id); err != nil {
|
||||||
if err != context.DeadlineExceeded ||
|
if err != context.DeadlineExceeded ||
|
||||||
!strings.Contains(err.Error(), context.DeadlineExceeded.Error()) {
|
!strings.Contains(err.Error(), context.DeadlineExceeded.Error()) {
|
||||||
w.failures++
|
w.failures++
|
||||||
logrus.WithError(err).Errorf("running container %s", id)
|
log.L.WithError(err).Errorf("running container %s", id)
|
||||||
errCounter.WithValues(err.Error()).Inc()
|
errCounter.WithValues(err.Error()).Inc()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ func setupDumpStacks() {
|
|||||||
ev, _ := windows.UTF16PtrFromString(event)
|
ev, _ := windows.UTF16PtrFromString(event)
|
||||||
sd, err := windows.SecurityDescriptorFromString("D:P(A;;GA;;;BA)(A;;GA;;;SY)")
|
sd, err := windows.SecurityDescriptorFromString("D:P(A;;GA;;;BA)(A;;GA;;;SY)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("failed to get security descriptor for debug stackdump event %s: %s", event, err.Error())
|
log.L.Errorf("failed to get security descriptor for debug stackdump event %s: %s", event, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var sa windows.SecurityAttributes
|
var sa windows.SecurityAttributes
|
||||||
@ -84,11 +84,11 @@ func setupDumpStacks() {
|
|||||||
sa.SecurityDescriptor = sd
|
sa.SecurityDescriptor = sd
|
||||||
h, err := windows.CreateEvent(&sa, 0, 0, ev)
|
h, err := windows.CreateEvent(&sa, 0, 0, ev)
|
||||||
if h == 0 || err != nil {
|
if h == 0 || err != nil {
|
||||||
logrus.Errorf("failed to create debug stackdump event %s: %s", event, err.Error())
|
log.L.Errorf("failed to create debug stackdump event %s: %s", event, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
logrus.Debugf("Stackdump - waiting signal at %s", event)
|
log.L.Debugf("Stackdump - waiting signal at %s", event)
|
||||||
for {
|
for {
|
||||||
windows.WaitForSingleObject(h, windows.INFINITE)
|
windows.WaitForSingleObject(h, windows.INFINITE)
|
||||||
dumpStacks(true)
|
dumpStacks(true)
|
||||||
@ -109,7 +109,7 @@ func init() {
|
|||||||
// Microsoft/go-winio/tools/etw-provider-gen.
|
// Microsoft/go-winio/tools/etw-provider-gen.
|
||||||
provider, err := etw.NewProvider("ContainerD", etwCallback)
|
provider, err := etw.NewProvider("ContainerD", etwCallback)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error(err)
|
log.L.Error(err)
|
||||||
} else {
|
} else {
|
||||||
if hook, err := etwlogrus.NewHookFromProvider(provider); err == nil {
|
if hook, err := etwlogrus.NewHookFromProvider(provider); err == nil {
|
||||||
logrus.AddHook(hook)
|
logrus.AddHook(hook)
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||||
"github.com/containerd/containerd/cmd/ctr/commands/tasks"
|
"github.com/containerd/containerd/cmd/ctr/commands/tasks"
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ var restoreCommand = cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := tasks.HandleConsoleResize(ctx, task, con); err != nil {
|
if err := tasks.HandleConsoleResize(ctx, task, con); err != nil {
|
||||||
logrus.WithError(err).Error("console resize")
|
log.G(ctx).WithError(err).Error("console resize")
|
||||||
}
|
}
|
||||||
|
|
||||||
status := <-statusC
|
status := <-statusC
|
||||||
|
@ -30,10 +30,10 @@ import (
|
|||||||
"github.com/containerd/containerd/cmd/ctr/commands/tasks"
|
"github.com/containerd/containerd/cmd/ctr/commands/tasks"
|
||||||
"github.com/containerd/containerd/containers"
|
"github.com/containerd/containerd/containers"
|
||||||
clabels "github.com/containerd/containerd/labels"
|
clabels "github.com/containerd/containerd/labels"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/oci"
|
"github.com/containerd/containerd/oci"
|
||||||
gocni "github.com/containerd/go-cni"
|
gocni "github.com/containerd/go-cni"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ var Command = cli.Command{
|
|||||||
defer func() {
|
defer func() {
|
||||||
if enableCNI {
|
if enableCNI {
|
||||||
if err := network.Remove(ctx, commands.FullID(ctx, container), ""); err != nil {
|
if err := network.Remove(ctx, commands.FullID(ctx, container), ""); err != nil {
|
||||||
logrus.WithError(err).Error("network review")
|
log.L.WithError(err).Error("network review")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
task.Delete(ctx)
|
task.Delete(ctx)
|
||||||
@ -232,7 +232,7 @@ var Command = cli.Command{
|
|||||||
}
|
}
|
||||||
if tty {
|
if tty {
|
||||||
if err := tasks.HandleConsoleResize(ctx, task, con); err != nil {
|
if err := tasks.HandleConsoleResize(ctx, task, con); err != nil {
|
||||||
logrus.WithError(err).Error("console resize")
|
log.L.WithError(err).Error("console resize")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sigc := commands.ForwardAllSignals(ctx, task)
|
sigc := commands.ForwardAllSignals(ctx, task)
|
||||||
@ -262,7 +262,7 @@ func buildLabels(cmdLabels, imageLabels map[string]string) map[string]string {
|
|||||||
} else {
|
} else {
|
||||||
// In case the image label is invalid, we output a warning and skip adding it to the
|
// In case the image label is invalid, we output a warning and skip adding it to the
|
||||||
// container.
|
// container.
|
||||||
logrus.WithError(err).Warnf("unable to add image label with key %s to the container", k)
|
log.L.WithError(err).Warnf("unable to add image label with key %s to the container", k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// labels from the command line will override image and the initial image config labels
|
// labels from the command line will override image and the initial image config labels
|
||||||
|
@ -25,11 +25,11 @@ import (
|
|||||||
"github.com/containerd/console"
|
"github.com/containerd/console"
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/oci"
|
"github.com/containerd/containerd/oci"
|
||||||
"github.com/containerd/containerd/pkg/netns"
|
"github.com/containerd/containerd/pkg/netns"
|
||||||
"github.com/containerd/containerd/snapshots"
|
"github.com/containerd/containerd/snapshots"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
|
|||||||
con := console.Current()
|
con := console.Current()
|
||||||
size, err := con.Size()
|
size, err := con.Size()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Error("console size")
|
log.L.WithError(err).Error("console size")
|
||||||
}
|
}
|
||||||
opts = append(opts, oci.WithTTYSize(int(size.Width), int(size.Height)))
|
opts = append(opts, oci.WithTTYSize(int(size.Width), int(size.Height)))
|
||||||
}
|
}
|
||||||
|
@ -30,13 +30,13 @@ import (
|
|||||||
"github.com/containerd/console"
|
"github.com/containerd/console"
|
||||||
"github.com/containerd/containerd/api/runtime/task/v2"
|
"github.com/containerd/containerd/api/runtime/task/v2"
|
||||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/namespaces"
|
"github.com/containerd/containerd/namespaces"
|
||||||
ptypes "github.com/containerd/containerd/protobuf/types"
|
ptypes "github.com/containerd/containerd/protobuf/types"
|
||||||
"github.com/containerd/containerd/runtime/v2/shim"
|
"github.com/containerd/containerd/runtime/v2/shim"
|
||||||
"github.com/containerd/ttrpc"
|
"github.com/containerd/ttrpc"
|
||||||
"github.com/containerd/typeurl/v2"
|
"github.com/containerd/typeurl/v2"
|
||||||
"github.com/opencontainers/runtime-spec/specs-go"
|
"github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ var execCommand = cli.Command{
|
|||||||
}
|
}
|
||||||
fmt.Printf("exec running with pid %d\n", r.Pid)
|
fmt.Printf("exec running with pid %d\n", r.Pid)
|
||||||
if context.Bool("attach") {
|
if context.Bool("attach") {
|
||||||
logrus.Info("attaching")
|
log.L.Info("attaching")
|
||||||
if tty {
|
if tty {
|
||||||
current := console.Current()
|
current := console.Current()
|
||||||
defer current.Reset()
|
defer current.Reset()
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
|
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/containerd/containerd/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type killer interface {
|
type killer interface {
|
||||||
@ -38,16 +38,16 @@ func ForwardAllSignals(ctx gocontext.Context, task killer) chan os.Signal {
|
|||||||
go func() {
|
go func() {
|
||||||
for s := range sigc {
|
for s := range sigc {
|
||||||
if canIgnoreSignal(s) {
|
if canIgnoreSignal(s) {
|
||||||
logrus.Debugf("Ignoring signal %s", s)
|
log.L.Debugf("Ignoring signal %s", s)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
logrus.Debug("forwarding signal ", s)
|
log.L.Debug("forwarding signal ", s)
|
||||||
if err := task.Kill(ctx, s.(syscall.Signal)); err != nil {
|
if err := task.Kill(ctx, s.(syscall.Signal)); err != nil {
|
||||||
if errdefs.IsNotFound(err) {
|
if errdefs.IsNotFound(err) {
|
||||||
logrus.WithError(err).Debugf("Not forwarding signal %s", s)
|
log.L.WithError(err).Debugf("Not forwarding signal %s", s)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logrus.WithError(err).Errorf("forward signal %s", s)
|
log.L.WithError(err).Errorf("forward signal %s", s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
"github.com/containerd/console"
|
"github.com/containerd/console"
|
||||||
"github.com/containerd/containerd/cio"
|
"github.com/containerd/containerd/cio"
|
||||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ var attachCommand = cli.Command{
|
|||||||
|
|
||||||
if tty {
|
if tty {
|
||||||
if err := HandleConsoleResize(ctx, task, con); err != nil {
|
if err := HandleConsoleResize(ctx, task, con); err != nil {
|
||||||
logrus.WithError(err).Error("console resize")
|
log.L.WithError(err).Error("console resize")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sigc := commands.ForwardAllSignals(ctx, task)
|
sigc := commands.ForwardAllSignals(ctx, task)
|
||||||
|
@ -26,8 +26,8 @@ import (
|
|||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
"github.com/containerd/containerd/cio"
|
"github.com/containerd/containerd/cio"
|
||||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/oci"
|
"github.com/containerd/containerd/oci"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ var execCommand = cli.Command{
|
|||||||
}
|
}
|
||||||
if tty {
|
if tty {
|
||||||
if err := HandleConsoleResize(ctx, process, con); err != nil {
|
if err := HandleConsoleResize(ctx, process, con); err != nil {
|
||||||
logrus.WithError(err).Error("console resize")
|
log.L.WithError(err).Error("console resize")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sigc := commands.ForwardAllSignals(ctx, process)
|
sigc := commands.ForwardAllSignals(ctx, process)
|
||||||
|
@ -23,10 +23,10 @@ import (
|
|||||||
|
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
gocni "github.com/containerd/go-cni"
|
gocni "github.com/containerd/go-cni"
|
||||||
"github.com/containerd/typeurl/v2"
|
"github.com/containerd/typeurl/v2"
|
||||||
"github.com/moby/sys/signal"
|
"github.com/moby/sys/signal"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ func RemoveCniNetworkIfExist(ctx context.Context, container containerd.Container
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := network.Remove(ctx, commands.FullID(ctx, container), ""); err != nil {
|
if err := network.Remove(ctx, commands.FullID(ctx, container), ""); err != nil {
|
||||||
logrus.WithError(err).Error("network remove error")
|
log.L.WithError(err).Error("network remove error")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
"github.com/containerd/containerd/cio"
|
"github.com/containerd/containerd/cio"
|
||||||
"github.com/containerd/containerd/cmd/ctr/commands"
|
"github.com/containerd/containerd/cmd/ctr/commands"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ var startCommand = cli.Command{
|
|||||||
}
|
}
|
||||||
if tty {
|
if tty {
|
||||||
if err := HandleConsoleResize(ctx, task, con); err != nil {
|
if err := HandleConsoleResize(ctx, task, con); err != nil {
|
||||||
logrus.WithError(err).Error("console resize")
|
log.L.WithError(err).Error("console resize")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sigc := commands.ForwardAllSignals(ctx, task)
|
sigc := commands.ForwardAllSignals(ctx, task)
|
||||||
|
@ -26,12 +26,13 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
winio "github.com/Microsoft/go-winio"
|
"github.com/Microsoft/go-winio"
|
||||||
|
exec "golang.org/x/sys/execabs"
|
||||||
|
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/protobuf"
|
"github.com/containerd/containerd/protobuf"
|
||||||
"github.com/containerd/containerd/protobuf/proto"
|
"github.com/containerd/containerd/protobuf/proto"
|
||||||
"github.com/containerd/typeurl/v2"
|
"github.com/containerd/typeurl/v2"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
exec "golang.org/x/sys/execabs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const processorPipe = "STREAM_PROCESSOR_PIPE"
|
const processorPipe = "STREAM_PROCESSOR_PIPE"
|
||||||
@ -61,7 +62,7 @@ func NewBinaryProcessor(ctx context.Context, imt, rmt string, stream StreamProce
|
|||||||
defer l.Close()
|
defer l.Close()
|
||||||
conn, err := l.Accept()
|
conn, err := l.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Error("accept npipe connection")
|
log.G(ctx).WithError(err).Error("accept npipe connection")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
io.Copy(conn, bytes.NewReader(data))
|
io.Copy(conn, bytes.NewReader(data))
|
||||||
|
@ -20,12 +20,13 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
|
"github.com/opencontainers/go-digest"
|
||||||
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
|
|
||||||
"github.com/containerd/containerd/archive/compression"
|
"github.com/containerd/containerd/archive/compression"
|
||||||
"github.com/containerd/containerd/content"
|
"github.com/containerd/containerd/content"
|
||||||
"github.com/containerd/containerd/labels"
|
"github.com/containerd/containerd/labels"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/containerd/containerd/log"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetDiffID gets the diff ID of the layer blob descriptor.
|
// GetDiffID gets the diff ID of the layer blob descriptor.
|
||||||
@ -75,7 +76,7 @@ func GetDiffID(ctx context.Context, cs content.Store, desc ocispec.Descriptor) (
|
|||||||
}
|
}
|
||||||
info.Labels[labels.LabelUncompressed] = digest.String()
|
info.Labels[labels.LabelUncompressed] = digest.String()
|
||||||
if _, err := cs.Update(ctx, info, "labels"); err != nil {
|
if _, err := cs.Update(ctx, info, "labels"); err != nil {
|
||||||
logrus.WithError(err).Warnf("failed to set %s label for %s", labels.LabelUncompressed, desc.Digest)
|
log.G(ctx).WithError(err).Warnf("failed to set %s label for %s", labels.LabelUncompressed, desc.Digest)
|
||||||
}
|
}
|
||||||
return digest, nil
|
return digest, nil
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ import (
|
|||||||
"github.com/containerd/containerd/namespaces"
|
"github.com/containerd/containerd/namespaces"
|
||||||
"github.com/containerd/containerd/runtime"
|
"github.com/containerd/containerd/runtime"
|
||||||
"github.com/docker/go-metrics"
|
"github.com/docker/go-metrics"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewTaskMonitor returns a new cgroups monitor
|
// NewTaskMonitor returns a new cgroups monitor
|
||||||
@ -75,7 +74,7 @@ func (m *cgroupsMonitor) Monitor(c runtime.Task, labels map[string]string) error
|
|||||||
}
|
}
|
||||||
err = m.oom.Add(c.ID(), c.Namespace(), cg, m.trigger)
|
err = m.oom.Add(c.ID(), c.Namespace(), cg, m.trigger)
|
||||||
if err == cgroups.ErrMemoryNotSupported {
|
if err == cgroups.ErrMemoryNotSupported {
|
||||||
logrus.WithError(err).Warn("OOM monitoring failed")
|
log.L.WithError(err).Warn("OOM monitoring failed")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/containerd/containerd/cio"
|
"github.com/containerd/containerd/cio"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/containerd/containerd/pkg/cri/util"
|
"github.com/containerd/containerd/pkg/cri/util"
|
||||||
@ -109,12 +110,12 @@ func (c *ContainerIO) Pipe() {
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
if _, err := io.Copy(c.stdoutGroup, c.stdout); err != nil {
|
if _, err := io.Copy(c.stdoutGroup, c.stdout); err != nil {
|
||||||
logrus.WithError(err).Errorf("Failed to pipe stdout of container %q", c.id)
|
log.L.WithError(err).Errorf("Failed to pipe stdout of container %q", c.id)
|
||||||
}
|
}
|
||||||
c.stdout.Close()
|
c.stdout.Close()
|
||||||
c.stdoutGroup.Close()
|
c.stdoutGroup.Close()
|
||||||
wg.Done()
|
wg.Done()
|
||||||
logrus.Debugf("Finish piping stdout of container %q", c.id)
|
log.L.Debugf("Finish piping stdout of container %q", c.id)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,12 +123,12 @@ func (c *ContainerIO) Pipe() {
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
if _, err := io.Copy(c.stderrGroup, c.stderr); err != nil {
|
if _, err := io.Copy(c.stderrGroup, c.stderr); err != nil {
|
||||||
logrus.WithError(err).Errorf("Failed to pipe stderr of container %q", c.id)
|
log.L.WithError(err).Errorf("Failed to pipe stderr of container %q", c.id)
|
||||||
}
|
}
|
||||||
c.stderr.Close()
|
c.stderr.Close()
|
||||||
c.stderrGroup.Close()
|
c.stderrGroup.Close()
|
||||||
wg.Done()
|
wg.Done()
|
||||||
logrus.Debugf("Finish piping stderr of container %q", c.id)
|
log.L.Debugf("Finish piping stderr of container %q", c.id)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,9 +151,9 @@ func (c *ContainerIO) Attach(opts AttachOptions) {
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
if _, err := io.Copy(c.stdin, stdinStreamRC); err != nil {
|
if _, err := io.Copy(c.stdin, stdinStreamRC); err != nil {
|
||||||
logrus.WithError(err).Errorf("Failed to pipe stdin for container attach %q", c.id)
|
log.L.WithError(err).Errorf("Failed to pipe stdin for container attach %q", c.id)
|
||||||
}
|
}
|
||||||
logrus.Infof("Attach stream %q closed", stdinKey)
|
log.L.Infof("Attach stream %q closed", stdinKey)
|
||||||
if opts.StdinOnce && !opts.Tty {
|
if opts.StdinOnce && !opts.Tty {
|
||||||
// Due to kubectl requirements and current docker behavior, when (opts.StdinOnce &&
|
// Due to kubectl requirements and current docker behavior, when (opts.StdinOnce &&
|
||||||
// opts.Tty) we have to close container stdin and keep stdout and stderr open until
|
// opts.Tty) we have to close container stdin and keep stdout and stderr open until
|
||||||
|
@ -21,8 +21,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/containerd/containerd/cio"
|
"github.com/containerd/containerd/cio"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/containerd/containerd/log"
|
||||||
|
|
||||||
cioutil "github.com/containerd/containerd/pkg/ioutil"
|
cioutil "github.com/containerd/containerd/pkg/ioutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -68,13 +67,13 @@ func (e *ExecIO) Attach(opts AttachOptions) <-chan struct{} {
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
if _, err := io.Copy(e.stdin, stdinStreamRC); err != nil {
|
if _, err := io.Copy(e.stdin, stdinStreamRC); err != nil {
|
||||||
logrus.WithError(err).Errorf("Failed to redirect stdin for container exec %q", e.id)
|
log.L.WithError(err).Errorf("Failed to redirect stdin for container exec %q", e.id)
|
||||||
}
|
}
|
||||||
logrus.Infof("Container exec %q stdin closed", e.id)
|
log.L.Infof("Container exec %q stdin closed", e.id)
|
||||||
if opts.StdinOnce && !opts.Tty {
|
if opts.StdinOnce && !opts.Tty {
|
||||||
e.stdin.Close()
|
e.stdin.Close()
|
||||||
if err := opts.CloseStdin(); err != nil {
|
if err := opts.CloseStdin(); err != nil {
|
||||||
logrus.WithError(err).Errorf("Failed to close stdin for container exec %q", e.id)
|
log.L.WithError(err).Errorf("Failed to close stdin for container exec %q", e.id)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if e.stdout != nil {
|
if e.stdout != nil {
|
||||||
@ -90,7 +89,7 @@ func (e *ExecIO) Attach(opts AttachOptions) <-chan struct{} {
|
|||||||
|
|
||||||
attachOutput := func(t StreamType, stream io.WriteCloser, out io.ReadCloser) {
|
attachOutput := func(t StreamType, stream io.WriteCloser, out io.ReadCloser) {
|
||||||
if _, err := io.Copy(stream, out); err != nil {
|
if _, err := io.Copy(stream, out); err != nil {
|
||||||
logrus.WithError(err).Errorf("Failed to pipe %q for container exec %q", t, e.id)
|
log.L.WithError(err).Errorf("Failed to pipe %q for container exec %q", t, e.id)
|
||||||
}
|
}
|
||||||
out.Close()
|
out.Close()
|
||||||
stream.Close()
|
stream.Close()
|
||||||
@ -99,7 +98,7 @@ func (e *ExecIO) Attach(opts AttachOptions) <-chan struct{} {
|
|||||||
}
|
}
|
||||||
e.closer.wg.Done()
|
e.closer.wg.Done()
|
||||||
wg.Done()
|
wg.Done()
|
||||||
logrus.Debugf("Finish piping %q of container exec %q", t, e.id)
|
log.L.Debugf("Finish piping %q of container exec %q", t, e.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
if opts.Stdout != nil {
|
if opts.Stdout != nil {
|
||||||
|
@ -28,7 +28,6 @@ import (
|
|||||||
|
|
||||||
"github.com/container-orchestrated-devices/container-device-interface/pkg/cdi"
|
"github.com/container-orchestrated-devices/container-device-interface/pkg/cdi"
|
||||||
"github.com/containerd/cgroups/v3"
|
"github.com/containerd/cgroups/v3"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
"github.com/containerd/containerd/containers"
|
"github.com/containerd/containerd/containers"
|
||||||
@ -53,14 +52,14 @@ func SwapControllerAvailable() bool {
|
|||||||
_, unified, err := cgroups.ParseCgroupFileUnified("/proc/self/cgroup")
|
_, unified, err := cgroups.ParseCgroupFileUnified("/proc/self/cgroup")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("failed to parse /proc/self/cgroup: %w", err)
|
err = fmt.Errorf("failed to parse /proc/self/cgroup: %w", err)
|
||||||
logrus.WithError(err).Warn(warn)
|
log.L.WithError(err).Warn(warn)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
p = filepath.Join("/sys/fs/cgroup", unified, "memory.swap.max")
|
p = filepath.Join("/sys/fs/cgroup", unified, "memory.swap.max")
|
||||||
}
|
}
|
||||||
if _, err := os.Stat(p); err != nil {
|
if _, err := os.Stat(p); err != nil {
|
||||||
if !errors.Is(err, os.ErrNotExist) {
|
if !errors.Is(err, os.ErrNotExist) {
|
||||||
logrus.WithError(err).Warn(warn)
|
log.L.WithError(err).Warn(warn)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ import (
|
|||||||
|
|
||||||
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
|
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/opencontainers/selinux/go-selinux/label"
|
"github.com/opencontainers/selinux/go-selinux/label"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||||
|
|
||||||
"github.com/containerd/containerd/containers"
|
"github.com/containerd/containerd/containers"
|
||||||
@ -347,7 +346,7 @@ func WithResources(resources *runtime.LinuxContainerResources, tolerateMissingHu
|
|||||||
return errors.New("huge pages limits are specified but hugetlb cgroup controller is missing. " +
|
return errors.New("huge pages limits are specified but hugetlb cgroup controller is missing. " +
|
||||||
"Please set tolerate_missing_hugetlb_controller to `true` to ignore this error")
|
"Please set tolerate_missing_hugetlb_controller to `true` to ignore this error")
|
||||||
}
|
}
|
||||||
logrus.Warn("hugetlb cgroup controller is absent. skipping huge pages limits")
|
log.L.Warn("hugetlb cgroup controller is absent. skipping huge pages limits")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,7 @@ package sbserver
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/containerd/containerd/log"
|
||||||
|
|
||||||
"github.com/containerd/containerd/pkg/blockio"
|
"github.com/containerd/containerd/pkg/blockio"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ func (c *criService) blockIOClassFromAnnotations(containerName string, container
|
|||||||
if cls != "" && !blockio.IsEnabled() {
|
if cls != "" && !blockio.IsEnabled() {
|
||||||
if c.config.ContainerdConfig.IgnoreBlockIONotEnabledErrors {
|
if c.config.ContainerdConfig.IgnoreBlockIONotEnabledErrors {
|
||||||
cls = ""
|
cls = ""
|
||||||
logrus.Debugf("continuing create container %s, ignoring blockio not enabled (%v)", containerName, err)
|
log.L.Debugf("continuing create container %s, ignoring blockio not enabled (%v)", containerName, err)
|
||||||
} else {
|
} else {
|
||||||
return "", fmt.Errorf("blockio disabled, refusing to set blockio class of container %q to %q", containerName, cls)
|
return "", fmt.Errorf("blockio disabled, refusing to set blockio class of container %q to %q", containerName, cls)
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,9 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/go-cni"
|
"github.com/containerd/go-cni"
|
||||||
"github.com/fsnotify/fsnotify"
|
"github.com/fsnotify/fsnotify"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// cniNetConfSyncer is used to reload cni network conf triggered by fs change
|
// cniNetConfSyncer is used to reload cni network conf triggered by fs change
|
||||||
@ -70,7 +70,7 @@ func newCNINetConfSyncer(confDir string, netPlugin cni.CNI, loadOpts []cni.Opt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := syncer.netPlugin.Load(syncer.loadOpts...); err != nil {
|
if err := syncer.netPlugin.Load(syncer.loadOpts...); err != nil {
|
||||||
logrus.WithError(err).Error("failed to load cni during init, please check CRI plugin status before setting up network for pods")
|
log.L.WithError(err).Error("failed to load cni during init, please check CRI plugin status before setting up network for pods")
|
||||||
syncer.updateLastStatus(err)
|
syncer.updateLastStatus(err)
|
||||||
}
|
}
|
||||||
return syncer, nil
|
return syncer, nil
|
||||||
@ -83,7 +83,7 @@ func (syncer *cniNetConfSyncer) syncLoop() error {
|
|||||||
select {
|
select {
|
||||||
case event, ok := <-syncer.watcher.Events:
|
case event, ok := <-syncer.watcher.Events:
|
||||||
if !ok {
|
if !ok {
|
||||||
logrus.Debugf("cni watcher channel is closed")
|
log.L.Debugf("cni watcher channel is closed")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// Only reload config when receiving write/rename/remove
|
// Only reload config when receiving write/rename/remove
|
||||||
@ -92,21 +92,21 @@ func (syncer *cniNetConfSyncer) syncLoop() error {
|
|||||||
// TODO(fuweid): Might only reload target cni config
|
// TODO(fuweid): Might only reload target cni config
|
||||||
// files to prevent no-ops.
|
// files to prevent no-ops.
|
||||||
if event.Has(fsnotify.Chmod) || event.Has(fsnotify.Create) {
|
if event.Has(fsnotify.Chmod) || event.Has(fsnotify.Create) {
|
||||||
logrus.Debugf("ignore event from cni conf dir: %s", event)
|
log.L.Debugf("ignore event from cni conf dir: %s", event)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
logrus.Debugf("receiving change event from cni conf dir: %s", event)
|
log.L.Debugf("receiving change event from cni conf dir: %s", event)
|
||||||
|
|
||||||
lerr := syncer.netPlugin.Load(syncer.loadOpts...)
|
lerr := syncer.netPlugin.Load(syncer.loadOpts...)
|
||||||
if lerr != nil {
|
if lerr != nil {
|
||||||
logrus.WithError(lerr).
|
log.L.WithError(lerr).
|
||||||
Errorf("failed to reload cni configuration after receiving fs change event(%s)", event)
|
Errorf("failed to reload cni configuration after receiving fs change event(%s)", event)
|
||||||
}
|
}
|
||||||
syncer.updateLastStatus(lerr)
|
syncer.updateLastStatus(lerr)
|
||||||
|
|
||||||
case err := <-syncer.watcher.Errors:
|
case err := <-syncer.watcher.Errors:
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Error("failed to continue sync cni conf change")
|
log.L.WithError(err).Error("failed to continue sync cni conf change")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import (
|
|||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
|
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -62,7 +61,7 @@ func (c *criService) RemoveContainer(ctx context.Context, r *runtime.RemoveConta
|
|||||||
state := container.Status.Get().State()
|
state := container.Status.Get().State()
|
||||||
if state == runtime.ContainerState_CONTAINER_RUNNING ||
|
if state == runtime.ContainerState_CONTAINER_RUNNING ||
|
||||||
state == runtime.ContainerState_CONTAINER_UNKNOWN {
|
state == runtime.ContainerState_CONTAINER_UNKNOWN {
|
||||||
logrus.Infof("Forcibly stopping container %q", id)
|
log.L.Infof("Forcibly stopping container %q", id)
|
||||||
if err := c.stopContainer(ctx, container, 0); err != nil {
|
if err := c.stopContainer(ctx, container, 0); err != nil {
|
||||||
return nil, fmt.Errorf("failed to forcibly stop container %q: %w", id, err)
|
return nil, fmt.Errorf("failed to forcibly stop container %q: %w", id, err)
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ import (
|
|||||||
containerdio "github.com/containerd/containerd/cio"
|
containerdio "github.com/containerd/containerd/cio"
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||||
|
|
||||||
cio "github.com/containerd/containerd/pkg/cri/io"
|
cio "github.com/containerd/containerd/pkg/cri/io"
|
||||||
@ -242,7 +241,7 @@ func (c *criService) createContainerLoggers(logPath string, tty bool) (stdout io
|
|||||||
if stderrCh != nil {
|
if stderrCh != nil {
|
||||||
<-stderrCh
|
<-stderrCh
|
||||||
}
|
}
|
||||||
logrus.Debugf("Finish redirecting log file %q, closing it", logPath)
|
log.L.Debugf("Finish redirecting log file %q, closing it", logPath)
|
||||||
f.Close()
|
f.Close()
|
||||||
}()
|
}()
|
||||||
} else {
|
} else {
|
||||||
|
@ -28,13 +28,13 @@ import (
|
|||||||
containerdio "github.com/containerd/containerd/cio"
|
containerdio "github.com/containerd/containerd/cio"
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/events"
|
"github.com/containerd/containerd/events"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/pkg/cri/constants"
|
"github.com/containerd/containerd/pkg/cri/constants"
|
||||||
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
|
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
|
||||||
sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox"
|
sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox"
|
||||||
ctrdutil "github.com/containerd/containerd/pkg/cri/util"
|
ctrdutil "github.com/containerd/containerd/pkg/cri/util"
|
||||||
"github.com/containerd/containerd/protobuf"
|
"github.com/containerd/containerd/protobuf"
|
||||||
"github.com/containerd/typeurl/v2"
|
"github.com/containerd/typeurl/v2"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||||
"k8s.io/utils/clock"
|
"k8s.io/utils/clock"
|
||||||
)
|
)
|
||||||
@ -115,7 +115,7 @@ func (em *eventMonitor) startSandboxExitMonitor(ctx context.Context, id string,
|
|||||||
case exitRes := <-exitCh:
|
case exitRes := <-exitCh:
|
||||||
exitStatus, exitedAt, err := exitRes.Result()
|
exitStatus, exitedAt, err := exitRes.Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("failed to get task exit status for %q", id)
|
log.L.WithError(err).Errorf("failed to get task exit status for %q", id)
|
||||||
exitStatus = unknownExitCode
|
exitStatus = unknownExitCode
|
||||||
exitedAt = time.Now()
|
exitedAt = time.Now()
|
||||||
}
|
}
|
||||||
@ -128,7 +128,7 @@ func (em *eventMonitor) startSandboxExitMonitor(ctx context.Context, id string,
|
|||||||
ExitedAt: protobuf.ToTimestamp(exitedAt),
|
ExitedAt: protobuf.ToTimestamp(exitedAt),
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("received exit event %+v", e)
|
log.L.Debugf("received exit event %+v", e)
|
||||||
|
|
||||||
err = func() error {
|
err = func() error {
|
||||||
dctx := ctrdutil.NamespacedContext()
|
dctx := ctrdutil.NamespacedContext()
|
||||||
@ -147,7 +147,7 @@ func (em *eventMonitor) startSandboxExitMonitor(ctx context.Context, id string,
|
|||||||
return nil
|
return nil
|
||||||
}()
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("failed to handle sandbox TaskExit event %+v", e)
|
log.L.WithError(err).Errorf("failed to handle sandbox TaskExit event %+v", e)
|
||||||
em.backOff.enBackOff(id, e)
|
em.backOff.enBackOff(id, e)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -166,7 +166,7 @@ func (em *eventMonitor) startContainerExitMonitor(ctx context.Context, id string
|
|||||||
case exitRes := <-exitCh:
|
case exitRes := <-exitCh:
|
||||||
exitStatus, exitedAt, err := exitRes.Result()
|
exitStatus, exitedAt, err := exitRes.Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("failed to get task exit status for %q", id)
|
log.L.WithError(err).Errorf("failed to get task exit status for %q", id)
|
||||||
exitStatus = unknownExitCode
|
exitStatus = unknownExitCode
|
||||||
exitedAt = time.Now()
|
exitedAt = time.Now()
|
||||||
}
|
}
|
||||||
@ -179,7 +179,7 @@ func (em *eventMonitor) startContainerExitMonitor(ctx context.Context, id string
|
|||||||
ExitedAt: protobuf.ToTimestamp(exitedAt),
|
ExitedAt: protobuf.ToTimestamp(exitedAt),
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("received exit event %+v", e)
|
log.L.Debugf("received exit event %+v", e)
|
||||||
|
|
||||||
err = func() error {
|
err = func() error {
|
||||||
dctx := ctrdutil.NamespacedContext()
|
dctx := ctrdutil.NamespacedContext()
|
||||||
@ -198,7 +198,7 @@ func (em *eventMonitor) startContainerExitMonitor(ctx context.Context, id string
|
|||||||
return nil
|
return nil
|
||||||
}()
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("failed to handle container TaskExit event %+v", e)
|
log.L.WithError(err).Errorf("failed to handle container TaskExit event %+v", e)
|
||||||
em.backOff.enBackOff(id, e)
|
em.backOff.enBackOff(id, e)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -251,29 +251,29 @@ func (em *eventMonitor) start() <-chan error {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case e := <-em.ch:
|
case e := <-em.ch:
|
||||||
logrus.Debugf("Received containerd event timestamp - %v, namespace - %q, topic - %q", e.Timestamp, e.Namespace, e.Topic)
|
log.L.Debugf("Received containerd event timestamp - %v, namespace - %q, topic - %q", e.Timestamp, e.Namespace, e.Topic)
|
||||||
if e.Namespace != constants.K8sContainerdNamespace {
|
if e.Namespace != constants.K8sContainerdNamespace {
|
||||||
logrus.Debugf("Ignoring events in namespace - %q", e.Namespace)
|
log.L.Debugf("Ignoring events in namespace - %q", e.Namespace)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
id, evt, err := convertEvent(e.Event)
|
id, evt, err := convertEvent(e.Event)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("Failed to convert event %+v", e)
|
log.L.WithError(err).Errorf("Failed to convert event %+v", e)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if em.backOff.isInBackOff(id) {
|
if em.backOff.isInBackOff(id) {
|
||||||
logrus.Infof("Events for %q is in backoff, enqueue event %+v", id, evt)
|
log.L.Infof("Events for %q is in backoff, enqueue event %+v", id, evt)
|
||||||
em.backOff.enBackOff(id, evt)
|
em.backOff.enBackOff(id, evt)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if err := em.handleEvent(evt); err != nil {
|
if err := em.handleEvent(evt); err != nil {
|
||||||
logrus.WithError(err).Errorf("Failed to handle event %+v for %s", evt, id)
|
log.L.WithError(err).Errorf("Failed to handle event %+v for %s", evt, id)
|
||||||
em.backOff.enBackOff(id, evt)
|
em.backOff.enBackOff(id, evt)
|
||||||
}
|
}
|
||||||
case err := <-em.errCh:
|
case err := <-em.errCh:
|
||||||
// Close errCh in defer directly if there is no error.
|
// Close errCh in defer directly if there is no error.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Error("Failed to handle event stream")
|
log.L.WithError(err).Error("Failed to handle event stream")
|
||||||
errCh <- err
|
errCh <- err
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -283,7 +283,7 @@ func (em *eventMonitor) start() <-chan error {
|
|||||||
queue := em.backOff.deBackOff(id)
|
queue := em.backOff.deBackOff(id)
|
||||||
for i, any := range queue.events {
|
for i, any := range queue.events {
|
||||||
if err := em.handleEvent(any); err != nil {
|
if err := em.handleEvent(any); err != nil {
|
||||||
logrus.WithError(err).Errorf("Failed to handle backOff event %+v for %s", any, id)
|
log.L.WithError(err).Errorf("Failed to handle backOff event %+v for %s", any, id)
|
||||||
em.backOff.reBackOff(id, queue.events[i:], queue.duration)
|
em.backOff.reBackOff(id, queue.events[i:], queue.duration)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -310,7 +310,7 @@ func (em *eventMonitor) handleEvent(any interface{}) error {
|
|||||||
|
|
||||||
switch e := any.(type) {
|
switch e := any.(type) {
|
||||||
case *eventtypes.TaskExit:
|
case *eventtypes.TaskExit:
|
||||||
logrus.Infof("TaskExit event %+v", e)
|
log.L.Infof("TaskExit event %+v", e)
|
||||||
// Use ID instead of ContainerID to rule out TaskExit event for exec.
|
// Use ID instead of ContainerID to rule out TaskExit event for exec.
|
||||||
cntr, err := em.c.containerStore.Get(e.ID)
|
cntr, err := em.c.containerStore.Get(e.ID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -332,7 +332,7 @@ func (em *eventMonitor) handleEvent(any interface{}) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
case *eventtypes.TaskOOM:
|
case *eventtypes.TaskOOM:
|
||||||
logrus.Infof("TaskOOM event %+v", e)
|
log.L.Infof("TaskOOM event %+v", e)
|
||||||
// For TaskOOM, we only care which container it belongs to.
|
// For TaskOOM, we only care which container it belongs to.
|
||||||
cntr, err := em.c.containerStore.Get(e.ContainerID)
|
cntr, err := em.c.containerStore.Get(e.ContainerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -349,13 +349,13 @@ func (em *eventMonitor) handleEvent(any interface{}) error {
|
|||||||
return fmt.Errorf("failed to update container status for TaskOOM event: %w", err)
|
return fmt.Errorf("failed to update container status for TaskOOM event: %w", err)
|
||||||
}
|
}
|
||||||
case *eventtypes.ImageCreate:
|
case *eventtypes.ImageCreate:
|
||||||
logrus.Infof("ImageCreate event %+v", e)
|
log.L.Infof("ImageCreate event %+v", e)
|
||||||
return em.c.UpdateImage(ctx, e.Name)
|
return em.c.UpdateImage(ctx, e.Name)
|
||||||
case *eventtypes.ImageUpdate:
|
case *eventtypes.ImageUpdate:
|
||||||
logrus.Infof("ImageUpdate event %+v", e)
|
log.L.Infof("ImageUpdate event %+v", e)
|
||||||
return em.c.UpdateImage(ctx, e.Name)
|
return em.c.UpdateImage(ctx, e.Name)
|
||||||
case *eventtypes.ImageDelete:
|
case *eventtypes.ImageDelete:
|
||||||
logrus.Infof("ImageDelete event %+v", e)
|
log.L.Infof("ImageDelete event %+v", e)
|
||||||
return em.c.UpdateImage(ctx, e.Name)
|
return em.c.UpdateImage(ctx, e.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +402,7 @@ func handleContainerExit(ctx context.Context, e *eventtypes.TaskExit, cntr conta
|
|||||||
// Unknown state can only transit to EXITED state, so we need
|
// Unknown state can only transit to EXITED state, so we need
|
||||||
// to handle unknown state here.
|
// to handle unknown state here.
|
||||||
if status.Unknown {
|
if status.Unknown {
|
||||||
logrus.Debugf("Container %q transited from UNKNOWN to EXITED", cntr.ID)
|
log.L.Debugf("Container %q transited from UNKNOWN to EXITED", cntr.ID)
|
||||||
status.Unknown = false
|
status.Unknown = false
|
||||||
}
|
}
|
||||||
return status, nil
|
return status, nil
|
||||||
|
@ -27,14 +27,17 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
runhcsoptions "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
|
||||||
"github.com/containerd/typeurl/v2"
|
"github.com/containerd/typeurl/v2"
|
||||||
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
|
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/pelletier/go-toml"
|
||||||
|
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||||
|
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
"github.com/containerd/containerd/containers"
|
"github.com/containerd/containerd/containers"
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
clabels "github.com/containerd/containerd/labels"
|
clabels "github.com/containerd/containerd/labels"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
criconfig "github.com/containerd/containerd/pkg/cri/config"
|
criconfig "github.com/containerd/containerd/pkg/cri/config"
|
||||||
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
|
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
|
||||||
imagestore "github.com/containerd/containerd/pkg/cri/store/image"
|
imagestore "github.com/containerd/containerd/pkg/cri/store/image"
|
||||||
@ -42,10 +45,6 @@ import (
|
|||||||
runtimeoptions "github.com/containerd/containerd/pkg/runtimeoptions/v1"
|
runtimeoptions "github.com/containerd/containerd/pkg/runtimeoptions/v1"
|
||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
runcoptions "github.com/containerd/containerd/runtime/v2/runc/options"
|
runcoptions "github.com/containerd/containerd/runtime/v2/runc/options"
|
||||||
|
|
||||||
runhcsoptions "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
|
|
||||||
"github.com/pelletier/go-toml"
|
|
||||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Move common helpers for sbserver and podsandbox to a dedicated package once basic services are functinal.
|
// TODO: Move common helpers for sbserver and podsandbox to a dedicated package once basic services are functinal.
|
||||||
@ -254,7 +253,7 @@ func buildLabels(configLabels, imageConfigLabels map[string]string, containerTyp
|
|||||||
} else {
|
} else {
|
||||||
// In case the image label is invalid, we output a warning and skip adding it to the
|
// In case the image label is invalid, we output a warning and skip adding it to the
|
||||||
// container.
|
// container.
|
||||||
logrus.WithError(err).Warnf("unable to add image label with key %s to the container", k)
|
log.L.WithError(err).Warnf("unable to add image label with key %s to the container", k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// labels from the CRI request (config) will override labels in the image config
|
// labels from the CRI request (config) will override labels in the image config
|
||||||
@ -448,12 +447,12 @@ func copyResourcesToStatus(spec *runtimespec.Spec, status containerstore.Status)
|
|||||||
func (c *criService) generateAndSendContainerEvent(ctx context.Context, containerID string, sandboxID string, eventType runtime.ContainerEventType) {
|
func (c *criService) generateAndSendContainerEvent(ctx context.Context, containerID string, sandboxID string, eventType runtime.ContainerEventType) {
|
||||||
podSandboxStatus, err := c.getPodSandboxStatus(ctx, sandboxID)
|
podSandboxStatus, err := c.getPodSandboxStatus(ctx, sandboxID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Warnf("Failed to get podSandbox status for container event for sandboxID %q: %v. Sending the event with nil podSandboxStatus.", sandboxID, err)
|
log.G(ctx).Warnf("Failed to get podSandbox status for container event for sandboxID %q: %v. Sending the event with nil podSandboxStatus.", sandboxID, err)
|
||||||
podSandboxStatus = nil
|
podSandboxStatus = nil
|
||||||
}
|
}
|
||||||
containerStatuses, err := c.getContainerStatuses(ctx, sandboxID)
|
containerStatuses, err := c.getContainerStatuses(ctx, sandboxID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("Failed to get container statuses for container event for sandboxID %q: %v", sandboxID, err)
|
log.G(ctx).Errorf("Failed to get container statuses for container event for sandboxID %q: %v", sandboxID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
event := runtime.ContainerEventResponse{
|
event := runtime.ContainerEventResponse{
|
||||||
@ -468,7 +467,7 @@ func (c *criService) generateAndSendContainerEvent(ctx context.Context, containe
|
|||||||
select {
|
select {
|
||||||
case c.containerEventsChan <- event:
|
case c.containerEventsChan <- event:
|
||||||
default:
|
default:
|
||||||
logrus.Debugf("containerEventsChan is full, discarding event %+v", event)
|
log.G(ctx).Debugf("containerEventsChan is full, discarding event %+v", event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,11 +22,10 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
snapshot "github.com/containerd/containerd/snapshots"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
snapshotstore "github.com/containerd/containerd/pkg/cri/store/snapshot"
|
snapshotstore "github.com/containerd/containerd/pkg/cri/store/snapshot"
|
||||||
ctrdutil "github.com/containerd/containerd/pkg/cri/util"
|
ctrdutil "github.com/containerd/containerd/pkg/cri/util"
|
||||||
|
snapshot "github.com/containerd/containerd/snapshots"
|
||||||
)
|
)
|
||||||
|
|
||||||
// snapshotsSyncer syncs snapshot stats periodically. imagefs info and container stats
|
// snapshotsSyncer syncs snapshot stats periodically. imagefs info and container stats
|
||||||
@ -60,7 +59,7 @@ func (s *snapshotsSyncer) start() {
|
|||||||
// check the resource usage and optimize this.
|
// check the resource usage and optimize this.
|
||||||
for {
|
for {
|
||||||
if err := s.sync(); err != nil {
|
if err := s.sync(); err != nil {
|
||||||
logrus.WithError(err).Error("Failed to sync snapshot stats")
|
log.L.WithError(err).Error("Failed to sync snapshot stats")
|
||||||
}
|
}
|
||||||
<-tick.C
|
<-tick.C
|
||||||
}
|
}
|
||||||
@ -101,7 +100,7 @@ func (s *snapshotsSyncer) sync() error {
|
|||||||
usage, err := s.snapshotter.Usage(ctx, info.Name)
|
usage, err := s.snapshotter.Usage(ctx, info.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errdefs.IsNotFound(err) {
|
if !errdefs.IsNotFound(err) {
|
||||||
logrus.WithError(err).Errorf("Failed to get usage for snapshot %q", info.Name)
|
log.L.WithError(err).Errorf("Failed to get usage for snapshot %q", info.Name)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/containerd/containerd/log"
|
||||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||||
|
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
@ -122,11 +122,11 @@ func (c *Controller) waitSandboxExit(ctx context.Context, id string, exitCh <-ch
|
|||||||
exitedAt = time.Now()
|
exitedAt = time.Now()
|
||||||
select {
|
select {
|
||||||
case exitRes := <-exitCh:
|
case exitRes := <-exitCh:
|
||||||
logrus.Debugf("received sandbox exit %+v", exitRes)
|
log.G(ctx).Debugf("received sandbox exit %+v", exitRes)
|
||||||
|
|
||||||
exitStatus, exitedAt, err = exitRes.Result()
|
exitStatus, exitedAt, err = exitRes.Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("failed to get task exit status for %q", id)
|
log.G(ctx).WithError(err).Errorf("failed to get task exit status for %q", id)
|
||||||
exitStatus = unknownExitCode
|
exitStatus = unknownExitCode
|
||||||
exitedAt = time.Now()
|
exitedAt = time.Now()
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ func (c *Controller) waitSandboxExit(ctx context.Context, id string, exitCh <-ch
|
|||||||
return nil
|
return nil
|
||||||
}()
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("failed to handle sandbox TaskExit %s", id)
|
log.G(ctx).WithError(err).Errorf("failed to handle sandbox TaskExit %s", id)
|
||||||
// Don't backoff, the caller is responsible for.
|
// Don't backoff, the caller is responsible for.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,7 @@ package sbserver
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/containerd/containerd/log"
|
||||||
|
|
||||||
"github.com/containerd/containerd/pkg/rdt"
|
"github.com/containerd/containerd/pkg/rdt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -40,7 +39,7 @@ func (c *criService) rdtClassFromAnnotations(containerName string, containerAnno
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !rdt.IsEnabled() && c.config.ContainerdConfig.IgnoreRdtNotEnabledErrors {
|
if !rdt.IsEnabled() && c.config.ContainerdConfig.IgnoreRdtNotEnabledErrors {
|
||||||
logrus.Debugf("continuing create container %s, ignoring rdt not enabled (%v)", containerName, err)
|
log.L.Debugf("continuing create container %s, ignoring rdt not enabled (%v)", containerName, err)
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -49,7 +48,7 @@ func (c *criService) RemovePodSandbox(ctx context.Context, r *runtime.RemovePodS
|
|||||||
// If the sandbox is still running, not ready, or in an unknown state, forcibly stop it.
|
// If the sandbox is still running, not ready, or in an unknown state, forcibly stop it.
|
||||||
// Even if it's in a NotReady state, this will close its network namespace, if open.
|
// Even if it's in a NotReady state, this will close its network namespace, if open.
|
||||||
// This can happen if the task process associated with the Pod died or it was killed.
|
// This can happen if the task process associated with the Pod died or it was killed.
|
||||||
logrus.Infof("Forcibly stopping sandbox %q", id)
|
log.G(ctx).Infof("Forcibly stopping sandbox %q", id)
|
||||||
if err := c.stopPodSandbox(ctx, sandbox); err != nil {
|
if err := c.stopPodSandbox(ctx, sandbox); err != nil {
|
||||||
return nil, fmt.Errorf("failed to forcibly stop sandbox %q: %w", id, err)
|
return nil, fmt.Errorf("failed to forcibly stop sandbox %q: %w", id, err)
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@ import (
|
|||||||
"github.com/containerd/go-cni"
|
"github.com/containerd/go-cni"
|
||||||
"github.com/containerd/typeurl/v2"
|
"github.com/containerd/typeurl/v2"
|
||||||
"github.com/hashicorp/go-multierror"
|
"github.com/hashicorp/go-multierror"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||||
|
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
@ -598,7 +597,7 @@ func (c *criService) getSandboxController(config *runtime.PodSandboxConfig, runt
|
|||||||
}
|
}
|
||||||
|
|
||||||
func logDebugCNIResult(ctx context.Context, sandboxID string, result *cni.Result) {
|
func logDebugCNIResult(ctx context.Context, sandboxID string, result *cni.Result) {
|
||||||
if logrus.GetLevel() < logrus.DebugLevel {
|
if log.GetLevel() < log.DebugLevel {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cniResult, err := json.Marshal(result)
|
cniResult, err := json.Marshal(result)
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/oci"
|
"github.com/containerd/containerd/oci"
|
||||||
"github.com/containerd/containerd/pkg/cri/instrument"
|
"github.com/containerd/containerd/pkg/cri/instrument"
|
||||||
"github.com/containerd/containerd/pkg/cri/nri"
|
"github.com/containerd/containerd/pkg/cri/nri"
|
||||||
@ -39,7 +40,6 @@ import (
|
|||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
"github.com/containerd/containerd/sandbox"
|
"github.com/containerd/containerd/sandbox"
|
||||||
"github.com/containerd/go-cni"
|
"github.com/containerd/go-cni"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ func NewCRIService(config criconfig.Config, client *containerd.Client, nri *nri.
|
|||||||
}
|
}
|
||||||
|
|
||||||
imageFSPath := imageFSPath(config.ContainerdRootDir, config.ContainerdConfig.Snapshotter)
|
imageFSPath := imageFSPath(config.ContainerdRootDir, config.ContainerdConfig.Snapshotter)
|
||||||
logrus.Infof("Get image filesystem path %q", imageFSPath)
|
log.L.Infof("Get image filesystem path %q", imageFSPath)
|
||||||
|
|
||||||
// TODO: expose this as a separate containerd plugin.
|
// TODO: expose this as a separate containerd plugin.
|
||||||
imageService, err := images.NewService(config, imageFSPath, client)
|
imageService, err := images.NewService(config, imageFSPath, client)
|
||||||
@ -238,16 +238,16 @@ func (c *criService) RegisterTCP(s *grpc.Server) error {
|
|||||||
|
|
||||||
// Run starts the CRI service.
|
// Run starts the CRI service.
|
||||||
func (c *criService) Run() error {
|
func (c *criService) Run() error {
|
||||||
logrus.Info("Start subscribing containerd event")
|
log.L.Info("Start subscribing containerd event")
|
||||||
c.eventMonitor.subscribe(c.client)
|
c.eventMonitor.subscribe(c.client)
|
||||||
|
|
||||||
logrus.Infof("Start recovering state")
|
log.L.Infof("Start recovering state")
|
||||||
if err := c.recover(ctrdutil.NamespacedContext()); err != nil {
|
if err := c.recover(ctrdutil.NamespacedContext()); err != nil {
|
||||||
return fmt.Errorf("failed to recover state: %w", err)
|
return fmt.Errorf("failed to recover state: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start event handler.
|
// Start event handler.
|
||||||
logrus.Info("Start event monitor")
|
log.L.Info("Start event monitor")
|
||||||
eventMonitorErrCh := c.eventMonitor.start()
|
eventMonitorErrCh := c.eventMonitor.start()
|
||||||
|
|
||||||
// Start CNI network conf syncers
|
// Start CNI network conf syncers
|
||||||
@ -255,7 +255,7 @@ func (c *criService) Run() error {
|
|||||||
var netSyncGroup sync.WaitGroup
|
var netSyncGroup sync.WaitGroup
|
||||||
for name, h := range c.cniNetConfMonitor {
|
for name, h := range c.cniNetConfMonitor {
|
||||||
netSyncGroup.Add(1)
|
netSyncGroup.Add(1)
|
||||||
logrus.Infof("Start cni network conf syncer for %s", name)
|
log.L.Infof("Start cni network conf syncer for %s", name)
|
||||||
go func(h *cniNetConfSyncer) {
|
go func(h *cniNetConfSyncer) {
|
||||||
cniNetConfMonitorErrCh <- h.syncLoop()
|
cniNetConfMonitorErrCh <- h.syncLoop()
|
||||||
netSyncGroup.Done()
|
netSyncGroup.Done()
|
||||||
@ -274,12 +274,12 @@ func (c *criService) Run() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start streaming server.
|
// Start streaming server.
|
||||||
logrus.Info("Start streaming server")
|
log.L.Info("Start streaming server")
|
||||||
streamServerErrCh := make(chan error)
|
streamServerErrCh := make(chan error)
|
||||||
go func() {
|
go func() {
|
||||||
defer close(streamServerErrCh)
|
defer close(streamServerErrCh)
|
||||||
if err := c.streamServer.Start(true); err != nil && err != http.ErrServerClosed {
|
if err := c.streamServer.Start(true); err != nil && err != http.ErrServerClosed {
|
||||||
logrus.WithError(err).Error("Failed to start streaming server")
|
log.L.WithError(err).Error("Failed to start streaming server")
|
||||||
streamServerErrCh <- err
|
streamServerErrCh <- err
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -307,11 +307,11 @@ func (c *criService) Run() error {
|
|||||||
if err := <-eventMonitorErrCh; err != nil {
|
if err := <-eventMonitorErrCh; err != nil {
|
||||||
eventMonitorErr = err
|
eventMonitorErr = err
|
||||||
}
|
}
|
||||||
logrus.Info("Event monitor stopped")
|
log.L.Info("Event monitor stopped")
|
||||||
if err := <-streamServerErrCh; err != nil {
|
if err := <-streamServerErrCh; err != nil {
|
||||||
streamServerErr = err
|
streamServerErr = err
|
||||||
}
|
}
|
||||||
logrus.Info("Stream server stopped")
|
log.L.Info("Stream server stopped")
|
||||||
if eventMonitorErr != nil {
|
if eventMonitorErr != nil {
|
||||||
return fmt.Errorf("event monitor error: %w", eventMonitorErr)
|
return fmt.Errorf("event monitor error: %w", eventMonitorErr)
|
||||||
}
|
}
|
||||||
@ -327,10 +327,10 @@ func (c *criService) Run() error {
|
|||||||
// Close stops the CRI service.
|
// Close stops the CRI service.
|
||||||
// TODO(random-liu): Make close synchronous.
|
// TODO(random-liu): Make close synchronous.
|
||||||
func (c *criService) Close() error {
|
func (c *criService) Close() error {
|
||||||
logrus.Info("Stop CRI service")
|
log.L.Info("Stop CRI service")
|
||||||
for name, h := range c.cniNetConfMonitor {
|
for name, h := range c.cniNetConfMonitor {
|
||||||
if err := h.stop(); err != nil {
|
if err := h.stop(); err != nil {
|
||||||
logrus.WithError(err).Errorf("failed to stop cni network conf monitor for %s", name)
|
log.L.WithError(err).Errorf("failed to stop cni network conf monitor for %s", name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.eventMonitor.stop()
|
c.eventMonitor.stop()
|
||||||
|
@ -20,11 +20,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/container-orchestrated-devices/container-device-interface/pkg/cdi"
|
"github.com/container-orchestrated-devices/container-device-interface/pkg/cdi"
|
||||||
|
"github.com/opencontainers/selinux/go-selinux"
|
||||||
|
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/pkg/cap"
|
"github.com/containerd/containerd/pkg/cap"
|
||||||
"github.com/containerd/containerd/pkg/userns"
|
"github.com/containerd/containerd/pkg/userns"
|
||||||
"github.com/containerd/go-cni"
|
"github.com/containerd/go-cni"
|
||||||
"github.com/opencontainers/selinux/go-selinux"
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// networkAttachCount is the minimum number of networks the PodSandbox
|
// networkAttachCount is the minimum number of networks the PodSandbox
|
||||||
@ -35,13 +36,13 @@ const networkAttachCount = 2
|
|||||||
func (c *criService) initPlatform() (err error) {
|
func (c *criService) initPlatform() (err error) {
|
||||||
if userns.RunningInUserNS() {
|
if userns.RunningInUserNS() {
|
||||||
if !(c.config.DisableCgroup && !c.apparmorEnabled() && c.config.RestrictOOMScoreAdj) {
|
if !(c.config.DisableCgroup && !c.apparmorEnabled() && c.config.RestrictOOMScoreAdj) {
|
||||||
logrus.Warn("Running containerd in a user namespace typically requires disable_cgroup, disable_apparmor, restrict_oom_score_adj set to be true")
|
log.L.Warn("Running containerd in a user namespace typically requires disable_cgroup, disable_apparmor, restrict_oom_score_adj set to be true")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.config.EnableSelinux {
|
if c.config.EnableSelinux {
|
||||||
if !selinux.GetEnabled() {
|
if !selinux.GetEnabled() {
|
||||||
logrus.Warn("Selinux is not supported")
|
log.L.Warn("Selinux is not supported")
|
||||||
}
|
}
|
||||||
if r := c.config.SelinuxCategoryRange; r > 0 {
|
if r := c.config.SelinuxCategoryRange; r > 0 {
|
||||||
selinux.CategoryRange = uint32(r)
|
selinux.CategoryRange = uint32(r)
|
||||||
|
@ -21,8 +21,7 @@ package server
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/containerd/containerd/log"
|
||||||
|
|
||||||
"github.com/containerd/containerd/pkg/blockio"
|
"github.com/containerd/containerd/pkg/blockio"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ func (c *criService) blockIOClassFromAnnotations(containerName string, container
|
|||||||
if cls != "" && !blockio.IsEnabled() {
|
if cls != "" && !blockio.IsEnabled() {
|
||||||
if c.config.ContainerdConfig.IgnoreBlockIONotEnabledErrors {
|
if c.config.ContainerdConfig.IgnoreBlockIONotEnabledErrors {
|
||||||
cls = ""
|
cls = ""
|
||||||
logrus.Debugf("continuing create container %s, ignoring blockio not enabled (%v)", containerName, err)
|
log.L.Debugf("continuing create container %s, ignoring blockio not enabled (%v)", containerName, err)
|
||||||
} else {
|
} else {
|
||||||
return "", fmt.Errorf("blockio disabled, refusing to set blockio class of container %q to %q", containerName, cls)
|
return "", fmt.Errorf("blockio disabled, refusing to set blockio class of container %q to %q", containerName, cls)
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,9 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
cni "github.com/containerd/go-cni"
|
cni "github.com/containerd/go-cni"
|
||||||
"github.com/fsnotify/fsnotify"
|
"github.com/fsnotify/fsnotify"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// cniNetConfSyncer is used to reload cni network conf triggered by fs change
|
// cniNetConfSyncer is used to reload cni network conf triggered by fs change
|
||||||
@ -70,7 +70,7 @@ func newCNINetConfSyncer(confDir string, netPlugin cni.CNI, loadOpts []cni.Opt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err := syncer.netPlugin.Load(syncer.loadOpts...); err != nil {
|
if err := syncer.netPlugin.Load(syncer.loadOpts...); err != nil {
|
||||||
logrus.WithError(err).Error("failed to load cni during init, please check CRI plugin status before setting up network for pods")
|
log.L.WithError(err).Error("failed to load cni during init, please check CRI plugin status before setting up network for pods")
|
||||||
syncer.updateLastStatus(err)
|
syncer.updateLastStatus(err)
|
||||||
}
|
}
|
||||||
return syncer, nil
|
return syncer, nil
|
||||||
@ -83,7 +83,7 @@ func (syncer *cniNetConfSyncer) syncLoop() error {
|
|||||||
select {
|
select {
|
||||||
case event, ok := <-syncer.watcher.Events:
|
case event, ok := <-syncer.watcher.Events:
|
||||||
if !ok {
|
if !ok {
|
||||||
logrus.Debugf("cni watcher channel is closed")
|
log.L.Debugf("cni watcher channel is closed")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// Only reload config when receiving write/rename/remove
|
// Only reload config when receiving write/rename/remove
|
||||||
@ -92,21 +92,21 @@ func (syncer *cniNetConfSyncer) syncLoop() error {
|
|||||||
// TODO(fuweid): Might only reload target cni config
|
// TODO(fuweid): Might only reload target cni config
|
||||||
// files to prevent no-ops.
|
// files to prevent no-ops.
|
||||||
if event.Has(fsnotify.Chmod) || event.Has(fsnotify.Create) {
|
if event.Has(fsnotify.Chmod) || event.Has(fsnotify.Create) {
|
||||||
logrus.Debugf("ignore event from cni conf dir: %s", event)
|
log.L.Debugf("ignore event from cni conf dir: %s", event)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
logrus.Debugf("receiving change event from cni conf dir: %s", event)
|
log.L.Debugf("receiving change event from cni conf dir: %s", event)
|
||||||
|
|
||||||
lerr := syncer.netPlugin.Load(syncer.loadOpts...)
|
lerr := syncer.netPlugin.Load(syncer.loadOpts...)
|
||||||
if lerr != nil {
|
if lerr != nil {
|
||||||
logrus.WithError(lerr).
|
log.L.WithError(lerr).
|
||||||
Errorf("failed to reload cni configuration after receiving fs change event(%s)", event)
|
Errorf("failed to reload cni configuration after receiving fs change event(%s)", event)
|
||||||
}
|
}
|
||||||
syncer.updateLastStatus(lerr)
|
syncer.updateLastStatus(lerr)
|
||||||
|
|
||||||
case err := <-syncer.watcher.Errors:
|
case err := <-syncer.watcher.Errors:
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Error("failed to continue sync cni conf change")
|
log.L.WithError(err).Error("failed to continue sync cni conf change")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import (
|
|||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
|
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -62,7 +61,7 @@ func (c *criService) RemoveContainer(ctx context.Context, r *runtime.RemoveConta
|
|||||||
state := container.Status.Get().State()
|
state := container.Status.Get().State()
|
||||||
if state == runtime.ContainerState_CONTAINER_RUNNING ||
|
if state == runtime.ContainerState_CONTAINER_RUNNING ||
|
||||||
state == runtime.ContainerState_CONTAINER_UNKNOWN {
|
state == runtime.ContainerState_CONTAINER_UNKNOWN {
|
||||||
logrus.Infof("Forcibly stopping container %q", id)
|
log.L.Infof("Forcibly stopping container %q", id)
|
||||||
if err := c.stopContainer(ctx, container, 0); err != nil {
|
if err := c.stopContainer(ctx, container, 0); err != nil {
|
||||||
return nil, fmt.Errorf("failed to forcibly stop container %q: %w", id, err)
|
return nil, fmt.Errorf("failed to forcibly stop container %q: %w", id, err)
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ import (
|
|||||||
containerdio "github.com/containerd/containerd/cio"
|
containerdio "github.com/containerd/containerd/cio"
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||||
|
|
||||||
cio "github.com/containerd/containerd/pkg/cri/io"
|
cio "github.com/containerd/containerd/pkg/cri/io"
|
||||||
@ -241,7 +240,7 @@ func (c *criService) createContainerLoggers(logPath string, tty bool) (stdout io
|
|||||||
if stderrCh != nil {
|
if stderrCh != nil {
|
||||||
<-stderrCh
|
<-stderrCh
|
||||||
}
|
}
|
||||||
logrus.Debugf("Finish redirecting log file %q, closing it", logPath)
|
log.L.Debugf("Finish redirecting log file %q, closing it", logPath)
|
||||||
f.Close()
|
f.Close()
|
||||||
}()
|
}()
|
||||||
} else {
|
} else {
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
containerdio "github.com/containerd/containerd/cio"
|
containerdio "github.com/containerd/containerd/cio"
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/events"
|
"github.com/containerd/containerd/events"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/pkg/cri/constants"
|
"github.com/containerd/containerd/pkg/cri/constants"
|
||||||
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
|
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
|
||||||
sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox"
|
sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox"
|
||||||
@ -115,7 +116,7 @@ func (em *eventMonitor) startSandboxExitMonitor(ctx context.Context, id string,
|
|||||||
case exitRes := <-exitCh:
|
case exitRes := <-exitCh:
|
||||||
exitStatus, exitedAt, err := exitRes.Result()
|
exitStatus, exitedAt, err := exitRes.Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("failed to get task exit status for %q", id)
|
log.L.WithError(err).Errorf("failed to get task exit status for %q", id)
|
||||||
exitStatus = unknownExitCode
|
exitStatus = unknownExitCode
|
||||||
exitedAt = time.Now()
|
exitedAt = time.Now()
|
||||||
}
|
}
|
||||||
@ -128,7 +129,7 @@ func (em *eventMonitor) startSandboxExitMonitor(ctx context.Context, id string,
|
|||||||
ExitedAt: protobuf.ToTimestamp(exitedAt),
|
ExitedAt: protobuf.ToTimestamp(exitedAt),
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("received exit event %+v", e)
|
log.L.Debugf("received exit event %+v", e)
|
||||||
|
|
||||||
err = func() error {
|
err = func() error {
|
||||||
dctx := ctrdutil.NamespacedContext()
|
dctx := ctrdutil.NamespacedContext()
|
||||||
@ -147,7 +148,7 @@ func (em *eventMonitor) startSandboxExitMonitor(ctx context.Context, id string,
|
|||||||
return nil
|
return nil
|
||||||
}()
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("failed to handle sandbox TaskExit event %+v", e)
|
log.L.WithError(err).Errorf("failed to handle sandbox TaskExit event %+v", e)
|
||||||
em.backOff.enBackOff(id, e)
|
em.backOff.enBackOff(id, e)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -166,7 +167,7 @@ func (em *eventMonitor) startContainerExitMonitor(ctx context.Context, id string
|
|||||||
case exitRes := <-exitCh:
|
case exitRes := <-exitCh:
|
||||||
exitStatus, exitedAt, err := exitRes.Result()
|
exitStatus, exitedAt, err := exitRes.Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("failed to get task exit status for %q", id)
|
log.L.WithError(err).Errorf("failed to get task exit status for %q", id)
|
||||||
exitStatus = unknownExitCode
|
exitStatus = unknownExitCode
|
||||||
exitedAt = time.Now()
|
exitedAt = time.Now()
|
||||||
}
|
}
|
||||||
@ -179,7 +180,7 @@ func (em *eventMonitor) startContainerExitMonitor(ctx context.Context, id string
|
|||||||
ExitedAt: protobuf.ToTimestamp(exitedAt),
|
ExitedAt: protobuf.ToTimestamp(exitedAt),
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("received exit event %+v", e)
|
log.L.Debugf("received exit event %+v", e)
|
||||||
|
|
||||||
err = func() error {
|
err = func() error {
|
||||||
dctx := ctrdutil.NamespacedContext()
|
dctx := ctrdutil.NamespacedContext()
|
||||||
@ -198,7 +199,7 @@ func (em *eventMonitor) startContainerExitMonitor(ctx context.Context, id string
|
|||||||
return nil
|
return nil
|
||||||
}()
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("failed to handle container TaskExit event %+v", e)
|
log.L.WithError(err).Errorf("failed to handle container TaskExit event %+v", e)
|
||||||
em.backOff.enBackOff(id, e)
|
em.backOff.enBackOff(id, e)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -251,14 +252,14 @@ func (em *eventMonitor) start() <-chan error {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case e := <-em.ch:
|
case e := <-em.ch:
|
||||||
logrus.Debugf("Received containerd event timestamp - %v, namespace - %q, topic - %q", e.Timestamp, e.Namespace, e.Topic)
|
log.L.Debugf("Received containerd event timestamp - %v, namespace - %q, topic - %q", e.Timestamp, e.Namespace, e.Topic)
|
||||||
if e.Namespace != constants.K8sContainerdNamespace {
|
if e.Namespace != constants.K8sContainerdNamespace {
|
||||||
logrus.Debugf("Ignoring events in namespace - %q", e.Namespace)
|
log.L.Debugf("Ignoring events in namespace - %q", e.Namespace)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
id, evt, err := convertEvent(e.Event)
|
id, evt, err := convertEvent(e.Event)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("Failed to convert event %+v", e)
|
log.L.WithError(err).Errorf("Failed to convert event %+v", e)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if em.backOff.isInBackOff(id) {
|
if em.backOff.isInBackOff(id) {
|
||||||
|
@ -30,6 +30,7 @@ import (
|
|||||||
"github.com/containerd/containerd/containers"
|
"github.com/containerd/containerd/containers"
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
clabels "github.com/containerd/containerd/labels"
|
clabels "github.com/containerd/containerd/labels"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
criconfig "github.com/containerd/containerd/pkg/cri/config"
|
criconfig "github.com/containerd/containerd/pkg/cri/config"
|
||||||
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
|
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
|
||||||
imagestore "github.com/containerd/containerd/pkg/cri/store/image"
|
imagestore "github.com/containerd/containerd/pkg/cri/store/image"
|
||||||
@ -295,7 +296,7 @@ func buildLabels(configLabels, imageConfigLabels map[string]string, containerTyp
|
|||||||
} else {
|
} else {
|
||||||
// In case the image label is invalid, we output a warning and skip adding it to the
|
// In case the image label is invalid, we output a warning and skip adding it to the
|
||||||
// container.
|
// container.
|
||||||
logrus.WithError(err).Warnf("unable to add image label with key %s to the container", k)
|
log.L.WithError(err).Warnf("unable to add image label with key %s to the container", k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// labels from the CRI request (config) will override labels in the image config
|
// labels from the CRI request (config) will override labels in the image config
|
||||||
@ -517,7 +518,7 @@ func copyResourcesToStatus(spec *runtimespec.Spec, status containerstore.Status)
|
|||||||
func (c *criService) generateAndSendContainerEvent(ctx context.Context, containerID string, sandboxID string, eventType runtime.ContainerEventType) {
|
func (c *criService) generateAndSendContainerEvent(ctx context.Context, containerID string, sandboxID string, eventType runtime.ContainerEventType) {
|
||||||
podSandboxStatus, err := c.getPodSandboxStatus(ctx, sandboxID)
|
podSandboxStatus, err := c.getPodSandboxStatus(ctx, sandboxID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Warnf("Failed to get podSandbox status for container event for sandboxID %q: %v. Sending the event with nil podSandboxStatus.", sandboxID, err)
|
log.L.Warnf("Failed to get podSandbox status for container event for sandboxID %q: %v. Sending the event with nil podSandboxStatus.", sandboxID, err)
|
||||||
podSandboxStatus = nil
|
podSandboxStatus = nil
|
||||||
}
|
}
|
||||||
containerStatuses, err := c.getContainerStatuses(ctx, sandboxID)
|
containerStatuses, err := c.getContainerStatuses(ctx, sandboxID)
|
||||||
|
@ -21,8 +21,7 @@ package server
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/containerd/containerd/log"
|
||||||
|
|
||||||
"github.com/containerd/containerd/pkg/rdt"
|
"github.com/containerd/containerd/pkg/rdt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -40,7 +39,7 @@ func (c *criService) rdtClassFromAnnotations(containerName string, containerAnno
|
|||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !rdt.IsEnabled() && c.config.ContainerdConfig.IgnoreRdtNotEnabledErrors {
|
if !rdt.IsEnabled() && c.config.ContainerdConfig.IgnoreRdtNotEnabledErrors {
|
||||||
logrus.Debugf("continuing create container %s, ignoring rdt not enabled (%v)", containerName, err)
|
log.L.Debugf("continuing create container %s, ignoring rdt not enabled (%v)", containerName, err)
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -25,7 +25,6 @@ import (
|
|||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -50,7 +49,7 @@ func (c *criService) RemovePodSandbox(ctx context.Context, r *runtime.RemovePodS
|
|||||||
// If the sandbox is still running, not ready, or in an unknown state, forcibly stop it.
|
// If the sandbox is still running, not ready, or in an unknown state, forcibly stop it.
|
||||||
// Even if it's in a NotReady state, this will close its network namespace, if open.
|
// Even if it's in a NotReady state, this will close its network namespace, if open.
|
||||||
// This can happen if the task process associated with the Pod died or it was killed.
|
// This can happen if the task process associated with the Pod died or it was killed.
|
||||||
logrus.Infof("Forcibly stopping sandbox %q", id)
|
log.L.Infof("Forcibly stopping sandbox %q", id)
|
||||||
if err := c.stopPodSandbox(ctx, sandbox); err != nil {
|
if err := c.stopPodSandbox(ctx, sandbox); err != nil {
|
||||||
return nil, fmt.Errorf("failed to forcibly stop sandbox %q: %w", id, err)
|
return nil, fmt.Errorf("failed to forcibly stop sandbox %q: %w", id, err)
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ import (
|
|||||||
"github.com/containerd/typeurl/v2"
|
"github.com/containerd/typeurl/v2"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
selinux "github.com/opencontainers/selinux/go-selinux"
|
selinux "github.com/opencontainers/selinux/go-selinux"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||||
|
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
@ -765,7 +764,7 @@ func (c *criService) getSandboxRuntime(config *runtime.PodSandboxConfig, runtime
|
|||||||
}
|
}
|
||||||
|
|
||||||
func logDebugCNIResult(ctx context.Context, sandboxID string, result *cni.Result) {
|
func logDebugCNIResult(ctx context.Context, sandboxID string, result *cni.Result) {
|
||||||
if logrus.GetLevel() < logrus.DebugLevel {
|
if log.GetLevel() < log.DebugLevel {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cniResult, err := json.Marshal(result)
|
cniResult, err := json.Marshal(result)
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/oci"
|
"github.com/containerd/containerd/oci"
|
||||||
"github.com/containerd/containerd/pkg/cri/instrument"
|
"github.com/containerd/containerd/pkg/cri/instrument"
|
||||||
"github.com/containerd/containerd/pkg/cri/nri"
|
"github.com/containerd/containerd/pkg/cri/nri"
|
||||||
@ -144,7 +145,7 @@ func NewCRIService(config criconfig.Config, client *containerd.Client, nri *nri.
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.imageFSPath = imageFSPath(config.ContainerdRootDir, config.ContainerdConfig.Snapshotter)
|
c.imageFSPath = imageFSPath(config.ContainerdRootDir, config.ContainerdConfig.Snapshotter)
|
||||||
logrus.Infof("Get image filesystem path %q", c.imageFSPath)
|
log.L.Infof("Get image filesystem path %q", c.imageFSPath)
|
||||||
|
|
||||||
if err := c.initPlatform(); err != nil {
|
if err := c.initPlatform(); err != nil {
|
||||||
return nil, fmt.Errorf("initialize platform: %w", err)
|
return nil, fmt.Errorf("initialize platform: %w", err)
|
||||||
@ -203,20 +204,20 @@ func (c *criService) RegisterTCP(s *grpc.Server) error {
|
|||||||
|
|
||||||
// Run starts the CRI service.
|
// Run starts the CRI service.
|
||||||
func (c *criService) Run() error {
|
func (c *criService) Run() error {
|
||||||
logrus.Info("Start subscribing containerd event")
|
log.L.Info("Start subscribing containerd event")
|
||||||
c.eventMonitor.subscribe(c.client)
|
c.eventMonitor.subscribe(c.client)
|
||||||
|
|
||||||
logrus.Infof("Start recovering state")
|
log.L.Infof("Start recovering state")
|
||||||
if err := c.recover(ctrdutil.NamespacedContext()); err != nil {
|
if err := c.recover(ctrdutil.NamespacedContext()); err != nil {
|
||||||
return fmt.Errorf("failed to recover state: %w", err)
|
return fmt.Errorf("failed to recover state: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start event handler.
|
// Start event handler.
|
||||||
logrus.Info("Start event monitor")
|
log.L.Info("Start event monitor")
|
||||||
eventMonitorErrCh := c.eventMonitor.start()
|
eventMonitorErrCh := c.eventMonitor.start()
|
||||||
|
|
||||||
// Start snapshot stats syncer, it doesn't need to be stopped.
|
// Start snapshot stats syncer, it doesn't need to be stopped.
|
||||||
logrus.Info("Start snapshots syncer")
|
log.L.Info("Start snapshots syncer")
|
||||||
snapshotsSyncer := newSnapshotsSyncer(
|
snapshotsSyncer := newSnapshotsSyncer(
|
||||||
c.snapshotStore,
|
c.snapshotStore,
|
||||||
c.client.SnapshotService(c.config.ContainerdConfig.Snapshotter),
|
c.client.SnapshotService(c.config.ContainerdConfig.Snapshotter),
|
||||||
@ -229,7 +230,7 @@ func (c *criService) Run() error {
|
|||||||
var netSyncGroup sync.WaitGroup
|
var netSyncGroup sync.WaitGroup
|
||||||
for name, h := range c.cniNetConfMonitor {
|
for name, h := range c.cniNetConfMonitor {
|
||||||
netSyncGroup.Add(1)
|
netSyncGroup.Add(1)
|
||||||
logrus.Infof("Start cni network conf syncer for %s", name)
|
log.L.Infof("Start cni network conf syncer for %s", name)
|
||||||
go func(h *cniNetConfSyncer) {
|
go func(h *cniNetConfSyncer) {
|
||||||
cniNetConfMonitorErrCh <- h.syncLoop()
|
cniNetConfMonitorErrCh <- h.syncLoop()
|
||||||
netSyncGroup.Done()
|
netSyncGroup.Done()
|
||||||
@ -248,12 +249,12 @@ func (c *criService) Run() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start streaming server.
|
// Start streaming server.
|
||||||
logrus.Info("Start streaming server")
|
log.L.Info("Start streaming server")
|
||||||
streamServerErrCh := make(chan error)
|
streamServerErrCh := make(chan error)
|
||||||
go func() {
|
go func() {
|
||||||
defer close(streamServerErrCh)
|
defer close(streamServerErrCh)
|
||||||
if err := c.streamServer.Start(true); err != nil && err != http.ErrServerClosed {
|
if err := c.streamServer.Start(true); err != nil && err != http.ErrServerClosed {
|
||||||
logrus.WithError(err).Error("Failed to start streaming server")
|
log.L.WithError(err).Error("Failed to start streaming server")
|
||||||
streamServerErrCh <- err
|
streamServerErrCh <- err
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -281,11 +282,11 @@ func (c *criService) Run() error {
|
|||||||
if err := <-eventMonitorErrCh; err != nil {
|
if err := <-eventMonitorErrCh; err != nil {
|
||||||
eventMonitorErr = err
|
eventMonitorErr = err
|
||||||
}
|
}
|
||||||
logrus.Info("Event monitor stopped")
|
log.L.Info("Event monitor stopped")
|
||||||
if err := <-streamServerErrCh; err != nil {
|
if err := <-streamServerErrCh; err != nil {
|
||||||
streamServerErr = err
|
streamServerErr = err
|
||||||
}
|
}
|
||||||
logrus.Info("Stream server stopped")
|
log.L.Info("Stream server stopped")
|
||||||
if eventMonitorErr != nil {
|
if eventMonitorErr != nil {
|
||||||
return fmt.Errorf("event monitor error: %w", eventMonitorErr)
|
return fmt.Errorf("event monitor error: %w", eventMonitorErr)
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/container-orchestrated-devices/container-device-interface/pkg/cdi"
|
"github.com/container-orchestrated-devices/container-device-interface/pkg/cdi"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/pkg/cap"
|
"github.com/containerd/containerd/pkg/cap"
|
||||||
"github.com/containerd/containerd/pkg/userns"
|
"github.com/containerd/containerd/pkg/userns"
|
||||||
cni "github.com/containerd/go-cni"
|
cni "github.com/containerd/go-cni"
|
||||||
"github.com/opencontainers/selinux/go-selinux"
|
"github.com/opencontainers/selinux/go-selinux"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// networkAttachCount is the minimum number of networks the PodSandbox
|
// networkAttachCount is the minimum number of networks the PodSandbox
|
||||||
@ -35,13 +35,13 @@ const networkAttachCount = 2
|
|||||||
func (c *criService) initPlatform() (err error) {
|
func (c *criService) initPlatform() (err error) {
|
||||||
if userns.RunningInUserNS() {
|
if userns.RunningInUserNS() {
|
||||||
if !(c.config.DisableCgroup && !c.apparmorEnabled() && c.config.RestrictOOMScoreAdj) {
|
if !(c.config.DisableCgroup && !c.apparmorEnabled() && c.config.RestrictOOMScoreAdj) {
|
||||||
logrus.Warn("Running containerd in a user namespace typically requires disable_cgroup, disable_apparmor, restrict_oom_score_adj set to be true")
|
log.L.Warn("Running containerd in a user namespace typically requires disable_cgroup, disable_apparmor, restrict_oom_score_adj set to be true")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.config.EnableSelinux {
|
if c.config.EnableSelinux {
|
||||||
if !selinux.GetEnabled() {
|
if !selinux.GetEnabled() {
|
||||||
logrus.Warn("Selinux is not supported")
|
log.L.Warn("Selinux is not supported")
|
||||||
}
|
}
|
||||||
if r := c.config.SelinuxCategoryRange; r > 0 {
|
if r := c.config.SelinuxCategoryRange; r > 0 {
|
||||||
selinux.CategoryRange = uint32(r)
|
selinux.CategoryRange = uint32(r)
|
||||||
|
@ -22,11 +22,10 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
snapshot "github.com/containerd/containerd/snapshots"
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
snapshotstore "github.com/containerd/containerd/pkg/cri/store/snapshot"
|
snapshotstore "github.com/containerd/containerd/pkg/cri/store/snapshot"
|
||||||
ctrdutil "github.com/containerd/containerd/pkg/cri/util"
|
ctrdutil "github.com/containerd/containerd/pkg/cri/util"
|
||||||
|
snapshot "github.com/containerd/containerd/snapshots"
|
||||||
)
|
)
|
||||||
|
|
||||||
// snapshotsSyncer syncs snapshot stats periodically. imagefs info and container stats
|
// snapshotsSyncer syncs snapshot stats periodically. imagefs info and container stats
|
||||||
@ -60,7 +59,7 @@ func (s *snapshotsSyncer) start() {
|
|||||||
// check the resource usage and optimize this.
|
// check the resource usage and optimize this.
|
||||||
for {
|
for {
|
||||||
if err := s.sync(); err != nil {
|
if err := s.sync(); err != nil {
|
||||||
logrus.WithError(err).Error("Failed to sync snapshot stats")
|
log.L.WithError(err).Error("Failed to sync snapshot stats")
|
||||||
}
|
}
|
||||||
<-tick.C
|
<-tick.C
|
||||||
}
|
}
|
||||||
@ -101,7 +100,7 @@ func (s *snapshotsSyncer) sync() error {
|
|||||||
usage, err := s.snapshotter.Usage(ctx, info.Name)
|
usage, err := s.snapshotter.Usage(ctx, info.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if !errdefs.IsNotFound(err) {
|
if !errdefs.IsNotFound(err) {
|
||||||
logrus.WithError(err).Errorf("Failed to get usage for snapshot %q", info.Name)
|
log.L.WithError(err).Errorf("Failed to get usage for snapshot %q", info.Name)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -32,13 +32,13 @@ import (
|
|||||||
"github.com/containerd/console"
|
"github.com/containerd/console"
|
||||||
"github.com/containerd/containerd/api/runtime/task/v2"
|
"github.com/containerd/containerd/api/runtime/task/v2"
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/mount"
|
"github.com/containerd/containerd/mount"
|
||||||
"github.com/containerd/containerd/namespaces"
|
"github.com/containerd/containerd/namespaces"
|
||||||
"github.com/containerd/containerd/pkg/process"
|
"github.com/containerd/containerd/pkg/process"
|
||||||
"github.com/containerd/containerd/pkg/stdio"
|
"github.com/containerd/containerd/pkg/stdio"
|
||||||
"github.com/containerd/containerd/runtime/v2/runc/options"
|
"github.com/containerd/containerd/runtime/v2/runc/options"
|
||||||
"github.com/containerd/typeurl/v2"
|
"github.com/containerd/typeurl/v2"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewContainer returns a new runc container
|
// NewContainer returns a new runc container
|
||||||
@ -111,7 +111,7 @@ func NewContainer(ctx context.Context, platform stdio.Platform, r *task.CreateTa
|
|||||||
defer func() {
|
defer func() {
|
||||||
if retErr != nil {
|
if retErr != nil {
|
||||||
if err := mount.UnmountMounts(mounts, rootfs, 0); err != nil {
|
if err := mount.UnmountMounts(mounts, rootfs, 0); err != nil {
|
||||||
logrus.WithError(err).Warn("failed to cleanup rootfs mount")
|
log.G(ctx).WithError(err).Warn("failed to cleanup rootfs mount")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -148,17 +148,17 @@ func NewContainer(ctx context.Context, platform stdio.Platform, r *task.CreateTa
|
|||||||
if cgroups.Mode() == cgroups.Unified {
|
if cgroups.Mode() == cgroups.Unified {
|
||||||
g, err := cgroupsv2.PidGroupPath(pid)
|
g, err := cgroupsv2.PidGroupPath(pid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("loading cgroup2 for %d", pid)
|
log.G(ctx).WithError(err).Errorf("loading cgroup2 for %d", pid)
|
||||||
return container, nil
|
return container, nil
|
||||||
}
|
}
|
||||||
cg, err = cgroupsv2.Load(g)
|
cg, err = cgroupsv2.Load(g)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("loading cgroup2 for %d", pid)
|
log.G(ctx).WithError(err).Errorf("loading cgroup2 for %d", pid)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cg, err = cgroup1.Load(cgroup1.PidPath(pid))
|
cg, err = cgroup1.Load(cgroup1.PidPath(pid))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("loading cgroup for %d", pid)
|
log.G(ctx).WithError(err).Errorf("loading cgroup for %d", pid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
container.cgroup = cg
|
container.cgroup = cg
|
||||||
@ -369,16 +369,16 @@ func (c *Container) Start(ctx context.Context, r *task.StartRequest) (process.Pr
|
|||||||
if cgroups.Mode() == cgroups.Unified {
|
if cgroups.Mode() == cgroups.Unified {
|
||||||
g, err := cgroupsv2.PidGroupPath(p.Pid())
|
g, err := cgroupsv2.PidGroupPath(p.Pid())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("loading cgroup2 for %d", p.Pid())
|
log.G(ctx).WithError(err).Errorf("loading cgroup2 for %d", p.Pid())
|
||||||
}
|
}
|
||||||
cg, err = cgroupsv2.Load(g)
|
cg, err = cgroupsv2.Load(g)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("loading cgroup2 for %d", p.Pid())
|
log.G(ctx).WithError(err).Errorf("loading cgroup2 for %d", p.Pid())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cg, err = cgroup1.Load(cgroup1.PidPath(p.Pid()))
|
cg, err = cgroup1.Load(cgroup1.PidPath(p.Pid()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("loading cgroup for %d", p.Pid())
|
log.G(ctx).WithError(err).Errorf("loading cgroup for %d", p.Pid())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.cgroup = cg
|
c.cgroup = cg
|
||||||
|
@ -23,9 +23,9 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/containerd/containerd/api/types"
|
"github.com/containerd/containerd/api/types"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/pkg/shutdown"
|
"github.com/containerd/containerd/pkg/shutdown"
|
||||||
"github.com/containerd/ttrpc"
|
"github.com/containerd/ttrpc"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
api "github.com/containerd/containerd/api/runtime/sandbox/v1"
|
api "github.com/containerd/containerd/api/runtime/sandbox/v1"
|
||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
@ -64,17 +64,17 @@ func (p *pauseService) RegisterTTRPC(server *ttrpc.Server) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *pauseService) CreateSandbox(ctx context.Context, req *api.CreateSandboxRequest) (*api.CreateSandboxResponse, error) {
|
func (p *pauseService) CreateSandbox(ctx context.Context, req *api.CreateSandboxRequest) (*api.CreateSandboxResponse, error) {
|
||||||
log.Debugf("create sandbox request: %+v", req)
|
log.G(ctx).Debugf("create sandbox request: %+v", req)
|
||||||
return &api.CreateSandboxResponse{}, nil
|
return &api.CreateSandboxResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pauseService) StartSandbox(ctx context.Context, req *api.StartSandboxRequest) (*api.StartSandboxResponse, error) {
|
func (p *pauseService) StartSandbox(ctx context.Context, req *api.StartSandboxRequest) (*api.StartSandboxResponse, error) {
|
||||||
log.Debugf("start sandbox request: %+v", req)
|
log.G(ctx).Debugf("start sandbox request: %+v", req)
|
||||||
return &api.StartSandboxResponse{}, nil
|
return &api.StartSandboxResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pauseService) Platform(ctx context.Context, req *api.PlatformRequest) (*api.PlatformResponse, error) {
|
func (p *pauseService) Platform(ctx context.Context, req *api.PlatformRequest) (*api.PlatformResponse, error) {
|
||||||
log.Debugf("platform request: %+v", req)
|
log.G(ctx).Debugf("platform request: %+v", req)
|
||||||
|
|
||||||
platform := types.Platform{
|
platform := types.Platform{
|
||||||
OS: runtime.GOOS,
|
OS: runtime.GOOS,
|
||||||
@ -85,7 +85,7 @@ func (p *pauseService) Platform(ctx context.Context, req *api.PlatformRequest) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *pauseService) StopSandbox(ctx context.Context, req *api.StopSandboxRequest) (*api.StopSandboxResponse, error) {
|
func (p *pauseService) StopSandbox(ctx context.Context, req *api.StopSandboxRequest) (*api.StopSandboxResponse, error) {
|
||||||
log.Debugf("stop sandbox request: %+v", req)
|
log.G(ctx).Debugf("stop sandbox request: %+v", req)
|
||||||
p.shutdown.Shutdown()
|
p.shutdown.Shutdown()
|
||||||
return &api.StopSandboxResponse{}, nil
|
return &api.StopSandboxResponse{}, nil
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ func (p *pauseService) WaitSandbox(ctx context.Context, req *api.WaitSandboxRequ
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *pauseService) SandboxStatus(ctx context.Context, req *api.SandboxStatusRequest) (*api.SandboxStatusResponse, error) {
|
func (p *pauseService) SandboxStatus(ctx context.Context, req *api.SandboxStatusRequest) (*api.SandboxStatusResponse, error) {
|
||||||
log.Debugf("sandbox status request: %+v", req)
|
log.G(ctx).Debugf("sandbox status request: %+v", req)
|
||||||
return &api.SandboxStatusResponse{}, nil
|
return &api.SandboxStatusResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ import (
|
|||||||
taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
|
taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
|
||||||
"github.com/containerd/containerd/api/types/task"
|
"github.com/containerd/containerd/api/types/task"
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/namespaces"
|
"github.com/containerd/containerd/namespaces"
|
||||||
"github.com/containerd/containerd/pkg/oom"
|
"github.com/containerd/containerd/pkg/oom"
|
||||||
oomv1 "github.com/containerd/containerd/pkg/oom/v1"
|
oomv1 "github.com/containerd/containerd/pkg/oom/v1"
|
||||||
@ -48,7 +49,6 @@ import (
|
|||||||
runcC "github.com/containerd/go-runc"
|
runcC "github.com/containerd/go-runc"
|
||||||
"github.com/containerd/ttrpc"
|
"github.com/containerd/ttrpc"
|
||||||
"github.com/containerd/typeurl/v2"
|
"github.com/containerd/typeurl/v2"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -170,23 +170,23 @@ func (s *service) Start(ctx context.Context, r *taskAPI.StartRequest) (*taskAPI.
|
|||||||
switch cg := container.Cgroup().(type) {
|
switch cg := container.Cgroup().(type) {
|
||||||
case cgroup1.Cgroup:
|
case cgroup1.Cgroup:
|
||||||
if err := s.ep.Add(container.ID, cg); err != nil {
|
if err := s.ep.Add(container.ID, cg); err != nil {
|
||||||
logrus.WithError(err).Error("add cg to OOM monitor")
|
log.G(ctx).WithError(err).Error("add cg to OOM monitor")
|
||||||
}
|
}
|
||||||
case *cgroupsv2.Manager:
|
case *cgroupsv2.Manager:
|
||||||
allControllers, err := cg.RootControllers()
|
allControllers, err := cg.RootControllers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Error("failed to get root controllers")
|
log.G(ctx).WithError(err).Error("failed to get root controllers")
|
||||||
} else {
|
} else {
|
||||||
if err := cg.ToggleControllers(allControllers, cgroupsv2.Enable); err != nil {
|
if err := cg.ToggleControllers(allControllers, cgroupsv2.Enable); err != nil {
|
||||||
if userns.RunningInUserNS() {
|
if userns.RunningInUserNS() {
|
||||||
logrus.WithError(err).Debugf("failed to enable controllers (%v)", allControllers)
|
log.G(ctx).WithError(err).Debugf("failed to enable controllers (%v)", allControllers)
|
||||||
} else {
|
} else {
|
||||||
logrus.WithError(err).Errorf("failed to enable controllers (%v)", allControllers)
|
log.G(ctx).WithError(err).Errorf("failed to enable controllers (%v)", allControllers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := s.ep.Add(container.ID, cg); err != nil {
|
if err := s.ep.Add(container.ID, cg); err != nil {
|
||||||
logrus.WithError(err).Error("add cg to OOM monitor")
|
log.G(ctx).WithError(err).Error("add cg to OOM monitor")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,7 +541,7 @@ func (s *service) checkProcesses(e runcC.Exit) {
|
|||||||
// Ensure all children are killed
|
// Ensure all children are killed
|
||||||
if runc.ShouldKillAllOnExit(s.context, container.Bundle) {
|
if runc.ShouldKillAllOnExit(s.context, container.Bundle) {
|
||||||
if err := ip.KillAll(s.context); err != nil {
|
if err := ip.KillAll(s.context); err != nil {
|
||||||
logrus.WithError(err).WithField("id", ip.ID()).
|
log.L.WithError(err).WithField("id", ip.ID()).
|
||||||
Error("failed to kill init's children")
|
Error("failed to kill init's children")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -587,7 +587,7 @@ func (s *service) forward(ctx context.Context, publisher shim.Publisher) {
|
|||||||
for e := range s.events {
|
for e := range s.events {
|
||||||
err := publisher.Publish(ctx, runc.GetTopic(e), e)
|
err := publisher.Publish(ctx, runc.GetTopic(e), e)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Error("post event")
|
log.G(ctx).WithError(err).Error("post event")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
publisher.Close()
|
publisher.Close()
|
||||||
|
@ -23,11 +23,11 @@ import (
|
|||||||
|
|
||||||
v1 "github.com/containerd/containerd/api/services/ttrpc/events/v1"
|
v1 "github.com/containerd/containerd/api/services/ttrpc/events/v1"
|
||||||
"github.com/containerd/containerd/events"
|
"github.com/containerd/containerd/events"
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/namespaces"
|
"github.com/containerd/containerd/namespaces"
|
||||||
"github.com/containerd/containerd/pkg/ttrpcutil"
|
"github.com/containerd/containerd/pkg/ttrpcutil"
|
||||||
"github.com/containerd/containerd/protobuf"
|
"github.com/containerd/containerd/protobuf"
|
||||||
"github.com/containerd/ttrpc"
|
"github.com/containerd/ttrpc"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -83,13 +83,13 @@ func (l *RemoteEventsPublisher) Close() (err error) {
|
|||||||
func (l *RemoteEventsPublisher) processQueue() {
|
func (l *RemoteEventsPublisher) processQueue() {
|
||||||
for i := range l.requeue {
|
for i := range l.requeue {
|
||||||
if i.count > maxRequeue {
|
if i.count > maxRequeue {
|
||||||
logrus.Errorf("evicting %s from queue because of retry count", i.ev.Topic)
|
log.L.Errorf("evicting %s from queue because of retry count", i.ev.Topic)
|
||||||
// drop the event
|
// drop the event
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := l.forwardRequest(i.ctx, &v1.ForwardRequest{Envelope: i.ev}); err != nil {
|
if err := l.forwardRequest(i.ctx, &v1.ForwardRequest{Envelope: i.ev}); err != nil {
|
||||||
logrus.WithError(err).Error("forward event")
|
log.L.WithError(err).Error("forward event")
|
||||||
l.queue(i)
|
l.queue(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,6 @@ import (
|
|||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
"github.com/containerd/containerd/snapshots"
|
"github.com/containerd/containerd/snapshots"
|
||||||
"github.com/containerd/containerd/snapshots/storage"
|
"github.com/containerd/containerd/snapshots/storage"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type snapshotter struct {
|
type snapshotter struct {
|
||||||
@ -364,7 +362,7 @@ func (b *snapshotter) Remove(ctx context.Context, key string) (err error) {
|
|||||||
// Attempt to restore source
|
// Attempt to restore source
|
||||||
if err1 := btrfs.SubvolSnapshot(source, removed, readonly); err1 != nil {
|
if err1 := btrfs.SubvolSnapshot(source, removed, readonly); err1 != nil {
|
||||||
log.G(ctx).WithFields(log.Fields{
|
log.G(ctx).WithFields(log.Fields{
|
||||||
logrus.ErrorKey: err1,
|
"error": err1,
|
||||||
"subvolume": source,
|
"subvolume": source,
|
||||||
"renamed": removed,
|
"renamed": removed,
|
||||||
}).Error("failed to restore subvolume from renamed")
|
}).Error("failed to restore subvolume from renamed")
|
||||||
|
@ -26,11 +26,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/containerd/containerd/log"
|
||||||
"github.com/containerd/containerd/mount"
|
"github.com/containerd/containerd/mount"
|
||||||
"github.com/containerd/containerd/pkg/testutil"
|
"github.com/containerd/containerd/pkg/testutil"
|
||||||
"github.com/containerd/containerd/snapshots/devmapper/dmsetup"
|
"github.com/containerd/containerd/snapshots/devmapper/dmsetup"
|
||||||
"github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
exec "golang.org/x/sys/execabs"
|
exec "golang.org/x/sys/execabs"
|
||||||
)
|
)
|
||||||
@ -57,7 +57,7 @@ const (
|
|||||||
func TestPoolDevice(t *testing.T) {
|
func TestPoolDevice(t *testing.T) {
|
||||||
testutil.RequiresRoot(t)
|
testutil.RequiresRoot(t)
|
||||||
|
|
||||||
logrus.SetLevel(logrus.DebugLevel)
|
assert.NoError(t, log.SetLevel("debug"))
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
tempDir := t.TempDir()
|
tempDir := t.TempDir()
|
||||||
|
Loading…
Reference in New Issue
Block a user