Skip to content

Commit 71f707b

Browse files
authored
Delete jobs on immutable conflict (#61)
1 parent 0da2ba0 commit 71f707b

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

  • src/controllers/restatecluster/reconcilers

src/controllers/restatecluster/reconcilers/compute.rs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ async fn check_pia(
713713
namespace
714714
);
715715

716-
let created = job_api
716+
let created = match job_api
717717
.patch(
718718
name,
719719
&params,
@@ -747,7 +747,28 @@ async fn check_pia(
747747
status: None,
748748
}),
749749
)
750-
.await?;
750+
.await
751+
{
752+
Ok(created) => created,
753+
Err(kube::Error::Api(kube::error::ErrorResponse {
754+
code: 422,
755+
reason,
756+
message,
757+
..
758+
})) if reason == "Invalid" && message.contains("field is immutable") => {
759+
// when tolerations change, the existing job becomes invalid
760+
delete_job(namespace, job_api, name).await?;
761+
762+
return Err(Error::NotReady {
763+
reason: "PodIdentityAssociationCanaryPending".into(),
764+
message: "Canary Job has not yet succeeded; recreated Job after tolerations change"
765+
.into(),
766+
// job watch will cover this
767+
requeue_after: None,
768+
});
769+
}
770+
Err(err) => return Err(err.into()),
771+
};
751772

752773
if let Some(conditions) = created.status.and_then(|s| s.conditions) {
753774
for condition in conditions {

0 commit comments

Comments
 (0)