fix: small logrus fixes

Ensure correct logrus setup.

Signed-off-by: Dmitriy Matrenichev <dmitry.matrenichev@siderolabs.com>
This commit is contained in:
Dmitriy Matrenichev 2024-11-26 21:32:52 +03:00
parent a9875b7704
commit 177df62a0e
No known key found for this signature in database
GPG Key ID: 94B473337258BFD5
2 changed files with 15 additions and 1 deletions

View File

@ -7,15 +7,18 @@ package image
import ( import (
"context" "context"
"fmt" "fmt"
stdlog "log"
"os" "os"
"time" "time"
containerd "github.com/containerd/containerd/v2/client" containerd "github.com/containerd/containerd/v2/client"
"github.com/containerd/containerd/v2/core/images" "github.com/containerd/containerd/v2/core/images"
"github.com/containerd/errdefs" "github.com/containerd/errdefs"
"github.com/containerd/log"
"github.com/distribution/reference" "github.com/distribution/reference"
ocispec "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/siderolabs/go-retry/retry" "github.com/siderolabs/go-retry/retry"
"github.com/sirupsen/logrus"
containerdrunner "github.com/siderolabs/talos/internal/app/machined/pkg/system/runner/containerd" containerdrunner "github.com/siderolabs/talos/internal/app/machined/pkg/system/runner/containerd"
"github.com/siderolabs/talos/pkg/machinery/config/config" "github.com/siderolabs/talos/pkg/machinery/config/config"
@ -83,9 +86,19 @@ func Pull(ctx context.Context, reg config.Registries, client *containerd.Client,
} }
} }
containerdLogger := logrus.New()
containerdLogger.Out = stdlog.Default().Writer()
containerdLogger.Formatter = &logrus.TextFormatter{
DisableColors: true,
DisableQuote: true,
DisableTimestamp: true,
}
ctx = log.WithLogger(ctx, containerdLogger.WithField("image", ref))
resolver := NewResolver(reg) resolver := NewResolver(reg)
err = retry.Exponential(PullTimeout, retry.WithUnits(PullRetryInterval), retry.WithErrorLogging(true)).Retry(func() error { err = retry.Exponential(PullTimeout, retry.WithUnits(PullRetryInterval), retry.WithErrorLogging(true)).RetryWithContext(ctx, func(ctx context.Context) error {
if img, err = client.Pull( if img, err = client.Pull(
ctx, ctx,
ref, ref,

View File

@ -34,6 +34,7 @@ func (condition *SyncCondition) Wait(ctx context.Context) error {
_, err := condition.state.WatchFor( _, err := condition.state.WatchFor(
ctx, ctx,
resource.NewMetadata(v1alpha1.NamespaceName, StatusType, StatusID, resource.VersionUndefined), resource.NewMetadata(v1alpha1.NamespaceName, StatusType, StatusID, resource.VersionUndefined),
state.WithEventTypes(state.Created, state.Updated),
state.WithCondition(func(r resource.Resource) (bool, error) { state.WithCondition(func(r resource.Resource) (bool, error) {
return r.(*Status).TypedSpec().Synced, nil return r.(*Status).TypedSpec().Synced, nil
}), }),