From 2eee36f8c26539b98dab6e7d8eea46eaa307cf5b Mon Sep 17 00:00:00 2001 From: Ho Kim Date: Mon, 16 Dec 2024 09:01:03 +0000 Subject: [PATCH] fix(vine): skip updating immutable resources --- crates/dash/provider/src/client/job.rs | 13 +++++++++++++ .../vine/templates/session/user-session.yaml.j2 | 2 ++ 2 files changed, 15 insertions(+) diff --git a/crates/dash/provider/src/client/job.rs b/crates/dash/provider/src/client/job.rs index 00a9f164..beb40286 100644 --- a/crates/dash/provider/src/client/job.rs +++ b/crates/dash/provider/src/client/job.rs @@ -271,6 +271,12 @@ impl TaskActorJobClient { ), }; + // Detect the immutable resources + let immutable = matches!( + (ar.group.as_str(), ar.kind.as_str()), + ("", "PersistentVolume") | ("storage.k8s.io", "StorageClass") + ); + // Use the discovered kind in an Api, and Controller with the ApiResource as its DynamicType let api: Api = match caps.scope { Scope::Cluster => Api::all_with(self.kube.clone(), &ar), @@ -278,6 +284,7 @@ impl TaskActorJobClient { }; apis.push(Template { api, + immutable, name: name.clone(), template, }); @@ -289,6 +296,7 @@ impl TaskActorJobClient { #[derive(Debug)] struct Template { api: Api, + immutable: bool, name: String, template: DynamicObject, } @@ -304,6 +312,11 @@ impl From<&Template> for TemplateRef { #[instrument(level = Level::INFO, skip(template), fields(template.name = %template.name), err(Display))] async fn try_create(template: Template, exists: bool) -> Result<()> { if exists { + // Skip applying to immutable resources + if template.immutable { + return Ok(()); + } + let pp = PatchParams { field_manager: Some(crate::NAME.into()), force: true, diff --git a/templates/vine/templates/session/user-session.yaml.j2 b/templates/vine/templates/session/user-session.yaml.j2 index e400142f..b78a9321 100644 --- a/templates/vine/templates/session/user-session.yaml.j2 +++ b/templates/vine/templates/session/user-session.yaml.j2 @@ -719,6 +719,7 @@ spec: capacity: {{ spec.boxQuota.storage.requests | json_encode() | safe }} hostPath: path: "/opt/vine/sessions/{{ metadata.namespace }}" + type: DirectoryOrCreate persistentVolumeReclaimPolicy: Recycle storageClassName: manual --- @@ -757,6 +758,7 @@ spec: capacity: {{ spec.boxQuota.storage.requests | json_encode() | safe }} hostPath: path: "/opt/vine/sessions/_shared" + type: DirectoryOrCreate persistentVolumeReclaimPolicy: Retain storageClassName: manual ---