Skip to content

Commit

Permalink
tolerations in targetless, but no default
Browse files Browse the repository at this point in the history
  • Loading branch information
meowjesty committed Jan 24, 2025
1 parent dbf3080 commit 0e7d32c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 4 additions & 2 deletions mirrord/config/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,10 @@ pub struct AgentConfig {

/// ### agent.tolerations {#agent-tolerations}
///
/// Set pod tolerations. (not with ephemeral agents)
/// Default is
/// Set pod tolerations. (not with ephemeral agents).
///
/// Defaults to `operator: Exists`.
///
/// ```json
/// [
/// {
Expand Down
13 changes: 8 additions & 5 deletions mirrord/kube/src/api/container/pod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use crate::api::{
runtime::RuntimeData,
};

/// The `targetless` agent variant is created by this, see its [`PodVariant::as_update`].
pub struct PodVariant<'c> {
agent: &'c AgentConfig,
command_line: Vec<String>,
Expand Down Expand Up @@ -67,8 +68,6 @@ impl ContainerVariant for PodVariant<'_> {
..
} = self;

let tolerations = agent.tolerations.as_ref().unwrap_or(&DEFAULT_TOLERATIONS);

let resources = agent.resources.clone().unwrap_or_else(|| {
serde_json::from_value(serde_json::json!({
"requests":
Expand Down Expand Up @@ -124,7 +123,7 @@ impl ContainerVariant for PodVariant<'_> {
spec: Some(PodSpec {
restart_policy: Some("Never".to_string()),
image_pull_secrets,
tolerations: Some(tolerations.clone()),
tolerations: agent.tolerations.clone(),
node_selector: Some(node_selector),
service_account_name: agent.service_account.clone(),
containers: vec![Container {
Expand All @@ -148,6 +147,10 @@ impl ContainerVariant for PodVariant<'_> {
}
}

/// The `targeted` agent variant is created by this.
///
/// It builds on top of [`PodVariant`], merging spec, etc from there. See
/// [`PodTargetedVariant::as_update`].
pub struct PodTargetedVariant<'c> {
inner: PodVariant<'c>,
runtime_data: &'c RuntimeData,
Expand Down Expand Up @@ -195,7 +198,7 @@ impl ContainerVariant for PodTargetedVariant<'_> {
let agent = self.agent_config();
let params = self.params();

let tolerations = agent.tolerations.clone();
let tolerations = agent.tolerations.as_ref().unwrap_or(&DEFAULT_TOLERATIONS);

let env = self.runtime_data.mesh.map(|mesh_vendor| {
let mut env = vec![EnvVar {
Expand All @@ -216,7 +219,7 @@ impl ContainerVariant for PodTargetedVariant<'_> {
let update = Pod {
spec: Some(PodSpec {
restart_policy: Some("Never".to_string()),
tolerations,
tolerations: Some(tolerations.clone()),
host_pid: Some(true),
node_name: Some(runtime_data.node_name.clone()),
volumes: Some(vec![
Expand Down

0 comments on commit 0e7d32c

Please sign in to comment.