Skip to content

Commit

Permalink
set correct rpc address (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregcusack authored Jul 30, 2024
1 parent ae44093 commit 1ea8a2d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
22 changes: 15 additions & 7 deletions src/kubernetes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ impl<'a> Kubernetes<'a> {
if self.metrics.is_some() {
env_vars.push(self.get_metrics_env_var_secret())
}
env_vars.push(self.set_namespace_environment_variable());
env_vars.append(&mut self.set_load_balancer_environment_variables());

let accounts_volume = Some(vec![Volume {
name: "bootstrap-accounts-volume".into(),
Expand Down Expand Up @@ -473,13 +475,16 @@ impl<'a> Kubernetes<'a> {
}
}

fn set_namespace_environment_variable(&self) -> EnvVar {
k8s_helpers::create_environment_variable(
"NAMESPACE".to_string(),
None,
Some("metadata.namespace".to_string()),
)
}

fn set_non_bootstrap_environment_variables(&self) -> Vec<EnvVar> {
vec![
k8s_helpers::create_environment_variable(
"NAMESPACE".to_string(),
None,
Some("metadata.namespace".to_string()),
),
k8s_helpers::create_environment_variable(
"BOOTSTRAP_RPC_ADDRESS".to_string(),
Some("bootstrap-validator-service.$(NAMESPACE).svc.cluster.local:8899".to_string()),
Expand Down Expand Up @@ -567,10 +572,11 @@ impl<'a> Kubernetes<'a> {
label_selector: &BTreeMap<String, String>,
validator_index: usize,
) -> Result<ReplicaSet, Box<dyn Error>> {
let mut env_vars = self.set_non_bootstrap_environment_variables();
let mut env_vars = vec![self.set_namespace_environment_variable()];
if self.metrics.is_some() {
env_vars.push(self.get_metrics_env_var_secret())
}
env_vars.append(&mut self.set_non_bootstrap_environment_variables());
env_vars.append(&mut self.set_load_balancer_environment_variables());

let accounts_volume = Some(vec![Volume {
Expand Down Expand Up @@ -643,6 +649,7 @@ impl<'a> Kubernetes<'a> {
}),
..Default::default()
}];
env_vars.push(self.set_namespace_environment_variable());
env_vars.append(&mut self.set_non_bootstrap_environment_variables());
env_vars.append(&mut self.set_load_balancer_environment_variables());

Expand Down Expand Up @@ -707,10 +714,11 @@ impl<'a> Kubernetes<'a> {
label_selector: &BTreeMap<String, String>,
client_index: usize,
) -> Result<ReplicaSet, Box<dyn Error>> {
let mut env_vars = self.set_non_bootstrap_environment_variables();
let mut env_vars = vec![self.set_namespace_environment_variable()];
if self.metrics.is_some() {
env_vars.push(self.get_metrics_env_var_secret())
}
env_vars.append(&mut self.set_non_bootstrap_environment_variables());
env_vars.append(&mut self.set_load_balancer_environment_variables());

let accounts_volume = Some(vec![Volume {
Expand Down
14 changes: 9 additions & 5 deletions src/startup_scripts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ for arg in "${args[@]}"; do
echo "$arg"
done
solana config set -u "http://$LOAD_BALANCER_RPC_ADDRESS"
pid=
kill_node() {
# Note: do not echo anything from this function to ensure $pid is actually
Expand Down Expand Up @@ -510,6 +512,8 @@ RETRY_DELAY=5
# Load balancer RPC URL
LOAD_BALANCER_RPC_URL="http://$LOAD_BALANCER_RPC_ADDRESS"
solana config set -u $LOAD_BALANCER_RPC_URL
# Identity file
IDENTITY_FILE=$identity
Expand Down Expand Up @@ -560,12 +564,12 @@ run_solana_command() {
}
setup_validator() {
if ! run_solana_command "solana -u $LOAD_BALANCER_RPC_URL airdrop $node_sol $IDENTITY_FILE" "Airdrop"; then
if ! run_solana_command "solana airdrop $node_sol $IDENTITY_FILE" "Airdrop"; then
echo "Aidrop command failed."
exit 1
fi
if ! run_solana_command "solana -u $LOAD_BALANCER_RPC_URL create-vote-account --allow-unsafe-authorized-withdrawer validator-accounts/vote.json $IDENTITY_FILE $IDENTITY_FILE -k $IDENTITY_FILE --commission $commission" "Create Vote Account"; then
if ! run_solana_command "solana create-vote-account --allow-unsafe-authorized-withdrawer validator-accounts/vote.json $IDENTITY_FILE $IDENTITY_FILE -k $IDENTITY_FILE --commission $commission" "Create Vote Account"; then
if $vote_account_already_exists; then
echo "Vote account already exists. Skipping remaining commands."
else
Expand All @@ -579,7 +583,7 @@ setup_validator() {
run_delegate_stake() {
echo "stake sol for account: $stake_sol"
if ! run_solana_command "solana -u $LOAD_BALANCER_RPC_URL create-stake-account validator-accounts/stake.json $stake_sol -k $IDENTITY_FILE" "Create Stake Account"; then
if ! run_solana_command "solana create-stake-account validator-accounts/stake.json $stake_sol -k $IDENTITY_FILE" "Create Stake Account"; then
if $stake_account_already_exists; then
echo "Stake account already exists. Skipping remaining commands."
else
Expand All @@ -591,14 +595,14 @@ run_delegate_stake() {
if [ "$stake_account_already_exists" != true ]; then
echo "stake account does not exist. so lets deligate"
if ! run_solana_command "solana -u $LOAD_BALANCER_RPC_URL delegate-stake validator-accounts/stake.json validator-accounts/vote.json --force -k $IDENTITY_FILE" "Delegate Stake"; then
if ! run_solana_command "solana delegate-stake validator-accounts/stake.json validator-accounts/vote.json --force -k $IDENTITY_FILE" "Delegate Stake"; then
echo "Delegate stake command failed."
exit 1
fi
echo "delegated stake"
fi
solana --url $LOAD_BALANCER_RPC_URL --keypair $IDENTITY_FILE stake-account validator-accounts/stake.json
solana --keypair $IDENTITY_FILE stake-account validator-accounts/stake.json
}
echo "get airdrop and create vote account"
Expand Down

0 comments on commit 1ea8a2d

Please sign in to comment.