- 
                Notifications
    You must be signed in to change notification settings 
- Fork 470
Added support to gracefully shutdown language worker #8385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            65 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      d5aa3bf
              
                First set of changes for graceful shutdown of worker
              
              
                surgupta-msft e97874e
              
                Adding stop process async
              
              
                surgupta-msft c269436
              
                Adidng stopProcessAsync to send grpc message to worker
              
              
                surgupta-msft b62d5d4
              
                Adding StopWorkerProcess method
              
              
                surgupta-msft 3b87dc9
              
                Removing cancellation token
              
              
                surgupta-msft 005b4f1
              
                duplicate call removal
              
              
                surgupta-msft 677c51c
              
                Adding in capapbilities
              
              
                surgupta-msft 05c3c54
              
                Updating stopWorkerProcess method
              
              
                surgupta-msft 6725fc8
              
                minor
              
              
                surgupta-msft 6885749
              
                Correcting comment
              
              
                surgupta-msft e0e20db
              
                Tests
              
              
                surgupta-msft 86d743f
              
                Grace period changes
              
              
                surgupta-msft 6e06cb7
              
                Added unit test
              
              
                surgupta-msft 3e2236e
              
                Investigating failing tests
              
              
                surgupta-msft da847f9
              
                Added Dispose tests in grpc channel
              
              
                surgupta-msft 02d7752
              
                Improving tests
              
              
                surgupta-msft 8648a1a
              
                Minor changes
              
              
                surgupta-msft 9fabebb
              
                Merging with latest dev
              
              
                surgupta-msft 7b9d330
              
                Resolving PR comments
              
              
                surgupta-msft aec780c
              
                Adding delay in a test
              
              
                surgupta-msft e73076f
              
                Added 10sec delay
              
              
                surgupta-msft 6d10a1b
              
                Updating grace period to 10 sec
              
              
                surgupta-msft dfe4e84
              
                Code cleanup
              
              
                surgupta-msft 9d9012e
              
                Removing blank line and unused libraries
              
              
                surgupta-msft c55152f
              
                Duplicate variable
              
              
                surgupta-msft e5faf24
              
                Merge branch 'dev' into surgupta/graceful-shutdown-worker
              
              
                surgupta-msft 2d48f97
              
                Fixing typo
              
              
                surgupta-msft bad68b6
              
                Revert "Fixing typo"
              
              
                surgupta-msft 5dd1dbb
              
                Improving wait for gracePeriod
              
              
                surgupta-msft c8796c8
              
                Merge branch 'dev' into surgupta/graceful-shutdown-worker
              
              
                surgupta-msft 7a1f75e
              
                Adding unite test
              
              
                surgupta-msft 2236f9e
              
                updated UT
              
              
                surgupta-msft f921c56
              
                Removing extra log line
              
              
                surgupta-msft 73b3a38
              
                Merge branch 'dev' into surgupta/graceful-shutdown-worker
              
              
                surgupta-msft 246862b
              
                Changes to handle exceptions and timeout
              
              
                surgupta-msft 879626b
              
                Removing dispose from jobobjectregistry
              
              
                surgupta-msft 576b09f
              
                Removing unused disposed variable
              
              
                surgupta-msft 68625d7
              
                Changing log level from warning to info
              
              
                surgupta-msft 3a0d58c
              
                minor change
              
              
                surgupta-msft df9b50b
              
                Adding StopProcess in IWorkerProcess
              
              
                surgupta-msft 31b48ca
              
                Merge branch 'dev' into surgupta/graceful-shutdown-worker
              
              
                surgupta-msft cbbd2c0
              
                Added method WaitForProcessTermination()
              
              
                surgupta-msft 96dbae2
              
                Wait Period in Seconds
              
              
                surgupta-msft b8d767e
              
                Fixing test failure
              
              
                surgupta-msft 38e7b32
              
                Fixing test failures
              
              
                surgupta-msft 2ed34ef
              
                Changes in workerprocess
              
              
                surgupta-msft dd46133
              
                CHanges in workerprocess and tests
              
              
                surgupta-msft 9da12db
              
                Adding release notes
              
              
                surgupta-msft eda9d27
              
                Revert "CHanges in workerprocess and tests"
              
              
                surgupta-msft b606e5b
              
                Test changes for debugging
              
              
                surgupta-msft d0f52cf
              
                Merging with latest dev
              
              
                surgupta-msft cce2cae
              
                Adding capability
              
              
                surgupta-msft 7886492
              
                Sequential stop and start
              
              
                surgupta-msft 0d9d953
              
                Updating release notes and minor fixes
              
              
                surgupta-msft 004acb3
              
                Minor fixes
              
              
                surgupta-msft a3b1b39
              
                Updating worker process
              
              
                surgupta-msft 762f0c0
              
                Reseting worker init timeout
              
              
                surgupta-msft b950549
              
                Adding destructor in JobObjectRegistry
              
              
                surgupta-msft fbaa461
              
                Removing finally block from worker process
              
              
                surgupta-msft b3518f8
              
                Merging with Dev
              
              
                surgupta-msft ffe8cfb
              
                Updating release notes
              
              
                surgupta-msft 4a0b7f0
              
                Removing extra log lines
              
              
                surgupta-msft 59c2a09
              
                Checking process termination in JobObjectRegistry dispose
              
              
                surgupta-msft 5a79ab3
              
                Naming updates
              
              
                surgupta-msft 1cd4f8b
              
                Improving WaitForExit method
              
              
                surgupta-msft File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -14,6 +14,7 @@ | |
| using System.Threading.Tasks; | ||
| using System.Threading.Tasks.Dataflow; | ||
| using Google.Protobuf.Collections; | ||
| using Google.Protobuf.WellKnownTypes; | ||
| using Microsoft.Azure.WebJobs.Logging; | ||
| using Microsoft.Azure.WebJobs.Script.Description; | ||
| using Microsoft.Azure.WebJobs.Script.Diagnostics; | ||
|  | @@ -901,10 +902,36 @@ protected virtual void Dispose(bool disposing) | |
|  | ||
| public void Dispose() | ||
| { | ||
| StopWorkerProcess(); | ||
| _disposing = true; | ||
| Dispose(true); | ||
| } | ||
|  | ||
| private void StopWorkerProcess() | ||
| { | ||
| bool capabilityEnabled = !string.IsNullOrEmpty(_workerCapabilities.GetCapabilityState(RpcWorkerConstants.HandlesWorkerTerminateMessage)); | ||
| if (!capabilityEnabled) | ||
| { | ||
| return; | ||
| } | ||
|  | ||
| int gracePeriod = WorkerConstants.WorkerTerminateGracePeriodInSeconds; | ||
|  | ||
| var workerTerminate = new WorkerTerminate() | ||
| { | ||
| GracePeriod = Duration.FromTimeSpan(TimeSpan.FromSeconds(gracePeriod)) | ||
| }; | ||
|  | ||
| _workerChannelLogger.LogDebug($"Sending WorkerTerminate message with grace period {gracePeriod} seconds."); | ||
|  | ||
| SendStreamingMessage(new StreamingMessage | ||
| { | ||
| WorkerTerminate = workerTerminate | ||
| }); | ||
|  | ||
| WorkerProcess.WaitForProcessExitInMilliSeconds(gracePeriod * 1000); | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. super nit here, but I don't feel we need to change the name, the method definition/summary should be enough to indicate if the parameter it takes is milliseconds or second | ||
| } | ||
|  | ||
| public async Task DrainInvocationsAsync() | ||
| { | ||
| _workerChannelLogger.LogDebug($"Count of in-buffer invocations waiting to be drained out: {_executingInvocations.Count}"); | ||
|  | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.