fix: add JD01 GC retention controls
This commit is contained in:
@@ -18,6 +18,10 @@ interface RemoteGcOptions {
|
||||
tmp: boolean;
|
||||
tmpMinAgeHours: number;
|
||||
toolCaches: boolean;
|
||||
webObserveArtifacts: boolean;
|
||||
k3sImageCache: boolean;
|
||||
hostContainerdCache: boolean;
|
||||
localPathOrphans: boolean;
|
||||
aptCache: boolean;
|
||||
coreDumps: boolean;
|
||||
coreDumpMinAgeHours: number;
|
||||
@@ -45,6 +49,10 @@ const DEFAULT_REMOTE_OPTIONS: RemoteGcOptions = {
|
||||
tmp: true,
|
||||
tmpMinAgeHours: 24,
|
||||
toolCaches: false,
|
||||
webObserveArtifacts: false,
|
||||
k3sImageCache: false,
|
||||
hostContainerdCache: false,
|
||||
localPathOrphans: false,
|
||||
aptCache: true,
|
||||
coreDumps: true,
|
||||
coreDumpMinAgeHours: 1,
|
||||
@@ -63,6 +71,16 @@ const GC_CONFIG_RELATIVE_PATH = "config/unidesk-cli.yaml";
|
||||
const GC_REMOTE_CONFIG_REF = `${GC_CONFIG_RELATIVE_PATH}#gc.remote.targets`;
|
||||
const GC_REMOTE_RUNNER_RELATIVE_PATH = "scripts/src/gc-remote-runner.py";
|
||||
const GC_REMOTE_RUNNER_CONFIG_PLACEHOLDER = "__UNIDESK_GC_REMOTE_CONFIG_BASE64__";
|
||||
const GC_REMOTE_WEB_OBSERVE_RELATIVE_PATH = "scripts/src/gc-remote-web-observe.py";
|
||||
const GC_REMOTE_WEB_OBSERVE_PLACEHOLDER = "# __UNIDESK_GC_REMOTE_WEB_OBSERVE_HELPERS__";
|
||||
const GC_REMOTE_CONTAINERD_RELATIVE_PATH = "scripts/src/gc-remote-containerd.py";
|
||||
const GC_REMOTE_CONTAINERD_PLACEHOLDER = "# __UNIDESK_GC_REMOTE_CONTAINERD_HELPERS__";
|
||||
const GC_REMOTE_PVC_RELATIVE_PATH = "scripts/src/gc-remote-pvc.py";
|
||||
const GC_REMOTE_PVC_PLACEHOLDER = "# __UNIDESK_GC_REMOTE_PVC_HELPERS__";
|
||||
const GC_REMOTE_GROWTH_RELATIVE_PATH = "scripts/src/gc-remote-growth.py";
|
||||
const GC_REMOTE_GROWTH_PLACEHOLDER = "# __UNIDESK_GC_REMOTE_GROWTH_HELPERS__";
|
||||
const GC_REMOTE_REGISTRY_RELATIVE_PATH = "scripts/src/gc-remote-registry.py";
|
||||
const GC_REMOTE_REGISTRY_PLACEHOLDER = "# __UNIDESK_GC_REMOTE_REGISTRY_HELPERS__";
|
||||
|
||||
export async function runRemoteGcCommand(config: UniDeskConfig, providerId: string | undefined, action: string | undefined, args: string[]): Promise<unknown> {
|
||||
if (providerId === undefined || providerId.length === 0) {
|
||||
@@ -186,6 +204,22 @@ function parseRemoteGcOptions(args: string[]): RemoteGcOptions {
|
||||
options.toolCaches = true;
|
||||
} else if (arg === "--no-tool-caches") {
|
||||
options.toolCaches = false;
|
||||
} else if (arg === "--include-web-observe-artifacts") {
|
||||
options.webObserveArtifacts = true;
|
||||
} else if (arg === "--no-web-observe-artifacts") {
|
||||
options.webObserveArtifacts = false;
|
||||
} else if (arg === "--include-k3s-image-cache") {
|
||||
options.k3sImageCache = true;
|
||||
} else if (arg === "--no-k3s-image-cache") {
|
||||
options.k3sImageCache = false;
|
||||
} else if (arg === "--include-host-containerd-cache") {
|
||||
options.hostContainerdCache = true;
|
||||
} else if (arg === "--no-host-containerd-cache") {
|
||||
options.hostContainerdCache = false;
|
||||
} else if (arg === "--include-local-path-orphans") {
|
||||
options.localPathOrphans = true;
|
||||
} else if (arg === "--no-local-path-orphans") {
|
||||
options.localPathOrphans = false;
|
||||
} else if (arg === "--no-apt-cache") {
|
||||
options.aptCache = false;
|
||||
} else if (arg === "--no-core-dumps") {
|
||||
@@ -295,5 +329,31 @@ function remoteGcPython(configBase64: string): string {
|
||||
if (!template.includes(GC_REMOTE_RUNNER_CONFIG_PLACEHOLDER)) {
|
||||
throw new Error(`${GC_REMOTE_RUNNER_RELATIVE_PATH} missing ${GC_REMOTE_RUNNER_CONFIG_PLACEHOLDER}`);
|
||||
}
|
||||
return template.replace(GC_REMOTE_RUNNER_CONFIG_PLACEHOLDER, configBase64);
|
||||
if (!template.includes(GC_REMOTE_WEB_OBSERVE_PLACEHOLDER)) {
|
||||
throw new Error(`${GC_REMOTE_RUNNER_RELATIVE_PATH} missing ${GC_REMOTE_WEB_OBSERVE_PLACEHOLDER}`);
|
||||
}
|
||||
if (!template.includes(GC_REMOTE_CONTAINERD_PLACEHOLDER)) {
|
||||
throw new Error(`${GC_REMOTE_RUNNER_RELATIVE_PATH} missing ${GC_REMOTE_CONTAINERD_PLACEHOLDER}`);
|
||||
}
|
||||
if (!template.includes(GC_REMOTE_PVC_PLACEHOLDER)) {
|
||||
throw new Error(`${GC_REMOTE_RUNNER_RELATIVE_PATH} missing ${GC_REMOTE_PVC_PLACEHOLDER}`);
|
||||
}
|
||||
if (!template.includes(GC_REMOTE_GROWTH_PLACEHOLDER)) {
|
||||
throw new Error(`${GC_REMOTE_RUNNER_RELATIVE_PATH} missing ${GC_REMOTE_GROWTH_PLACEHOLDER}`);
|
||||
}
|
||||
if (!template.includes(GC_REMOTE_REGISTRY_PLACEHOLDER)) {
|
||||
throw new Error(`${GC_REMOTE_RUNNER_RELATIVE_PATH} missing ${GC_REMOTE_REGISTRY_PLACEHOLDER}`);
|
||||
}
|
||||
const webObserveHelpers = readFileSync(rootPath(GC_REMOTE_WEB_OBSERVE_RELATIVE_PATH), "utf8");
|
||||
const containerdHelpers = readFileSync(rootPath(GC_REMOTE_CONTAINERD_RELATIVE_PATH), "utf8");
|
||||
const pvcHelpers = readFileSync(rootPath(GC_REMOTE_PVC_RELATIVE_PATH), "utf8");
|
||||
const growthHelpers = readFileSync(rootPath(GC_REMOTE_GROWTH_RELATIVE_PATH), "utf8");
|
||||
const registryHelpers = readFileSync(rootPath(GC_REMOTE_REGISTRY_RELATIVE_PATH), "utf8");
|
||||
return template
|
||||
.replace(GC_REMOTE_WEB_OBSERVE_PLACEHOLDER, webObserveHelpers.trimEnd())
|
||||
.replace(GC_REMOTE_CONTAINERD_PLACEHOLDER, containerdHelpers.trimEnd())
|
||||
.replace(GC_REMOTE_PVC_PLACEHOLDER, pvcHelpers.trimEnd())
|
||||
.replace(GC_REMOTE_GROWTH_PLACEHOLDER, growthHelpers.trimEnd())
|
||||
.replace(GC_REMOTE_REGISTRY_PLACEHOLDER, registryHelpers.trimEnd())
|
||||
.replace(GC_REMOTE_RUNNER_CONFIG_PLACEHOLDER, configBase64);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user