Skip to content

Commit

Permalink
Wait for extract-balena-ca after changing config.json
Browse files Browse the repository at this point in the history
When config.json changes on balena join, the
extract-balena-ca.service runs automatically. We should
wait for this service to finish so that the ca is
refreshed before reading balenaRootCA

Change-type: patch
  • Loading branch information
jaomaloy committed Nov 30, 2023
1 parent e3d3c11 commit dc56b09
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::path::{Path, PathBuf};
use crate::systemd::service_exists;

pub const SUPERVISOR_SERVICE: &str = "balena-supervisor.service";
pub const EXTRACT_BALENA_CA_SERVICE: &str = "extract-balena-ca.service";

const CONFIG_ROUTE: &str = "/os/v1/config";
const OS_CONFIG_PATH: &str = "/etc/os-config.json";
Expand Down
5 changes: 4 additions & 1 deletion src/join.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::fs;
use std::path::Path;

use crate::args::{Args, SUPERVISOR_SERVICE};
use crate::args::{Args, EXTRACT_BALENA_CA_SERVICE, SUPERVISOR_SERVICE};
use crate::config_json::{
get_api_endpoint, get_root_certificate, merge_config_json, read_config_json, write_config_json,
ConfigMap,
Expand Down Expand Up @@ -93,6 +93,9 @@ fn reconfigure_core(
) -> Result<()> {
if should_write_config_json {
write_config_json(&args.config_json_path, config_json)?;

// wait for extract-balena-ca service to finish restarting
systemd::start_service(EXTRACT_BALENA_CA_SERVICE)?;
}

if has_service_config_changes {
Expand Down

0 comments on commit dc56b09

Please sign in to comment.