Skip to content

Commit

Permalink
Merge pull request solana-labs#31 from gregcusack/k8s-cluster-officia…
Browse files Browse the repository at this point in the history
…l-debug-genesis

pull genesis from bootstrap onto validators
  • Loading branch information
Greg Cusack authored Oct 18, 2023
2 parents d26c298 + b7691b7 commit e90159b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 33 deletions.
9 changes: 1 addition & 8 deletions k8s-cluster/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,17 +381,10 @@ impl Genesis {
}

// solana-genesis creates a genesis.tar.bz2 but if we need to create snapshots, these
// are not included in the genesis.tar.bz2. So we package everything including genesis,
// are not included in the genesis.tar.bz2. So we package everything including genesis.tar.bz2,
// snapshots, etc into genesis-package.tar.bz2 and we use this as our genesis in the
// bootstrap validator
pub fn package_up(&mut self) -> Result<(), Box<dyn Error>> {
// delete the genesis.tar.bz2 since its contents will be included in the
// tar we're about to create
let genesis_path = LEDGER_DIR.join("genesis.tar.bz2");
if std::fs::metadata(&genesis_path).is_ok() {
std::fs::remove_file(&genesis_path)?;
}

info!("Packaging genesis");
let folder_to_tar = LEDGER_DIR.join("");
let tar_bz2_file = File::create(SOLANA_ROOT.join("config-k8s/genesis-package.tar.bz2"))?;
Expand Down
47 changes: 26 additions & 21 deletions k8s-cluster/src/kubernetes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ impl<'a> Kubernetes<'a> {
flags.push("--enable-rpc-transaction-history".to_string());
flags.push("--enable-extended-tx-metadata-storage".to_string());
}
if self.validator_config.enable_full_rpc {
flags.push("--enable-rpc-transaction-history".to_string());
flags.push("--enable-extended-tx-metadata-storage".to_string());
}

if let Some(slot) = self.validator_config.wait_for_supermajority {
flags.push("--wait-for-supermajority".to_string());
Expand Down Expand Up @@ -277,6 +273,8 @@ impl<'a> Kubernetes<'a> {
.await
}

// mount genesis in bootstrap. validators will pull
// genesis from bootstrap
#[allow(clippy::too_many_arguments)]
async fn create_replicas_set(
&self,
Expand All @@ -291,25 +289,32 @@ impl<'a> Kubernetes<'a> {
accounts_volume: Volume,
accounts_volume_mount: VolumeMount,
) -> Result<ReplicaSet, Box<dyn Error>> {
let Some(config_map_name) = config_map_name else {
return Err(boxed_error!("config_map_name is None!"));
};
let mut volumes = vec![accounts_volume];
let mut volume_mounts = vec![accounts_volume_mount];
if app_name == "bootstrap-validator" {
info!("bootstrap create replicaset");
let Some(config_map_name) = config_map_name else {
return Err(boxed_error!("config_map_name is None!"));
};

let genesis_volume = Volume {
name: "genesis-config-volume".into(),
config_map: Some(ConfigMapVolumeSource {
name: Some(config_map_name.clone()),
let genesis_volume = Volume {
name: "genesis-config-volume".into(),
config_map: Some(ConfigMapVolumeSource {
name: Some(config_map_name.clone()),
..Default::default()
}),
..Default::default()
}),
..Default::default()
};
};

let genesis_volume_mount = VolumeMount {
name: "genesis-config-volume".to_string(),
mount_path: "/home/solana/genesis".to_string(),
..Default::default()
};
let genesis_volume_mount = VolumeMount {
name: "genesis-config-volume".to_string(),
mount_path: "/home/solana/genesis".to_string(),
..Default::default()
};

volumes.push(genesis_volume);
volume_mounts.push(genesis_volume_mount);
}
// Define the pod spec
let pod_spec = PodTemplateSpec {
metadata: Some(ObjectMeta {
Expand All @@ -323,10 +328,10 @@ impl<'a> Kubernetes<'a> {
image_pull_policy: Some("Always".to_string()),
env: Some(env_vars),
command: Some(command.to_owned()),
volume_mounts: Some(vec![genesis_volume_mount, accounts_volume_mount]),
volume_mounts: Some(volume_mounts),
..Default::default()
}],
volumes: Some(vec![genesis_volume, accounts_volume]),
volumes: Some(volumes),
security_context: Some(PodSecurityContext {
run_as_user: Some(1000),
run_as_group: Some(1000),
Expand Down
2 changes: 0 additions & 2 deletions k8s-cluster/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,6 @@ async fn main() {
}
}

// std::process::exit(-1);

// Begin Kubernetes Setup and Deployment
let config_map = match kub_controller.create_genesis_config_map().await {
Ok(config_map) => {
Expand Down
5 changes: 3 additions & 2 deletions k8s-cluster/src/scripts/decode-accounts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ for i in "${!SECRET_FILES[@]}"; do
done

mkdir -p /home/solana/logs
# mkdir -p /home/solana/ledger
tar -xvf /home/solana/genesis/genesis-package.tar.bz2 -C /home/solana/
if [ "$validator_type" == "bootstrap" ]; then
tar -xvf /home/solana/genesis/genesis-package.tar.bz2 -C /home/solana/
fi

0 comments on commit e90159b

Please sign in to comment.