33using System . Linq ;
44using System . Threading ;
55using System . Threading . Tasks ;
6+ using Halibut ;
67using Halibut . ServiceModel ;
78using Octopus . Tentacle . Client . EventDriven ;
89using Octopus . Tentacle . Client . Execution ;
@@ -165,21 +166,31 @@ public async Task<ScriptOperationExecutionResult> CancelScript(CommandContext co
165166
166167 public async Task < ScriptStatus ? > CompleteScript ( CommandContext lastStatusResponse , CancellationToken scriptExecutionCancellationToken )
167168 {
168- using var activity = TentacleClient . ActivitySource . StartActivity ( $ "{ nameof ( ScriptServiceV1Executor ) } .{ nameof ( CompleteScript ) } ") ;
169- var response = await rpcCallExecutor . ExecuteWithNoRetries (
170- RpcCall . Create < IScriptService > ( nameof ( IScriptService . CompleteScript ) ) ,
171- async ct =>
172- {
173- var request = new CompleteScriptCommand ( lastStatusResponse . ScriptTicket , lastStatusResponse . NextLogSequence ) ;
174- var result = await clientScriptServiceV1 . CompleteScriptAsync ( request , new HalibutProxyRequestOptions ( ct ) ) ;
175-
176- return result ;
177- } ,
178- logger ,
179- clientOperationMetricsBuilder ,
180- CancellationToken . None ) . ConfigureAwait ( false ) ;
169+ try
170+ {
171+ using var activity = TentacleClient . ActivitySource . StartActivity ( $ "{ nameof ( ScriptServiceV1Executor ) } .{ nameof ( CompleteScript ) } ") ;
172+ var response = await rpcCallExecutor . ExecuteWithNoRetries (
173+ RpcCall . Create < IScriptService > ( nameof ( IScriptService . CompleteScript ) ) ,
174+ async ct =>
175+ {
176+ var request = new CompleteScriptCommand ( lastStatusResponse . ScriptTicket , lastStatusResponse . NextLogSequence ) ;
177+ var result = await clientScriptServiceV1 . CompleteScriptAsync ( request , new HalibutProxyRequestOptions ( ct ) ) ;
178+
179+ return result ;
180+ } ,
181+ logger ,
182+ clientOperationMetricsBuilder ,
183+ CancellationToken . None ) . ConfigureAwait ( false ) ;
184+
185+ return MapToScriptStatus ( response ) ;
186+ }
187+ catch ( Exception ex ) when ( ex is HalibutClientException or OperationCanceledException )
188+ {
189+ logger . Warn ( "Failed to cleanup the script working directory on Tentacle" ) ;
190+ logger . Verbose ( ex ) ;
191+ }
181192
182- return MapToScriptStatus ( response ) ;
193+ return null ;
183194 }
184195 }
185196}
0 commit comments