Skip to content

Commit

Permalink
feat: provide --client-env argument
Browse files Browse the repository at this point in the history
The `deploy` command now provides this argument so that the client can also be supplied environment
variables, which we will mainly use to control logging options.
  • Loading branch information
jacderida committed Mar 4, 2025
1 parent 02d9ad2 commit 76297d8
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Environment="EVM_NETWORK=arbitrum-sepolia"
{% elif evm_network_type == "evm-arbitrum-one" %}
Environment="EVM_NETWORK=arbitrum-one"
{% endif %}
{% if client_env_variables is defined %}
Environment="{{ client_env_variables }}"
{% endif %}
User=ant{{ count }}
{% if testnet_name.startswith('PROD-') %}
ExecStart=/home/ant{{ count }}/upload-random-data.sh
Expand Down
7 changes: 7 additions & 0 deletions src/ansible/extra_vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ pub fn build_node_extra_vars_doc(
extra_vars.add_env_variable_list("node_env_variables", env_vars.clone());
}

if let Some(client_env_vars) = &options.client_env_variables {
extra_vars.add_env_variable_list("client_env_variables", client_env_vars.clone());
}

if let Some((logstash_stack_name, logstash_hosts)) = &options.logstash_details {
extra_vars.add_variable("logstash_stack_name", logstash_stack_name);
extra_vars.add_list_variable(
Expand Down Expand Up @@ -475,6 +479,9 @@ pub fn build_uploaders_extra_vars_doc(
if let Some(network_id) = options.network_id {
extra_vars.add_variable("network_id", &network_id.to_string());
}
if let Some(client_env_variables) = &options.client_env_variables {
extra_vars.add_env_variable_list("client_env_variables", client_env_variables.clone());
}

extra_vars.add_variable("enable_telegraf", &options.enable_telegraf.to_string());

Expand Down
5 changes: 4 additions & 1 deletion src/ansible/provisioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct ProvisionOptions {
pub ant_version: Option<String>,
pub binary_option: BinaryOption,
pub chunk_size: Option<u64>,
pub client_env_variables: Option<Vec<(String, String)>>,
pub downloaders_count: u16,
pub enable_telegraf: bool,
pub evm_data_payments_address: Option<String>,
Expand Down Expand Up @@ -261,6 +262,7 @@ impl From<BootstrapOptions> for ProvisionOptions {
rewards_address: bootstrap_options.rewards_address,
token_amount: None,
uploaders_count: None,
client_env_variables: None,
}
}
}
Expand All @@ -273,7 +275,7 @@ impl From<DeployOptions> for ProvisionOptions {
chunk_size: deploy_options.chunk_size,
downloaders_count: deploy_options.downloaders_count,
enable_telegraf: deploy_options.enable_telegraf,
node_env_variables: deploy_options.env_variables,
node_env_variables: deploy_options.node_env_variables,
evm_data_payments_address: deploy_options.evm_data_payments_address,
evm_network: deploy_options.evm_network,
evm_payment_token_address: deploy_options.evm_payment_token_address,
Expand All @@ -296,6 +298,7 @@ impl From<DeployOptions> for ProvisionOptions {
rewards_address: deploy_options.rewards_address,
token_amount: deploy_options.initial_tokens,
uploaders_count: Some(deploy_options.uploaders_count),
client_env_variables: deploy_options.client_env_variables,
}
}
}
Expand Down
14 changes: 8 additions & 6 deletions src/cmd/deployments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ pub async fn handle_deploy(
antnode_version: Option<String>,
branch: Option<String>,
chunk_size: Option<u64>,
client_env_variables: Option<Vec<(String, String)>>,
disable_telegraf: bool,
downloaders_count: u16,
env_variables: Option<Vec<(String, String)>>,
environment_type: crate::EnvironmentType,
evm_data_payments_address: Option<String>,
evm_network_type: EvmNetwork,
Expand All @@ -225,6 +225,7 @@ pub async fn handle_deploy(
network_id: Option<u8>,
network_contacts_file_name: Option<String>,
node_count: Option<u16>,
node_env_variables: Option<Vec<(String, String)>>,
node_vm_count: Option<u16>,
node_vm_size: Option<String>,
node_volume_size: Option<u16>,
Expand Down Expand Up @@ -339,16 +340,16 @@ pub async fn handle_deploy(
let deploy_options = DeployOptions {
binary_option: binary_option.clone(),
chunk_size,
client_env_variables,
current_inventory: inventory,
downloaders_count,
env_variables,
enable_telegraf: !disable_telegraf,
environment_type: environment_type.clone(),
evm_data_payments_address,
evm_network: evm_network_type,
evm_node_vm_size,
evm_payment_token_address,
evm_rpc_url,
funding_wallet_secret_key,
full_cone_nat_gateway_vm_size,
full_cone_private_node_count,
full_cone_private_node_vm_count,
Expand All @@ -357,6 +358,7 @@ pub async fn handle_deploy(
full_cone_private_node_count,
))
}),
funding_wallet_secret_key,
genesis_node_volume_size: genesis_node_volume_size
.or_else(|| Some(calculate_size_per_attached_volume(1))),
initial_gas,
Expand All @@ -369,6 +371,7 @@ pub async fn handle_deploy(
name: name.clone(),
network_id,
node_count,
node_env_variables,
node_vm_count,
node_vm_size,
node_volume_size: node_volume_size
Expand All @@ -382,6 +385,8 @@ pub async fn handle_deploy(
peer_cache_node_vm_size,
peer_cache_node_volume_size: peer_cache_node_volume_size
.or_else(|| Some(calculate_size_per_attached_volume(peer_cache_node_count))),
public_rpc,
rewards_address,
symmetric_nat_gateway_vm_size,
symmetric_private_node_count,
symmetric_private_node_vm_count,
Expand All @@ -390,12 +395,9 @@ pub async fn handle_deploy(
symmetric_private_node_count,
))
}),
public_rpc,
rewards_address,
uploader_vm_count,
uploader_vm_size,
uploaders_count,
enable_telegraf: !disable_telegraf,
};

if to_genesis {
Expand Down
8 changes: 8 additions & 0 deletions src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,14 @@ pub enum Commands {
/// Example: --node-env SN_LOG=all,RUST_LOG=libp2p=debug
#[clap(name = "node-env", long, use_value_delimiter = true, value_parser = parse_environment_variables, verbatim_doc_comment)]
node_env_variables: Option<Vec<(String, String)>>,
/// Provide environment variables for the antnode RPC client.
///
/// This is useful to set the client's log levels. Each variable should be comma
/// separated without any space.
///
/// Example: --client-env CLIENT_LOG=all,RUST_LOG=debug
#[clap(name = "client-env", long, use_value_delimiter = true, value_parser = parse_environment_variables, verbatim_doc_comment)]
client_env_variables: Option<Vec<(String, String)>>,
/// The type of deployment.
///
/// Possible values are 'development', 'production' or 'staging'. The value used will
Expand Down
3 changes: 2 additions & 1 deletion src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ use std::{net::SocketAddr, path::PathBuf, time::Duration};
pub struct DeployOptions {
pub binary_option: BinaryOption,
pub chunk_size: Option<u64>,
pub client_env_variables: Option<Vec<(String, String)>>,
pub current_inventory: DeploymentInventory,
pub downloaders_count: u16,
pub enable_telegraf: bool,
pub environment_type: EnvironmentType,
pub env_variables: Option<Vec<(String, String)>>,
pub evm_data_payments_address: Option<String>,
pub evm_network: EvmNetwork,
pub evm_node_vm_size: Option<String>,
Expand All @@ -48,6 +48,7 @@ pub struct DeployOptions {
pub name: String,
pub network_id: Option<u8>,
pub node_count: u16,
pub node_env_variables: Option<Vec<(String, String)>>,
pub node_vm_count: Option<u16>,
pub node_vm_size: Option<String>,
pub node_volume_size: Option<u16>,
Expand Down
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ async fn main() -> Result<()> {
antnode_version,
branch,
chunk_size,
client_env_variables,
downloaders_count,
disable_telegraf,
environment_type,
Expand Down Expand Up @@ -182,9 +183,9 @@ async fn main() -> Result<()> {
antnode_version,
branch,
chunk_size,
client_env_variables,
disable_telegraf,
downloaders_count,
node_env_variables,
environment_type,
evm_data_payments_address,
evm_network_type,
Expand All @@ -209,6 +210,7 @@ async fn main() -> Result<()> {
network_id,
network_contacts_file_name,
node_count,
node_env_variables,
node_vm_count,
node_vm_size,
node_volume_size,
Expand Down
6 changes: 4 additions & 2 deletions src/upscale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ impl TestnetDeployer {
let mut provision_options = ProvisionOptions {
binary_option: options.current_inventory.binary_option.clone(),
chunk_size: None,
client_env_variables: None,
downloaders_count: 0,
enable_telegraf: true,
node_env_variables: None,
evm_network: options
.current_inventory
.environment_details
Expand Down Expand Up @@ -213,6 +213,7 @@ impl TestnetDeployer {
name: options.current_inventory.name.clone(),
network_id: options.current_inventory.environment_details.network_id,
node_count: desired_node_count,
node_env_variables: None,
max_archived_log_files: options.max_archived_log_files,
max_log_files: options.max_log_files,
output_inventory_dir_path: self
Expand Down Expand Up @@ -479,9 +480,9 @@ impl TestnetDeployer {
let provision_options = ProvisionOptions {
binary_option: options.current_inventory.binary_option.clone(),
chunk_size: None,
client_env_variables: None,
downloaders_count: 0,
enable_telegraf: true,
node_env_variables: None,
evm_data_payments_address: options
.current_inventory
.environment_details
Expand Down Expand Up @@ -510,6 +511,7 @@ impl TestnetDeployer {
name: options.current_inventory.name.clone(),
network_id: options.current_inventory.environment_details.network_id,
node_count: 0,
node_env_variables: None,
max_archived_log_files: options.max_archived_log_files,
max_log_files: options.max_log_files,
output_inventory_dir_path: self
Expand Down

0 comments on commit 76297d8

Please sign in to comment.