@@ -31,7 +31,7 @@ func resourceRunner() *schema.Resource {
3131 DeleteContext : resourceRunnerDelete ,
3232 ReadContext : resourceMachineRead ,
3333 Timeouts : & schema.ResourceTimeout {
34- Create : schema .DefaultTimeout (10 * time .Minute ),
34+ Create : schema .DefaultTimeout (20 * time .Minute ),
3535 Update : schema .DefaultTimeout (10 * time .Minute ),
3636 Delete : schema .DefaultTimeout (10 * time .Minute ),
3737 },
@@ -247,27 +247,30 @@ func resourceRunnerCreate(ctx context.Context, d *schema.ResourceData, m interfa
247247
248248 var logError error
249249 var logEvents string
250- err = resource .Retry (d .Timeout (schema .TimeoutCreate ), func () * resource.RetryError {
251- switch cloud := d .Get ("cloud" ).(string ); cloud {
250+ cloud := d .Get ("cloud" ).(string )
251+ ip := d .Get ("instance_ip" ).(string )
252+ err = resource .Retry (d .Timeout (schema .TimeoutCreate )- time .Minute , func () * resource.RetryError {
253+
254+ switch cloud {
252255 case "kubernetes" :
253256 logEvents , logError = resourceMachineLogs (ctx , d , m )
254257 default :
255258 logEvents , logError = utils .RunCommand ("journalctl --unit cml --no-pager" ,
256259 2 * time .Second ,
257- net .JoinHostPort (d . Get ( "instance_ip" ).( string ) , "22" ),
260+ net .JoinHostPort (ip , "22" ),
258261 "ubuntu" ,
259262 d .Get ("ssh_private" ).(string ))
260263 }
261264
262- log .Printf ("[DEBUG] Collected log events: %#v" , logEvents )
263- log .Printf ("[DEBUG] Connection errors: %#v" , logError )
264-
265265 if logError != nil {
266- return resource .RetryableError (fmt .Errorf ("Waiting for the machine to accept connections... %s" , logError ))
267- } else if utils .HasStatus (logEvents , "terminated" ) {
268- return resource .NonRetryableError (fmt .Errorf ("Failed to launch the runner!" ))
269- } else if utils .HasStatus (logEvents , "ready" ) {
270- return nil
266+ log .Printf ("[DEBUG] Connection errors: %#v" , logError )
267+ } else {
268+ log .Printf ("[DEBUG] Collected log events: %#v" , logEvents )
269+ if utils .HasStatus (logEvents , "terminated" ) {
270+ return resource .NonRetryableError (fmt .Errorf ("Failed to launch the runner!" ))
271+ } else if utils .HasStatus (logEvents , "ready" ) {
272+ return nil
273+ }
271274 }
272275
273276 return resource .RetryableError (fmt .Errorf ("Waiting for the runner to be ready..." ))
@@ -374,9 +377,11 @@ EOF'
374377{{- if .cloud}}
375378sudo systemctl daemon-reload
376379sudo systemctl enable cml.service
377- {{- if .instance_gpu}}
378- nvidia-smi &>/dev/null || reboot
379- {{- end}}
380+
381+ if ubuntu-drivers devices | grep -q NVIDIA; then
382+ (sudo modprobe nvidia && sudo nvidia-smi) || sudo reboot
383+ fi
384+
380385sudo systemctl start cml.service
381386{{- end}}
382387
0 commit comments