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

use event writer in skaffold execution #5965

Merged
merged 6 commits into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion pkg/skaffold/build/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (l *logAggregatorImpl) GetWriter() (io.Writer, func(), error) {

writer := io.Writer(w)
if output.IsColorable(l.out) {
writer = output.NewColorWriter(writer)
writer = output.GetWriter(writer, output.DefaultColorCode, false)
}
ch := make(chan string, buffSize)
l.messages <- ch
Expand Down
2 changes: 2 additions & 0 deletions pkg/skaffold/build/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"golang.org/x/sync/errgroup"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/constants"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/event"
eventV2 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/event/v2"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/graph"
Expand Down Expand Up @@ -107,6 +108,7 @@ func (s *scheduler) build(ctx context.Context, tags tag.ImageTags, i int) error
}
defer closeFn()

w = output.WithEventContext(w, constants.Build, strconv.Itoa(eventV2.GetArtifactID(a)), "skaffold")
MarlonGamez marked this conversation as resolved.
Show resolved Hide resolved
finalTag, err := performBuild(ctx, w, tags, a, s.artifactBuilder)
if err != nil {
event.BuildFailed(a.ImageName, err)
Expand Down
4 changes: 4 additions & 0 deletions pkg/skaffold/deploy/deploy_mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ import (
"bytes"
"context"
"io"
"strconv"
"strings"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/constants"
eventV2 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/event/v2"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/graph"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/instrumentation"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/kubernetes/manifest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/log"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/output"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
)

Expand All @@ -48,6 +51,7 @@ func (m DeployerMux) Deploy(ctx context.Context, w io.Writer, as []graph.Artifac

for i, deployer := range m {
eventV2.DeployInProgress(i)
w = output.WithEventContext(w, constants.Deploy, strconv.Itoa(i), "skaffold")
ctx, endTrace := instrumentation.StartTrace(ctx, "Deploy")

namespaces, err := deployer.Deploy(ctx, w, as)
Expand Down
8 changes: 8 additions & 0 deletions pkg/skaffold/event/v2/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ func AssignArtifactIDs(artifacts []*latestV1.Artifact) {
}
}

func GetArtifactID(a *latestV1.Artifact) int {
if id, ok := artifactIDs[a.ImageName]; ok {
return id
}

return -1
}

func CacheCheckInProgress(artifact string) {
buildSubtaskEvent(artifact, Cache, InProgress, nil)
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/skaffold/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package output

import (
"io"
"io/ioutil"
"os"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/constants"
Expand Down Expand Up @@ -52,7 +51,7 @@ func GetWriter(out io.Writer, defaultColor int, forceColors bool) io.Writer {
return skaffoldWriter{
MainWriter: SetupColors(out, defaultColor, forceColors),
// TODO(marlongamez): Replace this once event writer is implemented
EventWriter: ioutil.Discard,
EventWriter: eventV2.NewLogger(constants.DevLoop, "-1", "skaffold"),
MarlonGamez marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/skaffold/runner/build_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func (r *Builder) GetBuilds() []graph.Artifact {
func (r *Builder) Build(ctx context.Context, out io.Writer, artifacts []*latestV1.Artifact) ([]graph.Artifact, error) {
eventV2.TaskInProgress(constants.Build, "Build Containers")
eventV2.AssignArtifactIDs(artifacts)
out = output.WithEventContext(out, constants.Build, "-1", "skaffold")

// Use tags directly from the Kubernetes manifests.
if r.runCtx.DigestSource() == NoneDigestSource {
Expand Down
2 changes: 2 additions & 0 deletions pkg/skaffold/runner/v1/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ func (r *SkaffoldRunner) Deploy(ctx context.Context, out io.Writer, artifacts []
return r.Render(ctx, out, artifacts, false, r.runCtx.RenderOutput())
}

out = output.WithEventContext(out, constants.Deploy, "-1", "skaffold")

output.Default.Fprintln(out, "Tags used in deployment:")

for _, artifact := range artifacts {
Expand Down