AydarZaynutdinov commented on a change in pull request #15926:
URL: https://github.com/apache/beam/pull/15926#discussion_r747412275



##########
File path: playground/backend/cmd/server/controller.go
##########
@@ -447,13 +469,27 @@ func processSuccess(ctx context.Context, output []byte, 
pipelineId uuid.UUID, ca
 
                setToCache(ctx, cacheService, pipelineId, cache.RunOutput, 
string(output))
 
+               // set to cache pipelineId: cache.Canceled: false to stop 
cancelCheck() method
+               setToCache(ctx, cacheService, pipelineId, cache.Canceled, false)
+
+               // set to cache pipelineId: cache.SubKey_Status: 
pb.Status_STATUS_FINISHED
                setToCache(ctx, cacheService, pipelineId, cache.Status, 
pb.Status_STATUS_FINISHED)
        }
 }
 
+// processCancel process case when code processing was canceled
+func processCancel(ctx context.Context, cacheService cache.Cache, pipelineId 
uuid.UUID) {
+       logger.Infof("%s: was canceled\n", pipelineId)
+
+       // set to cache pipelineId: cache.SubKey_Status: 
pb.Status_STATUS_CANCELED
+       setToCache(ctx, cacheService, pipelineId, cache.Status, 
pb.Status_STATUS_CANCELED)

Review comment:
       It seems that no. According to the current logic after the 
`processCancel()` method we return false from the `processStep()` function:
   ```
   func processStep(...) bool {
       select {
       ....
       case <-cancelChannel:
           processCancel(ctx, cacheService, pipelined)
        return false
       ...
       }
       return true
   }
   ```
   
   and in the place where we call the `processStep()` we check the result of 
this function. If it is false the `processCode()` method finished:
   ```
   func processCode(...) {
       ...
       if !processStep(...) {
           return
       }
       ....
   }
   ```
   
   and defer part will be called:
   ```
   func processCode(...) {
       defer func(lc *fs_tool.LifeCycle) {
           finishCtxFunc()
        cleanUp(pipelineId, lc)
       }(lc)
       ...
   }
   ```
   
   So using this logic we will call a function to cancel the context.




-- 
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