@@ -546,6 +546,7 @@ export default class LimaBackend extends events.EventEmitter implements VMBacken
546
546
memory : ( this . cfg ?. memoryInGB || 4 ) * 1024 * 1024 * 1024 ,
547
547
mounts : [
548
548
{ location : path . join ( paths . cache , 'k3s' ) , writable : false } ,
549
+ { location : paths . logs , writable : true } ,
549
550
{ location : '~' , writable : true } ,
550
551
{ location : '/tmp/rancher-desktop' , writable : true } ,
551
552
] ,
@@ -1593,6 +1594,10 @@ export default class LimaBackend extends events.EventEmitter implements VMBacken
1593
1594
return ;
1594
1595
}
1595
1596
1597
+ if ( kubernetesVersion ) {
1598
+ await this . kubeBackend . deleteIncompatibleData ( kubernetesVersion ) ;
1599
+ }
1600
+
1596
1601
await this . progressTracker . action ( 'Configuring containerd' , 50 , this . configureContainerd ( ) ) ;
1597
1602
if ( config . containerEngine === ContainerEngine . CONTAINERD ) {
1598
1603
await this . startService ( 'containerd' ) ;
@@ -2032,7 +2037,6 @@ class LimaKubernetesBackend extends events.EventEmitter implements K8s.Kubernete
2032
2037
// Run rc-update as we have dynamic dependencies.
2033
2038
await this . vm . execCommand ( { root : true } , '/sbin/rc-update' , '--update' ) ;
2034
2039
await this . vm . execCommand ( { root : true } , '/sbin/rc-service' , '--ifnotstarted' , 'k3s' , 'start' ) ;
2035
- await this . followLogs ( ) ;
2036
2040
} ) ;
2037
2041
2038
2042
await this . progressTracker . action (
@@ -2146,28 +2150,6 @@ class LimaKubernetesBackend extends events.EventEmitter implements K8s.Kubernete
2146
2150
return k3sEndpoint ;
2147
2151
}
2148
2152
2149
- protected async followLogs ( ) {
2150
- try {
2151
- this . logProcess ?. kill ( 'SIGTERM' ) ;
2152
- } catch ( ex ) { }
2153
- this . logProcess = this . vm . spawn (
2154
- { logStream : await Logging . k3s . fdStream } ,
2155
- '/usr/bin/tail' , '-n+1' , '-F' , '/var/log/k3s.log' ) ;
2156
- this . logProcess . on ( 'exit' , ( status , signal ) => {
2157
- this . logProcess = null ;
2158
- if ( ! [ Action . STARTING , Action . NONE ] . includes ( this . vm . currentAction ) ) {
2159
- // Allow the log process to exit if we're stopping
2160
- return ;
2161
- }
2162
- if ( ! [ State . STARTING , State . STARTED ] . includes ( this . vm . state ) ) {
2163
- // Allow the log process to exit if we're not active.
2164
- return ;
2165
- }
2166
- console . log ( `Log process exited with ${ status } /${ signal } , restarting...` ) ;
2167
- setTimeout ( this . followLogs . bind ( this ) , 1_000 ) ;
2168
- } ) ;
2169
- }
2170
-
2171
2153
async stop ( ) {
2172
2154
if ( this . cfg ?. enabled ) {
2173
2155
try {
@@ -2208,9 +2190,6 @@ class LimaKubernetesBackend extends events.EventEmitter implements K8s.Kubernete
2208
2190
2209
2191
protected client : KubeClient | null = null ;
2210
2192
2211
- /** Process for tailing logs */
2212
- protected logProcess : childProcess . ChildProcess | null = null ;
2213
-
2214
2193
protected get progressTracker ( ) {
2215
2194
return this . vm . progressTracker ;
2216
2195
}
@@ -2264,21 +2243,15 @@ class LimaKubernetesBackend extends events.EventEmitter implements K8s.Kubernete
2264
2243
* @param version The version to install.
2265
2244
*/
2266
2245
protected async installK3s ( version : semver . SemVer ) {
2267
- const workdir = await fs . promises . mkdtemp ( path . join ( os . tmpdir ( ) , 'rd- k3s-install-' ) ) ;
2246
+ const k3s = this . arch === 'aarch64' ? ' k3s-arm64' : 'k3s' ;
2268
2247
2269
- try {
2270
- const k3s = this . arch === 'aarch64' ? 'k3s-arm64' : 'k3s' ;
2271
-
2272
- await this . vm . execCommand ( 'mkdir' , '-p' , 'bin' ) ;
2273
- await this . vm . writeFile ( 'bin/install-k3s' , INSTALL_K3S_SCRIPT , 'a+x' ) ;
2274
- await fs . promises . chmod ( path . join ( paths . cache , 'k3s' , version . raw , k3s ) , 0o755 ) ;
2275
- await this . vm . execCommand ( { root : true } , 'bin/install-k3s' , version . raw , path . join ( paths . cache , 'k3s' ) ) ;
2276
- const profilePath = path . join ( paths . resources , 'scripts' , 'profile' ) ;
2248
+ await this . vm . execCommand ( 'mkdir' , '-p' , 'bin' ) ;
2249
+ await this . vm . writeFile ( 'bin/install-k3s' , INSTALL_K3S_SCRIPT , 'a+x' ) ;
2250
+ await fs . promises . chmod ( path . join ( paths . cache , 'k3s' , version . raw , k3s ) , 0o755 ) ;
2251
+ await this . vm . execCommand ( { root : true } , 'bin/install-k3s' , version . raw , path . join ( paths . cache , 'k3s' ) ) ;
2252
+ const profilePath = path . join ( paths . resources , 'scripts' , 'profile' ) ;
2277
2253
2278
- await this . vm . lima ( 'copy' , profilePath , `${ MACHINE_NAME } :~/.profile` ) ;
2279
- } finally {
2280
- await fs . promises . rm ( workdir , { recursive : true } ) ;
2281
- }
2254
+ await this . vm . lima ( 'copy' , profilePath , `${ MACHINE_NAME } :~/.profile` ) ;
2282
2255
}
2283
2256
2284
2257
/**
@@ -2289,6 +2262,7 @@ class LimaKubernetesBackend extends events.EventEmitter implements K8s.Kubernete
2289
2262
PORT : this . desiredPort . toString ( ) ,
2290
2263
ENGINE : cfg . containerEngine ?? ContainerEngine . NONE ,
2291
2264
ADDITIONAL_ARGS : '' ,
2265
+ LOG_DIR : paths . logs ,
2292
2266
} ;
2293
2267
2294
2268
if ( allowSudo && os . platform ( ) === 'darwin' ) {
@@ -2318,7 +2292,7 @@ class LimaKubernetesBackend extends events.EventEmitter implements K8s.Kubernete
2318
2292
* Delete k3s data that may cause issues if we were to move to the given
2319
2293
* version.
2320
2294
*/
2321
- protected async deleteIncompatibleData ( desiredVersion : semver . SemVer ) {
2295
+ async deleteIncompatibleData ( desiredVersion : semver . SemVer ) {
2322
2296
const existingVersion = await K3sHelper . getInstalledK3sVersion ( this . vm ) ;
2323
2297
2324
2298
if ( ! existingVersion ) {
0 commit comments