Skip to content
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

feat(upgrade-job): add support for loki-stack helm chart upgrade #396

Merged
merged 9 commits into from
Jan 9, 2024
3 changes: 3 additions & 0 deletions k8s/upgrade/src/bin/upgrade-job/common/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ pub(crate) const TWO_DOT_FOUR: &str = "2.4.0";

/// Version value for the earliest possible 2.5 release.
pub(crate) const TWO_DOT_FIVE: &str = "2.5.0";

/// Version value for the earliest possible 2.6 release.
pub(crate) const TWO_DOT_SIX: &str = "2.6.0";
95 changes: 95 additions & 0 deletions k8s/upgrade/src/bin/upgrade-job/common/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use crate::{
UMBRELLA_CHART_UPGRADE_DOCS_URL,
},
events::event_recorder::EventNote,
helm::chart::PromtailConfigClient,
};
use k8s_openapi::api::core::v1::Container;
use snafu::Snafu;
use std::path::PathBuf;
use url::Url;
Expand Down Expand Up @@ -426,6 +428,60 @@ pub(crate) enum Error {
note: EventNote,
},

/// Error in serializing a helm::chart::PromtailConfigClient to a JSON string.
#[snafu(display(
"Failed to serialize .loki-stack.promtail.config.client {:?}: {}",
object,
source
))]
SerializePromtailConfigClientToJson {
source: serde_json::Error,
object: PromtailConfigClient,
},

/// Error in serializing a k8s_openapi::api::core::v1::Container to a JSON string.
#[snafu(display(
"Failed to serialize .loki-stack.promtail.initContainer {:?}: {}",
object,
source
))]
SerializePromtailInitContainerToJson {
source: serde_json::Error,
object: Container,
},

/// Error in deserializing a promtail helm chart's deprecated extraClientConfig to a
/// serde_json::Value.
#[snafu(display(
"Failed to deserialize .loki-stack.promtail.config.snippets.extraClientConfig to a serde_json::Value {}: {}",
config,
source
))]
DeserializePromtailExtraConfig {
source: serde_yaml::Error,
config: String,
},

/// Error in serializing a promtail helm chart's deprecated extraClientConfig, in a
/// serde_json::Value, to JSON.
#[snafu(display("Failed to serialize to JSON {:?}: {}", config, source))]
SerializePromtailExtraConfigToJson {
source: serde_json::Error,
config: serde_json::Value,
},

/// Error in serializing the deprecated config.snippets.extraClientConfig from the promtail
/// helm chart v3.11.0.
#[snafu(display(
"Failed to serialize object to a serde_json::Value {}: {}",
object,
source
))]
SerializePromtailExtraClientConfigToJson {
source: serde_json::Error,
object: String,
},

/// Error for when there are too many io-engine Pods in one single node;
#[snafu(display("Too many io-engine Pods in Node '{}'", node_name))]
TooManyIoEnginePods { node_name: String },
Expand Down Expand Up @@ -601,6 +657,45 @@ pub(crate) enum Error {
std_err: String,
},

/// Error for when the yq command to delete an object path returns an error.
#[snafu(display(
"`yq` delete-object-command returned an error,\ncommand: {},\nargs: {:?},\nstd_err: {}",
command,
args,
std_err,
))]
YqDeleteObjectCommand {
command: String,
args: Vec<String>,
std_err: String,
},

/// Error for when the yq command to append to an array returns an error.
#[snafu(display(
"`yq` append-to-array-command returned an error,\ncommand: {},\nargs: {:?},\nstd_err: {}",
command,
args,
std_err,
))]
YqAppendToArrayCommand {
command: String,
args: Vec<String>,
std_err: String,
},

/// Error for when the yq command to append to an object returns an error.
#[snafu(display(
"`yq` append-to-object-command returned an error,\ncommand: {},\nargs: {:?},\nstd_err: {}",
command,
args,
std_err,
))]
YqAppendToObjectCommand {
command: String,
args: Vec<String>,
std_err: String,
},

/// Error for when we fail to read the entries of a directory.
#[snafu(display("Failed to read the contents of directory {}: {}", path.display(), source))]
ReadingDirectoryContents {
Expand Down
Loading