@@ -148,13 +148,6 @@ export const runDeployApps = async (options: {
148148
149149 core . info ( `Deploy app '${ appName } ' to '${ environment } '${ tenantLabel } ...` ) ;
150150
151- // Enable maintenance mode on existing apps before deploying
152- const appExists = ( await fly . status ( { app : appName } ) ) !== null ;
153- if ( appExists ) {
154- core . info ( `Enabling maintenance mode for '${ appName } '` ) ;
155- await fly . secrets . set ( { MAINTENANCE_MODE : 'true' } , { app : appName } ) ;
156- }
157-
158151 // Deploy app
159152 try {
160153 const result = await fly . deploy ( {
@@ -192,66 +185,6 @@ export const runDeployApps = async (options: {
192185 if ( isHostDeployment ) {
193186 failedHostApps . add ( configAppName ) ;
194187 }
195- } finally {
196- if ( appExists ) {
197- core . info ( `Disabling maintenance mode for '${ appName } '` ) ;
198- // Fly.io machines may still be stabilizing after deploy — retry if the unset
199- // fails with a concurrent-update error.
200- let unsetSucceeded = false ;
201- const maxAttempts = 5 ;
202- const retryDelayMs = 15_000 ;
203- for ( let attempt = 1 ; attempt <= maxAttempts ; attempt ++ ) {
204- try {
205- await fly . secrets . unset ( 'MAINTENANCE_MODE' , { app : appName } ) ;
206- unsetSucceeded = true ;
207- break ;
208- } catch ( cleanupError ) {
209- const msg =
210- cleanupError instanceof Error
211- ? cleanupError . message
212- : String ( cleanupError ) ;
213- if ( attempt === maxAttempts ) {
214- core . warning (
215- `Failed to disable maintenance mode for '${ appName } ' after ${ maxAttempts } attempts: ${ msg } `
216- ) ;
217- } else {
218- core . info (
219- `Retry ${ attempt } /${ maxAttempts - 1 } disabling maintenance mode for '${ appName } ' in ${ retryDelayMs / 1000 } s: ${ msg } `
220- ) ;
221- await new Promise ( ( r ) => setTimeout ( r , retryDelayMs ) ) ;
222- }
223- }
224- }
225-
226- // MAINTENANCE_MODE is baked into the machine's per-machine config.env
227- // from when it was a Fly secret during deployment. fly secrets unset
228- // removes it from the secrets store but NOT from the machine-level config.
229- // fly machine update creates a new machine version with the env var cleared,
230- // forcing a cold restart — not a resume from a suspended memory snapshot.
231- if ( unsetSucceeded ) {
232- const statusAfterUnset = await fly . status ( { app : appName } ) ;
233- if ( statusAfterUnset ?. machines ) {
234- for ( const machine of statusAfterUnset . machines ) {
235- try {
236- core . info (
237- `Clearing MAINTENANCE_MODE env for machine '${ machine . id } ' of '${ appName } '`
238- ) ;
239- await fly . machines . update ( appName , machine . id , {
240- env : { MAINTENANCE_MODE : '' }
241- } ) ;
242- } catch ( updateErr ) {
243- const msg =
244- updateErr instanceof Error
245- ? updateErr . message
246- : String ( updateErr ) ;
247- core . warning (
248- `Failed to clear MAINTENANCE_MODE for machine '${ machine . id } ' of '${ appName } ': ${ msg } `
249- ) ;
250- }
251- }
252- }
253- }
254- }
255188 }
256189 }
257190
0 commit comments