@@ -84,23 +84,17 @@ private ScriptStatus MapToScriptStatus(KubernetesScriptStatusResponseV1Alpha scr
8484
8585 private ITicketForNextStatus MapToNextStatus ( KubernetesScriptStatusResponseV1Alpha scriptStatusResponse )
8686 {
87- return new DefaultTicketForNextStatus ( scriptStatusResponse . ScriptTicket , scriptStatusResponse . NextLogSequence , ScriptServiceVersion . ScriptServiceVersion1 ) ;
87+ return new DefaultTicketForNextStatus ( scriptStatusResponse . ScriptTicket , scriptStatusResponse . NextLogSequence , ScriptServiceVersion . KubernetesScriptServiceVersion1Alpha ) ;
8888 }
8989
9090 ( ScriptStatus , ITicketForNextStatus ) Map ( KubernetesScriptStatusResponseV1Alpha r )
9191 {
9292 return ( MapToScriptStatus ( r ) , MapToNextStatus ( r ) ) ;
9393 }
9494
95- public async Task < ( ScriptStatus , ITicketForNextStatus ) > StartScript ( ExecuteScriptCommand command , CancellationToken scriptExecutionCancellationToken )
96- {
97- return Map ( await _StartScript ( command , scriptExecutionCancellationToken ) ) ;
98- }
99-
100- private async Task < KubernetesScriptStatusResponseV1Alpha > _StartScript ( ExecuteScriptCommand executeScriptCommand , CancellationToken scriptExecutionCancellationToken )
95+ public async Task < ( ScriptStatus , ITicketForNextStatus ) > StartScript ( ExecuteScriptCommand executeScriptCommand , CancellationToken scriptExecutionCancellationToken )
10196 {
10297 var command = Map ( executeScriptCommand ) ;
103- KubernetesScriptStatusResponseV1Alpha scriptStatusResponse ;
10498 var startScriptCallsConnectedCount = 0 ;
10599 try
106100 {
@@ -121,14 +115,16 @@ void OnErrorAction(Exception ex)
121115 }
122116 }
123117
124- scriptStatusResponse = await rpcCallExecutor . Execute (
118+ var scriptStatusResponse = await rpcCallExecutor . Execute (
125119 retriesEnabled : clientOptions . RpcRetrySettings . RetriesEnabled ,
126120 RpcCall . Create < IKubernetesScriptServiceV1Alpha > ( nameof ( IKubernetesScriptServiceV1Alpha . StartScript ) ) ,
127121 StartScriptAction ,
128122 OnErrorAction ,
129123 logger ,
130124 clientOperationMetricsBuilder ,
131125 scriptExecutionCancellationToken ) . ConfigureAwait ( false ) ;
126+
127+ return ( MapToScriptStatus ( scriptStatusResponse ) , MapToNextStatus ( scriptStatusResponse ) ) ;
132128 }
133129 catch ( Exception ex ) when ( scriptExecutionCancellationToken . IsCancellationRequested )
134130 {
@@ -142,36 +138,15 @@ void OnErrorAction(Exception ex)
142138
143139 if ( ! startScriptCallIsConnecting || startScriptCallIsBeingRetried )
144140 {
145- // We have to assume the script started executing and call CancelScript and CompleteScript
146- // We don't have a response so we need to create one to continue the execution flow
147- scriptStatusResponse = new KubernetesScriptStatusResponseV1Alpha (
148- command . ScriptTicket ,
149- ProcessState . Pending ,
150- ScriptExitCodes . RunningExitCode ,
151- new List < ProcessOutput > ( ) ,
152- 0 ) ;
153-
154- try
155- {
156- new ShortCutTakenHere ( ) ;
157- //await ObserveUntilCompleteThenFinish(scriptStatusResponse, scriptExecutionCancellationToken).ConfigureAwait(false);
158- }
159- catch ( Exception observerUntilCompleteException )
160- {
161- // Throw an error so the caller knows that execution of the script was cancelled
162- throw new OperationCanceledException ( "Script execution was cancelled" , observerUntilCompleteException ) ;
163- }
164-
165- // Throw an error so the caller knows that execution of the script was cancelled
166- throw new OperationCanceledException ( "Script execution was cancelled" ) ;
141+ var scriptStatus = new ScriptStatus ( ProcessState . Pending , null , new List < ProcessOutput > ( ) ) ;
142+ var defaultTicketForNextStatus = new DefaultTicketForNextStatus ( command . ScriptTicket , 0 , ScriptServiceVersion . KubernetesScriptServiceVersion1Alpha ) ;
143+ return ( scriptStatus , defaultTicketForNextStatus ) ;
167144 }
168145
169146 // If the StartScript call was not in-flight or being retries then we know the script has not started executing on Tentacle
170147 // So can exit without calling CancelScript or CompleteScript
171148 throw new OperationCanceledException ( "Script execution was cancelled" , ex ) ;
172149 }
173-
174- return scriptStatusResponse ;
175150 }
176151
177152 public async Task < ( ScriptStatus , ITicketForNextStatus ) > GetStatus ( ITicketForNextStatus lastStatusResponse , CancellationToken scriptExecutionCancellationToken )
0 commit comments