@@ -93,8 +93,6 @@ impl IntoSubsystem<Report> for RelaySubsystem<StatusCode> {
9393 let mut observations = self . observations ;
9494 loop {
9595 select ! {
96- // TODO: We need to release the lock on
97- // any states we've locked.
9896 // Besides that, we can just hang out.
9997 _ = subsys. on_shutdown_requested( ) => {
10098 subsys. wait_for_children( ) . await ;
@@ -116,7 +114,6 @@ impl IntoSubsystem<Report> for RelaySubsystem<StatusCode> {
116114 // • We also need to poll the backend for new states.
117115 elem = state_stream. recv( ) => {
118116 debug!( "Received new state: {:?}" , & elem) ;
119- let mut trigger_shutdown = false ;
120117
121118 if let Some ( state) = elem {
122119 let state_id = state. id;
@@ -142,8 +139,8 @@ impl IntoSubsystem<Report> for RelaySubsystem<StatusCode> {
142139 // Ingress operation.
143140 self . ingress. promote_canary( ) . await ?;
144141
145- // If the canary is promoted, we can safely just shut down the CLI
146- trigger_shutdown = true ;
142+ locked_state . mark_done ( ) . await ? ;
143+ subsys . request_shutdown ( ) ;
147144 } ,
148145 DeployCanary => {
149146 // First, we deploy the canary to the platform. At
@@ -156,6 +153,7 @@ impl IntoSubsystem<Report> for RelaySubsystem<StatusCode> {
156153 info!( "Releasing the application..." ) ;
157154 self . ingress. release_canary( platform_id) . await . inspect( |res| debug!( "Result: {res:?}" ) ) ?;
158155 info!( "Release successful! Beginning canarying..." ) ;
156+ locked_state. mark_done( ) . await ?;
159157 } ,
160158 SetCanaryTraffic => {
161159 let percent_traffic = if let Some ( data) = locked_state. state( ) . data. clone( ) . flatten( ) {
@@ -166,27 +164,18 @@ impl IntoSubsystem<Report> for RelaySubsystem<StatusCode> {
166164 } ;
167165 let percent = WholePercent :: try_from( percent_traffic) . unwrap( ) ;
168166 self . ingress. set_canary_traffic( percent) . await ?;
167+ locked_state. mark_done( ) . await ?;
169168 } ,
170169 RollbackCanary => {
171170 // Set traffic to 0 immediately.
172171 self . ingress. set_canary_traffic( WholePercent :: try_from( 0 ) . unwrap( ) ) . await ?;
173172 // Then, yank the canary from the ingress.
174173 self . ingress. rollback_canary( ) . await ?;
175174
176- // If the canary is rolled back, we can safely just shut down the CLI
177- trigger_shutdown = true ;
175+ locked_state . mark_done ( ) . await ? ;
176+ subsys . request_shutdown ( ) ;
178177 } ,
179178 }
180- // Since the action completed successfully,
181- // we can release the lock and tell the backend
182- // that the state has been effected.
183- locked_state. mark_done( ) . await ?;
184-
185- // This is separated so we can mark the state as done
186- // before we shut down.
187- if trigger_shutdown {
188- subsys. request_shutdown( ) ;
189- }
190179 } else {
191180 // The stream has been closed, so we should shutdown.
192181 subsys. request_shutdown( ) ;
0 commit comments