Skip to content

Better code for pod identity management [was: Schedule pods without ids] #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Fixed
- Bugfix: when scheduling a pod, `GroupAntiAffinityStrategy` should not skip nodes that are mapped by other pods from different role+group. ([#222])

### Added
- `identity.rs` a new module split out of `scheduler.rs` that bundles code for pod and node id management.
- `identity::PodIdentityFactory` trait and one implementation called `identity::LabeledPodIdentityFactory`

### Removed
- BREAKING: `scheduler::PodToNodeMapping::from` ([#222])

[#222]: https://github.com/stackabletech/operator-rs/pull/222

## [0.2.2] - 2021-09-21


Expand Down
47 changes: 39 additions & 8 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::name_utils;
use crate::product_config_utils;
use crate::{name_utils, scheduler};
use std::collections::HashSet;
use std::collections::{BTreeMap, HashSet};

#[derive(Debug, thiserror::Error)]
pub enum Error {
Expand Down Expand Up @@ -82,12 +82,6 @@ pub enum Error {
)]
RequiredFileMissing { search_path: Vec<String> },

#[error("Scheduler reported error: {source}")]
SchedulerError {
#[from]
source: scheduler::Error,
},

#[error("ProductConfig Framework reported error: {source}")]
ProductConfigError {
#[from]
Expand All @@ -102,6 +96,43 @@ pub enum Error {

#[error("Error converting CRD byte array to UTF-8")]
FromUtf8Error(#[from] std::string::FromUtf8Error),
#[error(
"Not enough nodes [{number_of_nodes}] available to schedule pods [{number_of_pods}]. Unscheduled pods: {unscheduled_pods:?}."
)]
NotEnoughNodesAvailable {
number_of_nodes: usize,
number_of_pods: usize,
unscheduled_pods: Vec<String>,
},

#[error(
"PodIdentity could not be parsed: [{pod_id}]. This should not happen. Please open a ticket."
)]
PodIdentityNotParseable { pod_id: String },

#[error("Cannot build PodIdentity from Pod without labels. Missing labels: {0:?}")]
PodWithoutLabelsNotSupported(Vec<String>),

#[error("Cannot build NodeIdentity from node without name.")]
NodeWithoutNameNotSupported,

#[error("Cannot construct PodIdentity from empty id field.")]
PodIdentityFieldEmpty,

#[error(
"Pod identity field [{field}] with value [{value}] does not match the expected value [{expected}]"
)]
UnexpectedPodIdentityField {
field: String,
value: String,
expected: String,
},

#[error("Forbidden separator [{separator}] found in pod identity fields [{invalid_fields:?}]")]
PodIdentityFieldWithInvalidSeparator {
separator: String,
invalid_fields: BTreeMap<String, String>,
},
}

pub type OperatorResult<T> = std::result::Result<T, Error>;
Loading