damccorm commented on a change in pull request #16980:
URL: https://github.com/apache/beam/pull/16980#discussion_r820781533



##########
File path: sdks/go/pkg/beam/core/runtime/exec/plan.go
##########
@@ -131,6 +141,41 @@ func (p *Plan) Execute(ctx context.Context, id string, 
manager DataContext) erro
        return nil
 }
 
+func (p *Plan) Finalize(ctx context.Context, id string) error {
+       if p.status != Up {
+               return errors.Errorf("invalid status for plan %v: %v", p.id, 
p.status)
+       }
+       failedIndices := []int{}
+       for idx, bfc := range p.bf.callbacks {
+               if time.Now().Before(bfc.validUntil) {
+                       if err := bfc.callback(); err != nil {
+                               failedIndices = append(failedIndices, idx)
+                       }
+               }
+       }
+
+       newFinalizer := bundleFinalizer{
+               callbacks:         []bundleFinalizationCallback{},
+               lastValidCallback: time.Now(),
+       }
+
+       for _, idx := range failedIndices {
+               newFinalizer.callbacks = append(newFinalizer.callbacks, 
p.bf.callbacks[idx])
+               if 
newFinalizer.lastValidCallback.Before(p.bf.callbacks[idx].validUntil) {
+                       newFinalizer.lastValidCallback = 
p.bf.callbacks[idx].validUntil
+               }
+       }
+
+       if len(failedIndices) > 0 {
+               return errors.Errorf("Plan %v failed %v callbacks", p.ID(), 
len(failedIndices))
+       }
+       return nil
+}
+
+func (p *Plan) GetExpirationTime(ctx context.Context, id string) time.Time {

Review comment:
       Good call - we don't need the parameters here or above anymore.

##########
File path: sdks/go/pkg/beam/core/runtime/exec/plan.go
##########
@@ -131,6 +141,41 @@ func (p *Plan) Execute(ctx context.Context, id string, 
manager DataContext) erro
        return nil
 }
 
+func (p *Plan) Finalize(ctx context.Context, id string) error {
+       if p.status != Up {
+               return errors.Errorf("invalid status for plan %v: %v", p.id, 
p.status)
+       }
+       failedIndices := []int{}
+       for idx, bfc := range p.bf.callbacks {
+               if time.Now().Before(bfc.validUntil) {
+                       if err := bfc.callback(); err != nil {
+                               failedIndices = append(failedIndices, idx)
+                       }
+               }
+       }
+
+       newFinalizer := bundleFinalizer{

Review comment:
       Ooh, good catch - this should be getting assigned to `p.bf` so that if 
the runner tries to rerun finalization the failed callbacks get rerun, but it 
got dropped when I moved this code. I added it back.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to