Skip to content
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
17 changes: 12 additions & 5 deletions cmd/changes_end_change.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cmd

import (
"time"

"connectrpc.com/connect"
"github.com/overmindtech/sdp-go"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -48,13 +50,18 @@ func EndChange(cmd *cobra.Command, args []string) error {
}
}
log.WithContext(ctx).WithFields(lf).Info("processing")
lastLog := time.Now().Add(-1 * time.Minute)
for stream.Receive() {
msg := stream.Msg()
log.WithContext(ctx).WithFields(lf).WithFields(log.Fields{
"state": msg.GetState(),
"items": msg.GetNumItems(),
"edges": msg.GetNumEdges(),
}).Info("progress")
// print progress every 2 seconds
if time.Now().After(lastLog.Add(2 * time.Second)) {
log.WithContext(ctx).WithFields(lf).WithFields(log.Fields{
"state": msg.GetState(),
"items": msg.GetNumItems(),
"edges": msg.GetNumEdges(),
}).Info("progress")
lastLog = time.Now()
}
}
if stream.Err() != nil {
return loggedError{
Expand Down
17 changes: 12 additions & 5 deletions cmd/changes_start_change.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package cmd

import (
"time"

"connectrpc.com/connect"
"github.com/overmindtech/sdp-go"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -55,13 +57,18 @@ func StartChange(cmd *cobra.Command, args []string) error {
}
}
log.WithContext(ctx).WithFields(lf).Info("processing")
lastLog := time.Now().Add(-1 * time.Minute)
for stream.Receive() {
msg := stream.Msg()
log.WithContext(ctx).WithFields(lf).WithFields(log.Fields{
"state": msg.GetState(),
"items": msg.GetNumItems(),
"edges": msg.GetNumEdges(),
}).Info("progress")
// print progress every 2 seconds
if time.Now().After(lastLog.Add(2 * time.Second)) {
log.WithContext(ctx).WithFields(lf).WithFields(log.Fields{
"state": msg.GetState(),
"items": msg.GetNumItems(),
"edges": msg.GetNumEdges(),
}).Info("progress")
lastLog = time.Now()
}
}
if stream.Err() != nil {
return loggedError{
Expand Down
31 changes: 21 additions & 10 deletions cmd/terraform_apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"strings"
"time"

"connectrpc.com/connect"
"github.com/google/uuid"
Expand Down Expand Up @@ -153,13 +154,18 @@ func TerraformApplyImpl(ctx context.Context, cmd *cobra.Command, oi sdp.Overmind
}

var startMsg *sdp.StartChangeResponse
lastLog := time.Now().Add(-1 * time.Minute)
for startStream.Receive() {
startMsg = startStream.Msg()
log.WithFields(log.Fields{
"state": startMsg.GetState(),
"items": startMsg.GetNumItems(),
"edges": startMsg.GetNumEdges(),
}).Trace("progress")
// print progress every 2 seconds
if time.Now().After(lastLog.Add(2 * time.Second)) {
log.WithFields(log.Fields{
"state": startMsg.GetState(),
"items": startMsg.GetNumItems(),
"edges": startMsg.GetNumEdges(),
}).Trace("progress")
lastLog = time.Now()
}
stateLabel := "unknown"
switch startMsg.GetState() {
case sdp.StartChangeResponse_STATE_UNSPECIFIED:
Expand Down Expand Up @@ -212,13 +218,18 @@ func TerraformApplyImpl(ctx context.Context, cmd *cobra.Command, oi sdp.Overmind
}

var endMsg *sdp.EndChangeResponse
lastLog := time.Now().Add(-1 * time.Minute)
for endStream.Receive() {
endMsg = endStream.Msg()
log.WithFields(log.Fields{
"state": endMsg.GetState(),
"items": endMsg.GetNumItems(),
"edges": endMsg.GetNumEdges(),
}).Trace("progress")
// print progress every 2 seconds
if time.Now().After(lastLog.Add(2 * time.Second)) {
log.WithFields(log.Fields{
"state": endMsg.GetState(),
"items": endMsg.GetNumItems(),
"edges": endMsg.GetNumEdges(),
}).Trace("progress")
lastLog = time.Now()
}
stateLabel := "unknown"
switch endMsg.GetState() {
case sdp.EndChangeResponse_STATE_UNSPECIFIED:
Expand Down
Loading