From c7f76bb4b0930a1c50f87d297b3e423eeb78ea13 Mon Sep 17 00:00:00 2001 From: Alex Drake Date: Fri, 26 Apr 2019 12:11:45 -0700 Subject: [PATCH 1/4] Propagate Log Update Failures in AddSequencedLeaves --- client/log_client.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/log_client.go b/client/log_client.go index 4083200912..c253d82f61 100644 --- a/client/log_client.go +++ b/client/log_client.go @@ -310,10 +310,18 @@ func (c *LogClient) AddSequencedLeaves(ctx context.Context, dataByIndex map[int6 leaf.LeafIndex = index leaves = append(leaves, leaf) } - _, err := c.client.AddSequencedLeaves(ctx, &trillian.AddSequencedLeavesRequest{ + resp, err := c.client.AddSequencedLeaves(ctx, &trillian.AddSequencedLeavesRequest{ LogId: c.LogID, Leaves: leaves, }) + for _, leaf := range resp.GetResults() { + if stat := leaf.GetStatus().GetCode(); stat != codes.OK { + glog.Warningf("Got a non-OK status for a sequenced leaf: %+v", leaf) + if stat != codes.AlreadyExists { + return fmt.Errorf("unexpected fail status in AddSequencedLeaves: %+v", leaf) + } + } + } return err } From 8a8b91121617c9245d1a0c019751e6b7676bac60 Mon Sep 17 00:00:00 2001 From: Alex Drake Date: Fri, 26 Apr 2019 12:28:19 -0700 Subject: [PATCH 2/4] Update log_client.go --- client/log_client.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/client/log_client.go b/client/log_client.go index c253d82f61..559c80ccec 100644 --- a/client/log_client.go +++ b/client/log_client.go @@ -315,11 +315,8 @@ func (c *LogClient) AddSequencedLeaves(ctx context.Context, dataByIndex map[int6 Leaves: leaves, }) for _, leaf := range resp.GetResults() { - if stat := leaf.GetStatus().GetCode(); stat != codes.OK { - glog.Warningf("Got a non-OK status for a sequenced leaf: %+v", leaf) - if stat != codes.AlreadyExists { - return fmt.Errorf("unexpected fail status in AddSequencedLeaves: %+v", leaf) - } + if stat := leaf.GetStatus().GetCode(); stat != int32(codes.OK) && stat != int32(codes.AlreadyExists) { + return fmt.Errorf("unexpected fail status in AddSequencedLeaves: %+v", leaf) } } return err From 9b648939f8524fb2c5d6d26a90035f31213ab52d Mon Sep 17 00:00:00 2001 From: Gary Belvin Date: Mon, 29 Apr 2019 12:33:58 -0700 Subject: [PATCH 3/4] Update client/log_client.go Co-Authored-By: therealdrake --- client/log_client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/log_client.go b/client/log_client.go index 559c80ccec..1bd567165f 100644 --- a/client/log_client.go +++ b/client/log_client.go @@ -316,7 +316,7 @@ func (c *LogClient) AddSequencedLeaves(ctx context.Context, dataByIndex map[int6 }) for _, leaf := range resp.GetResults() { if stat := leaf.GetStatus().GetCode(); stat != int32(codes.OK) && stat != int32(codes.AlreadyExists) { - return fmt.Errorf("unexpected fail status in AddSequencedLeaves: %+v", leaf) + return status.Errorf(s.Code(), "unexpected fail status in AddSequencedLeaves: %+v, err: %v", leaf, s.Message()) } } return err From 6458c646410038f7f95f471b3145d9ff97b8a2d7 Mon Sep 17 00:00:00 2001 From: Gary Belvin Date: Mon, 29 Apr 2019 12:34:11 -0700 Subject: [PATCH 4/4] Update client/log_client.go Co-Authored-By: therealdrake --- client/log_client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/log_client.go b/client/log_client.go index 1bd567165f..a13a916de4 100644 --- a/client/log_client.go +++ b/client/log_client.go @@ -315,7 +315,7 @@ func (c *LogClient) AddSequencedLeaves(ctx context.Context, dataByIndex map[int6 Leaves: leaves, }) for _, leaf := range resp.GetResults() { - if stat := leaf.GetStatus().GetCode(); stat != int32(codes.OK) && stat != int32(codes.AlreadyExists) { + if s := status.FromProto(leaf.GetStatus()); s.Code() != codes.OK && s.Code() != codes.AlreadyExists { return status.Errorf(s.Code(), "unexpected fail status in AddSequencedLeaves: %+v, err: %v", leaf, s.Message()) } }