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
6 changes: 5 additions & 1 deletion cmd/gazctl/gazctlcmd/shards_unassign.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package gazctlcmd
import (
"context"
"fmt"
"time"

log "github.com/sirupsen/logrus"
pb "go.gazette.dev/core/broker/protocol"
Expand Down Expand Up @@ -30,11 +31,14 @@ list' command for more details about label selectors.
func (cmd *cmdShardsUnassign) Execute([]string) (err error) {
startup(ShardsCfg.BaseConfig)

var ctx, cancel = context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

var listResp = listShards(cmd.Selector)
if listResp.Status != pc.Status_OK {
return fmt.Errorf("unexpected listShard status: %v", listResp.Status.String())
}
var ctx = context.Background()

var client = pc.NewShardClient(ShardsCfg.Consumer.MustDial(ctx))

unassignResp, err := client.Unassign(pb.WithDispatchDefault(ctx), &pc.UnassignRequest{
Expand Down
4 changes: 3 additions & 1 deletion consumer/shard_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ func ShardUnassign(ctx context.Context, srv *Service, req *pc.UnassignRequest) (
etcdResp, err := srv.Etcd.Txn(ctx).If(cmp...).Then(ops...).Commit()
if err != nil {
return resp, fmt.Errorf("executing etcd transaction: %w", err)
} else if etcdResp.Succeeded {
} else if !etcdResp.Succeeded {
resp.Status = pc.Status_ETCD_TRANSACTION_FAILED
} else if len(ops) != 0 {
// If we made changes, delay responding until we have read our own Etcd write.
err = state.KS.WaitForRevision(ctx, etcdResp.Header.Revision)
}
Expand Down