@@ -326,6 +326,7 @@ export class Install {
326326 try {
327327 await Exec . exec ( `limactl ${ limaStartArgs . join ( ' ' ) } ` , [ ] , { env : envs } ) ;
328328 } catch ( e ) {
329+ await this . printDarwinDiagnostics ( ) ;
329330 fsp
330331 . readdir ( limaDir )
331332 . then ( files => {
@@ -539,11 +540,7 @@ EOF`,
539540 }
540541
541542 private async tearDownDarwin ( ) : Promise < void > {
542- await core . group ( 'Docker daemon logs' , async ( ) => {
543- await Exec . exec ( 'limactl' , [ 'shell' , '--tty=false' , this . limaInstanceName , 'sudo' , 'journalctl' , '-u' , 'docker.service' , '-l' , '--no-pager' ] ) . catch ( ( ) => {
544- core . warning ( `Failed to get Docker daemon logs` ) ;
545- } ) ;
546- } ) ;
543+ await this . printDarwinDiagnostics ( ) ;
547544 await core . group ( 'Stopping lima instance' , async ( ) => {
548545 await Exec . exec ( 'limactl' , [ 'stop' , '--tty=false' , this . limaInstanceName , '--force' ] ) ;
549546 } ) ;
@@ -558,6 +555,36 @@ EOF`,
558555 } ) ;
559556 }
560557
558+ private async printDarwinDiagnostics ( ) : Promise < void > {
559+ await this . printDarwinGuestCommandOutput ( 'Cloud-init output log' , [ 'sudo' , 'cat' , '/var/log/cloud-init-output.log' ] ) ;
560+ await this . printDarwinGuestCommandOutput ( 'Cloud-init status' , [ 'sudo' , 'timeout' , '300s' , 'cloud-init' , 'status' , '--wait' ] ) ;
561+ await this . printDarwinGuestCommandOutput ( 'Docker unit file' , [ 'sudo' , 'systemctl' , 'cat' , 'docker.service' ] ) ;
562+ await this . printDarwinGuestCommandOutput ( 'Docker service status' , [ 'sudo' , 'systemctl' , 'status' , 'docker.service' , 'docker.socket' , '-l' , '--no-pager' ] ) ;
563+ await this . printDarwinGuestCommandOutput ( 'Archive install script log' , [ 'sudo' , 'cat' , '/var/log/docker-actions-toolkit-archive-install.log' ] ) ;
564+ await this . printDarwinGuestCommandOutput ( 'Docker daemon logs' , [ 'sudo' , 'journalctl' , '-u' , 'docker.service' , '-l' , '--no-pager' ] ) ;
565+ }
566+
567+ private async printDarwinGuestCommandOutput ( title : string , args : string [ ] ) : Promise < void > {
568+ await core . group ( title , async ( ) => {
569+ const res = await Exec . getExecOutput ( 'limactl' , [ 'shell' , '--tty=false' , this . limaInstanceName , ...args ] , {
570+ ignoreReturnCode : true ,
571+ silent : true
572+ } ) . catch ( error => {
573+ core . info ( `Failed to get ${ title } : ${ error } ` ) ;
574+ return undefined ;
575+ } ) ;
576+ if ( ! res ) {
577+ return ;
578+ }
579+ const output = [ res . stdout . trim ( ) , res . stderr . trim ( ) ] . filter ( Boolean ) . join ( '\n' ) ;
580+ if ( output . length > 0 ) {
581+ core . info ( output ) ;
582+ } else if ( res . exitCode !== 0 ) {
583+ core . info ( `${ title } exited with code ${ res . exitCode } ` ) ;
584+ }
585+ } ) ;
586+ }
587+
561588 private async tearDownLinux ( ) : Promise < void > {
562589 await core . group ( 'Docker daemon logs' , async ( ) => {
563590 core . info ( fs . readFileSync ( path . join ( this . runDir , 'dockerd.log' ) , { encoding : 'utf8' } ) ) ;
0 commit comments