Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buildpacks builder output to go through Event API #6530

Merged
merged 1 commit into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkg/skaffold/build/buildpacks/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"github.com/buildpacks/pack/project"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/output"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/output/log"
latestV1 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest/v1"
)
Expand Down Expand Up @@ -97,7 +96,7 @@ func (b *Builder) build(ctx context.Context, out io.Writer, a *latestV1.Artifact

builderImage, runImage, pullPolicy := resolveDependencyImages(artifact, b.artifacts, a.Dependencies, b.pushImages)

if err := runPackBuildFunc(ctx, output.GetUnderlyingWriter(out), b.localDocker, pack.BuildOptions{
if err := runPackBuildFunc(ctx, out, b.localDocker, pack.BuildOptions{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to plumb through a logger so that we get real log entries, rather than just logrus-formatted output strings on out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you clarify what you mean by "real log entries" here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pack uses its own logger implementation. With this change, we're passing in a logrus logger that's configured to write to this provided writer instance, which means we're losing information: the pack logging is being turned into Skaffold output, whereas we could pass the pack logging through as logging entries.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay, I see what you mean. I'm not completely sure what the best approach for us would be here, as this change seems to be necessary for us to properly get the pack output through the event API stream

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would probably be a good enhancement not just here, but for our other builder/deployers as well that use their own logging implementations. probably out of scope for this change though - can you add a TODO in the runPackBuild() function?

AppPath: workspace,
Builder: builderImage,
RunImage: runImage,
Expand Down
8 changes: 0 additions & 8 deletions pkg/skaffold/build/buildpacks/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ import (
"io"

"github.com/buildpacks/pack/logging"
"github.com/mattn/go-colorable"
"github.com/sirupsen/logrus"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to remove the logrus from here and instead add a helper func NewLogger in output.Log.
Removing dependency on logger here will make the custom lint analyzer ignore list simpler.
See here https://github.com/GoogleContainerTools/skaffold/pull/6357/files#diff-82c7b02016fd4c13ff671a6b3c038aacdb4ed7aa4ec92871709e1c6bbaebe8d0R32

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be done as a follow up later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, I can handle this in a follow up 👍🏼


"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
)

// logger exists to meet the requirements of the pack logger.
Expand All @@ -33,11 +30,6 @@ type logger struct {
}

func NewLogger(out io.Writer) logging.Logger {
// If out is not a terminal, let's make sure no colors are printed.
if _, isTerm := util.IsTerminal(out); !isTerm {
out = colorable.NewNonColorable(out)
}

l := logrus.New()
l.SetOutput(out)

Expand Down