Skip to content

Commit

Permalink
fix(vine): skip updating immutable resources
Browse files Browse the repository at this point in the history
  • Loading branch information
HoKim98 committed Dec 16, 2024
1 parent c617060 commit 2eee36f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions crates/dash/provider/src/client/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,20 @@ 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<DynamicObject> = match caps.scope {
Scope::Cluster => Api::all_with(self.kube.clone(), &ar),
Scope::Namespaced => Api::namespaced_with(self.kube.clone(), namespace, &ar),
};
apis.push(Template {
api,
immutable,
name: name.clone(),
template,
});
Expand All @@ -289,6 +296,7 @@ impl TaskActorJobClient {
#[derive(Debug)]
struct Template {
api: Api<DynamicObject>,
immutable: bool,
name: String,
template: DynamicObject,
}
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions templates/vine/templates/session/user-session.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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
---
Expand Down Expand Up @@ -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
---
Expand Down

0 comments on commit 2eee36f

Please sign in to comment.