Skip to content

Commit

Permalink
Handle the case of a missing app ID
Browse files Browse the repository at this point in the history
This may happen if the reconciliation fails early on.
  • Loading branch information
ctron committed May 12, 2021
1 parent cb565fd commit 610564e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ttn-operator/src/controller/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,15 @@ impl<'a> Reconciler for ApplicationReconciler<'a> {
.as_ref()
.unwrap_or(&ctx.app.metadata.name)
.clone();
let mut status = if let Some(status) = ctx.status {
Controller::ensure_stable_app_id(&ctx.app.metadata, &ctx.spec, &app_id)?;
let mut status = if let Some(mut status) = ctx.status {
match status.app_id {
Some(ref app_id) => {
Controller::ensure_stable_app_id(&ctx.app.metadata, &ctx.spec, &app_id)?
}
None => {
status.app_id = Some(app_id.clone());
}
}
status
} else {
log::debug!("Missing status section, adding...");
Expand All @@ -110,6 +117,7 @@ impl<'a> Reconciler for ApplicationReconciler<'a> {
};
ctx.app.set_section(status.clone())?;
status
// FIXME: return and re-schedule here when we have the work queue
};

// ensure the app configuration
Expand Down

0 comments on commit 610564e

Please sign in to comment.