Skip to content

Commit

Permalink
Revert "add skaffold end session event"
Browse files Browse the repository at this point in the history
This reverts commit ca80757.
  • Loading branch information
tejal29 committed May 4, 2020
1 parent 9cb82be commit 735e963
Show file tree
Hide file tree
Showing 11 changed files with 202 additions and 654 deletions.
2 changes: 1 addition & 1 deletion cmd/skaffold/app/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var (

func NewSkaffoldCommand(out, err io.Writer) *cobra.Command {
updateMsg := make(chan string)
var shutdownAPIServer func() error
var shutdownAPIServer func() error

rootCmd := &cobra.Command{
Use: "skaffold",
Expand Down
8 changes: 1 addition & 7 deletions cmd/skaffold/app/cmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (

"github.com/spf13/cobra"
"github.com/spf13/pflag"

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

// Builder is used to build cobra commands.
Expand Down Expand Up @@ -96,11 +94,7 @@ func (b *builder) ExactArgs(argCount int, action func(context.Context, io.Writer
func (b *builder) NoArgs(action func(context.Context, io.Writer) error) *cobra.Command {
b.cmd.Args = cobra.NoArgs
b.cmd.RunE = func(*cobra.Command, []string) error {
err := action(b.cmd.Context(), b.cmd.OutOrStdout())
// The actual error code will be passed in
// https://github.com/GoogleContainerTools/skaffold/pull/4045
event.EndSessionEvent(1)
return err
return action(b.cmd.Context(), b.cmd.OutOrStdout())
}
return &b.cmd
}
143 changes: 15 additions & 128 deletions docs/content/en/api/skaffold.swagger.json

Large diffs are not rendered by default.

56 changes: 1 addition & 55 deletions docs/content/en/docs/references/api/grpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ anytime a deployment starts or completes, successfully or not.
| ----- | ---- | ----- | ----------- |
| type | [DeployerType](#proto.DeployerType) | | |
| count | [int32](#int32) | | |
| changeType | [ChangeType](#proto.ChangeType) | | |



Expand All @@ -270,23 +269,6 @@ anytime a deployment starts or completes, successfully or not.



<a name="proto.DevLoop"></a>
#### DevLoop



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| iteration | [int32](#int32) | | dev loop iteration |
| changeType | [ChangeType](#proto.ChangeType) | | Change type which triggered this loop |
| errCode | [ErrorCode](#proto.ErrorCode) | | actionable error message |







<a name="proto.DevLoopEvent"></a>
#### DevLoopEvent
`DevLoopEvent` marks the start and end of a dev loop.
Expand All @@ -295,7 +277,6 @@ anytime a deployment starts or completes, successfully or not.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| iteration | [int32](#int32) | | dev loop iteration |
| changeType | [ChangeType](#proto.ChangeType) | | |
| status | [string](#string) | | dev loop status oneof: In Progress, Completed, Failed |
| err | [ActionableErr](#proto.ActionableErr) | | actionable error message |

Expand All @@ -305,23 +286,6 @@ anytime a deployment starts or completes, successfully or not.



<a name="proto.EndEvent"></a>
#### EndEvent
`EndEvent` is the last event indicating skaffold session ended.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| errCode | [ErrorCode](#proto.ErrorCode) | | |
| errMsg | [string](#string) | | |
| loops | [DevLoop](#proto.DevLoop) | repeated | |







<a name="proto.Event"></a>
#### Event
`Event` describes an event in the Skaffold process.
Expand All @@ -339,7 +303,6 @@ It is one of MetaEvent, BuildEvent, DeployEvent, PortEvent, StatusCheckEvent, Re
| fileSyncEvent | [FileSyncEvent](#proto.FileSyncEvent) | | describes the sync status. |
| debuggingContainerEvent | [DebuggingContainerEvent](#proto.DebuggingContainerEvent) | | describes the appearance or disappearance of a debugging container |
| devLoopEvent | [DevLoopEvent](#proto.DevLoopEvent) | | describes a start and end of a dev loop. |
| endEvent | [EndEvent](#proto.EndEvent) | | |



Expand Down Expand Up @@ -553,7 +516,6 @@ will be sent with the new status.
| fileSyncState | [FileSyncState](#proto.FileSyncState) | | |
| debuggingContainers | [DebuggingContainerEvent](#proto.DebuggingContainerEvent) | repeated | |
| metadata | [Metadata](#proto.Metadata) | | |
| loops | [DevLoop](#proto.DevLoop) | repeated | |



Expand Down Expand Up @@ -689,22 +651,6 @@ Enum indicating builders used



<a name="proto.ChangeType"></a>

### ChangeType
Enum for indicating which dependency change triggered the dev loop

| Name | Number | Description |
| ---- | ------ | ----------- |
| INITIAL_LOOP | 0 | First iteration |
| BUILD | 1 | Indicates build dependency change |
| TEST | 2 | Indicates test dependency change |
| DEPLOY | 3 | Indicates deploy dependency change |
| CONFIG | 4 | Indicates skaffold config change |
| SYNC | 5 | Indicates sync dependency change |



<a name="proto.ClusterType"></a>

### ClusterType
Expand Down Expand Up @@ -741,7 +687,7 @@ Enum for error codes
| Name | Number | Description |
| ---- | ------ | ----------- |
| COULD_NOT_DETERMINE | 0 | Could not determine error |
| SUCCESS | 200 | Status Check Success |
| STATUS_CHECK_NO_ERROR | 200 | Status Check Success |
| STATUS_CHECK_IMAGE_PULL_ERR | 300 | Container image pull error |
| STATUS_CHECK_CONTAINER_CREATING | 301 | Container creating error |
| STATUS_CHECK_RUN_CONTAINER_ERR | 302 | Container run error |
Expand Down
6 changes: 3 additions & 3 deletions pkg/diag/validator/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func getContainerStatus(pod *v1.Pod) (proto.ErrorCode, error) {
}
}
}
return proto.ErrorCode_SUCCESS, nil
return proto.ErrorCode_STATUS_CHECK_NO_ERROR, nil
}

func getWaitingContainerStatus(cs []v1.ContainerStatus) (proto.ErrorCode, error) {
Expand All @@ -114,7 +114,7 @@ func getWaitingContainerStatus(cs []v1.ContainerStatus) (proto.ErrorCode, error)
}
}
// No waiting or terminated containers, pod should be in good health.
return proto.ErrorCode_SUCCESS, nil
return proto.ErrorCode_STATUS_CHECK_NO_ERROR, nil
}

func getTolerationsDetails(reason string, message string) (proto.ErrorCode, error) {
Expand Down Expand Up @@ -219,7 +219,7 @@ func newPodStatus(n string, ns string, p string) *podStatus {
name: n,
namespace: ns,
phase: p,
errCode: proto.ErrorCode_SUCCESS,
errCode: proto.ErrorCode_STATUS_CHECK_NO_ERROR,
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/diag/validator/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestRun(t *testing.T) {
},
}},
expected: []Resource{NewResource("test", "", "foo", "Succeeded", nil,
proto.ErrorCode_SUCCESS)},
proto.ErrorCode_STATUS_CHECK_NO_ERROR)},
},
{
description: "pod is in Stable State",
Expand All @@ -109,7 +109,7 @@ func TestRun(t *testing.T) {
},
}},
expected: []Resource{NewResource("test", "", "foo", "Running", nil,
proto.ErrorCode_SUCCESS)},
proto.ErrorCode_STATUS_CHECK_NO_ERROR)},
},
{
description: "pod condition unknown",
Expand Down
31 changes: 2 additions & 29 deletions pkg/skaffold/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,8 @@ func BuildComplete(imageName string) {
}

// DevLoopInProgress notifies that a dev loop has been started.
func DevLoopInProgress(i int, depType proto.ChangeType) {
handler.handleDevLoopEvent(&proto.DevLoopEvent{
Iteration: int32(i),
ChangeType: depType,
Status: InProgress,
})
func DevLoopInProgress(i int) {
handler.handleDevLoopEvent(&proto.DevLoopEvent{Iteration: int32(i), Status: InProgress})
}

// DevLoopFailed notifies that a dev loop has failed with an error code
Expand Down Expand Up @@ -419,18 +415,6 @@ func LogMetaEvent() {
})
}

// EndSessionEvent notifies that that skaffold session has ended and describes it
func EndSessionEvent(errorCode proto.ErrorCode) {
go handler.handle(&proto.Event{
EventType: &proto.Event_EndEvent{
EndEvent: &proto.EndEvent{
ErrCode: errorCode,
Loops: handler.state.Loops,
},
},
})
}

func (ev *eventHandler) handle(event *proto.Event) {
logEntry := &proto.LogEntry{
Timestamp: ptypes.TimestampNow(),
Expand Down Expand Up @@ -546,24 +530,14 @@ func (ev *eventHandler) handle(event *proto.Event) {
}
case *proto.Event_DevLoopEvent:
de := e.DevLoopEvent
ev.stateLock.Lock()
switch de.Status {
case InProgress:
ev.state.Loops = append(ev.state.Loops, &proto.DevLoop{
Iteration: de.Iteration,
ChangeType: de.ChangeType,
})
logEntry.Entry = fmt.Sprintf("Dev Iteration %d in progress", de.Iteration)
case Succeeded:
ev.state.Loops[int(de.Iteration)].ErrCode = proto.ErrorCode_SUCCESS
logEntry.Entry = fmt.Sprintf("Dev Iteration %d successful", de.Iteration)
default:
ev.state.Loops[int(de.Iteration)].ErrCode = de.Err.ErrCode
logEntry.Entry = fmt.Sprintf("Dev Iteration %d failed with error code %v", de.Iteration, de.Err.ErrCode)
}
ev.stateLock.Unlock()
case *proto.Event_EndEvent:
logEntry.Entry = fmt.Sprintf("Skaffold end event with %d dev loops", len(e.EndEvent.Loops))
default:
return
}
Expand All @@ -578,7 +552,6 @@ func ResetStateOnBuild() {
builds[k] = NotStarted
}
newState := emptyStateWithArtifacts(builds, handler.getState().Metadata)
newState.Loops = handler.getState().Loops
handler.setState(newState)
}

Expand Down
14 changes: 0 additions & 14 deletions pkg/skaffold/runner/changeset.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package runner
import (
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/sync"
"github.com/GoogleContainerTools/skaffold/proto"
)

type changeSet struct {
Expand All @@ -29,7 +28,6 @@ type changeSet struct {
resyncTracker map[string]*sync.Item
needsRedeploy bool
needsReload bool
changeType proto.ChangeType
}

func (c *changeSet) AddRebuild(a *latest.Artifact) {
Expand All @@ -39,7 +37,6 @@ func (c *changeSet) AddRebuild(a *latest.Artifact) {
c.rebuildTracker[a.ImageName] = a
c.needsRebuild = append(c.needsRebuild, a)
c.needsRedeploy = true
c.changeType = proto.ChangeType_BUILD
}

func (c *changeSet) AddResync(s *sync.Item) {
Expand All @@ -48,17 +45,6 @@ func (c *changeSet) AddResync(s *sync.Item) {
}
c.resyncTracker[s.Image] = s
c.needsResync = append(c.needsResync, s)
c.changeType = proto.ChangeType_SYNC
}

func (c *changeSet) AddRedeploy(ct proto.ChangeType) {
c.needsRedeploy = true
c.changeType = ct
}

func (c *changeSet) NeedsReload() {
c.needsReload = true
c.changeType = proto.ChangeType_CONFIG
}

func (c *changeSet) resetBuild() {
Expand Down
10 changes: 5 additions & 5 deletions pkg/skaffold/runner/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (r *SkaffoldRunner) doDev(ctx context.Context, out io.Writer) error {
// if any action is going to be performed, reset the monitor's changed component tracker for debouncing
defer r.monitor.Reset()
defer r.listener.LogWatchToUser(out)
event.DevLoopInProgress(iteration, r.changeSet.changeType)
event.DevLoopInProgress(iteration)
defer func() { iteration++ }()
if needsSync {
defer func() {
Expand Down Expand Up @@ -126,7 +126,7 @@ func (r *SkaffoldRunner) doDev(ctx context.Context, out io.Writer) error {
// Dev watches for changes and runs the skaffold build and deploy
// config until interrupted by the user.
func (r *SkaffoldRunner) Dev(ctx context.Context, out io.Writer, artifacts []*latest.Artifact) error {
event.DevLoopInProgress(0, proto.ChangeType_INITIAL_LOOP)
event.DevLoopInProgress(0)
r.createLogger(out, artifacts)
defer r.logger.Stop()

Expand Down Expand Up @@ -177,7 +177,7 @@ func (r *SkaffoldRunner) Dev(ctx context.Context, out io.Writer, artifacts []*la
// Watch test configuration
if err := r.monitor.Register(
r.tester.TestDependencies,
func(filemon.Events) { r.changeSet.AddRedeploy(proto.ChangeType_TEST) },
func(filemon.Events) { r.changeSet.needsRedeploy = true },
); err != nil {
event.DevLoopFailedWithErrorCode(0, proto.ErrorCode_DEV_REGISTER_TEST_DEPS, err)
return fmt.Errorf("watching test files: %w", err)
Expand All @@ -186,7 +186,7 @@ func (r *SkaffoldRunner) Dev(ctx context.Context, out io.Writer, artifacts []*la
// Watch deployment configuration
if err := r.monitor.Register(
r.deployer.Dependencies,
func(filemon.Events) { r.changeSet.AddRedeploy(proto.ChangeType_DEPLOY) },
func(filemon.Events) { r.changeSet.needsRedeploy = true },
); err != nil {
event.DevLoopFailedWithErrorCode(0, proto.ErrorCode_DEV_REGISTER_DEPLOY_DEPS, err)
return fmt.Errorf("watching files for deployer: %w", err)
Expand All @@ -195,7 +195,7 @@ func (r *SkaffoldRunner) Dev(ctx context.Context, out io.Writer, artifacts []*la
// Watch Skaffold configuration
if err := r.monitor.Register(
func() ([]string, error) { return []string{r.runCtx.Opts.ConfigurationFile}, nil },
func(filemon.Events) { r.changeSet.NeedsReload() },
func(filemon.Events) { r.changeSet.needsReload = true },
); err != nil {
event.DevLoopFailedWithErrorCode(0, proto.ErrorCode_DEV_REGISTER_CONFIG_DEP, err)
return fmt.Errorf("watching skaffold configuration %q: %w", r.runCtx.Opts.ConfigurationFile, err)
Expand Down
Loading

0 comments on commit 735e963

Please sign in to comment.