Skip to content

Commit 6cb7e94

Browse files
committed
Diagnostics: Add check for lima disk size overrides
This adds a check to see if the user has a lima override file set, and disk sizes set within that. If this is present, it breaks our settings for the disk size. Signed-off-by: Mark Yen <[email protected]>
1 parent 9cf970b commit 6cb7e94

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

pkg/rancher-desktop/main/diagnostics/diagnostics.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export class DiagnosticsManager {
5959
import('./kubeContext'),
6060
import('./kubeVersionsAvailable'),
6161
import('./limaDarwin'),
62+
import('./limaOverrides'),
6263
import('./mockForScreenshots'),
6364
import('./pathManagement'),
6465
import('./rdBinInShell'),
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
4+
import yaml from 'yaml';
5+
6+
import { DiagnosticsCategory, DiagnosticsChecker, DiagnosticsCheckerSingleResult } from './types';
7+
8+
import paths from '@pkg/utils/paths';
9+
10+
/**
11+
* Check for things in the user's Lima overrides file. We never create the file
12+
* ourselves, but the user may manually create it to adjust how Lima runs; it
13+
* may end up conflicting with what we attempt to do.
14+
*/
15+
const CheckLimaOverrides: DiagnosticsChecker = {
16+
id: 'LIMA_OVERRIDES',
17+
category: DiagnosticsCategory.ContainerEngine,
18+
applicable() {
19+
return Promise.resolve(process.platform !== 'win32');
20+
},
21+
async check() {
22+
const overridePath = path.join(paths.lima, '_config', 'override.yaml');
23+
const checkers = {
24+
/**
25+
* Check if the user has an override for the lima disk size. We have built-in
26+
* support for the feature now, and overrides would cause our settings to be
27+
* ignored.
28+
*/
29+
DISK_SIZE: (override) => {
30+
if ('disk' in override) {
31+
return {
32+
description: `Disk overrides are set in Lima override file \`${ overridePath }\``,
33+
passed: false,
34+
fixes: [{
35+
description: `Remove Lima override file \`${ overridePath }\``,
36+
}],
37+
};
38+
}
39+
return {
40+
description: `Disk size override not specified in Lima override file \`${ overridePath }\``,
41+
passed: true,
42+
fixes: [],
43+
};
44+
},
45+
} satisfies Record<string, (override: any) => Omit<DiagnosticsCheckerSingleResult, 'id'>>;
46+
const override = await (async function() {
47+
try {
48+
return yaml.parse(await fs.promises.readFile(overridePath, 'utf-8'));
49+
} catch {
50+
return undefined;
51+
}
52+
})();
53+
54+
if (!override || typeof override !== 'object') {
55+
// Override file does not exist, or is not valid YAML
56+
return Object.keys(checkers).map(id => ({
57+
id,
58+
description: `Override file \`${ overridePath }\` not loaded`,
59+
passed: true,
60+
fixes: [],
61+
}));
62+
}
63+
64+
return Object.entries(checkers).map(([id, checker]) => ({
65+
id,
66+
...checker(override),
67+
}));
68+
},
69+
};
70+
71+
export default CheckLimaOverrides;

0 commit comments

Comments
 (0)