@@ -193,19 +193,48 @@ async fn instance_launch() -> Result<()> {
193
193
194
194
// check that we saw it on the console
195
195
eprintln ! ( "waiting for serial console" ) ;
196
- sleep ( Duration :: from_secs ( 5 ) ) . await ;
197
- let data = String :: from_utf8_lossy (
198
- & ctx. client
199
- . instance_serial_console ( )
200
- . project ( ctx. project_name . clone ( ) )
201
- . instance ( instance. name . clone ( ) )
202
- . most_recent ( 1024 * 1024 )
203
- . max_bytes ( 1024 * 1024 )
204
- . send ( )
205
- . await ?
206
- . data ,
196
+
197
+ let data = wait_for_condition (
198
+ || async {
199
+ type Error =
200
+ CondCheckError < oxide_client:: Error < oxide_client:: types:: Error > > ;
201
+
202
+ let instance_state = ctx
203
+ . client
204
+ . instance_view ( )
205
+ . project ( ctx. project_name . clone ( ) )
206
+ . instance ( instance. name . clone ( ) )
207
+ . send ( )
208
+ . await ?
209
+ . run_state ;
210
+
211
+ if instance_state == InstanceState :: Starting {
212
+ return Err ( Error :: NotYet ) ;
213
+ }
214
+
215
+ let data = String :: from_utf8_lossy (
216
+ & ctx. client
217
+ . instance_serial_console ( )
218
+ . project ( ctx. project_name . clone ( ) )
219
+ . instance ( instance. name . clone ( ) )
220
+ . most_recent ( 1024 * 1024 )
221
+ . max_bytes ( 1024 * 1024 )
222
+ . send ( )
223
+ . await ?
224
+ . data ,
225
+ )
226
+ . into_owned ( ) ;
227
+ if data. contains ( "-----END SSH HOST KEY KEYS-----" ) {
228
+ Ok ( data)
229
+ } else {
230
+ Err ( Error :: NotYet )
231
+ }
232
+ } ,
233
+ & Duration :: from_secs ( 5 ) ,
234
+ & Duration :: from_secs ( 300 ) ,
207
235
)
208
- . into_owned ( ) ;
236
+ . await ?;
237
+
209
238
ensure ! (
210
239
data. contains( "Hello, Oxide!" ) ,
211
240
"string not seen on console\n {}" ,
0 commit comments