Skip to content

Commit

Permalink
Always pass state version when getting run logs (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasmik authored Jul 20, 2023
1 parent fee1bcb commit 0b9ce9b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
13 changes: 7 additions & 6 deletions client/structs/run_state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import (

// RunStateTransition represents a single run state transition.
type RunStateTransition struct {
HasLogs bool `graphql:"hasLogs"`
Note *string `graphql:"note"`
State RunState `graphql:"state"`
Terminal bool `graphql:"terminal"`
Timestamp int `graphql:"timestamp"`
Username *string `graphql:"username"`
HasLogs bool `graphql:"hasLogs"`
Note *string `graphql:"note"`
State RunState `graphql:"state"`
StateVersion int `graphql:"stateVersion"`
Terminal bool `graphql:"terminal"`
Timestamp int `graphql:"timestamp"`
Username *string `graphql:"username"`
}

// About returns "header" information about the state transition.
Expand Down
16 changes: 8 additions & 8 deletions internal/cmd/stack/run_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func runStates(ctx context.Context, stack, run string, sink chan<- string) (*str
fmt.Println("")

if transition.HasLogs {
if err := runStateLogs(ctx, stack, run, transition.State, sink); err != nil {
if err := runStateLogs(ctx, stack, run, transition.State, transition.StateVersion, sink); err != nil {
return nil, err
}
}
Expand All @@ -94,7 +94,7 @@ func runStates(ctx context.Context, stack, run string, sink chan<- string) (*str
}
}

func runStateLogs(ctx context.Context, stack, run string, state structs.RunState, sink chan<- string) error {
func runStateLogs(ctx context.Context, stack, run string, state structs.RunState, version int, sink chan<- string) error {
var query struct {
Stack *struct {
Run *struct {
Expand All @@ -106,18 +106,18 @@ func runStateLogs(ctx context.Context, stack, run string, state structs.RunState
Body string `graphql:"message"`
} `graphql:"messages"`
NextToken *graphql.String `graphql:"nextToken"`
} `graphql:"logs(state: $state, token: $token)"`
} `graphql:"logs(state: $state, token: $token, stateVersion: $stateVersion)"`
} `graphql:"run(id: $run)"`
} `graphql:"stack(id: $stack)"`
}

var token *graphql.String

variables := map[string]interface{}{
"stack": graphql.ID(stack),
"run": graphql.ID(run),
"state": state,
"token": token,
"stack": graphql.ID(stack),
"run": graphql.ID(run),
"state": state,
"token": token,
"stateVersion": graphql.Int(version),
}

var backOff time.Duration
Expand Down

0 comments on commit 0b9ce9b

Please sign in to comment.