Skip to content

Commit

Permalink
feat(upgrade-job): add migration for loki-stack
Browse files Browse the repository at this point in the history
- removes .loki-stack.loki.config.ingester.lifecycler.ring.kvstore as it
does not exist in loki-stack v2.9.11
- adds set value for the grafana/loki container image tag
- removes .loki-stack.promtail.config.snippets.extraClientConfigs as it
does not exist in loki-stack v2.9.11
- removes .loki-stack.promtail.initContainer as it does not exist in loki-stack
v2.9.11
- migrates .loki-stack.promtail.config.lokiAddress to .loki-stack.promtail.config.clients
- adds yq command_output helper function
- add set value for .loki-stack.promtail.readinessProbe.httpGet.path
- migrate .loki-stack.promtail.config.snippets.extraClientConfigs to
.loki-stack.promtail.config.clients

Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
  • Loading branch information
niladrih committed Dec 24, 2023
1 parent 831e0c5 commit 2e74712
Show file tree
Hide file tree
Showing 4 changed files with 495 additions and 129 deletions.
76 changes: 73 additions & 3 deletions k8s/upgrade/src/bin/upgrade-job/common/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::{
UMBRELLA_CHART_UPGRADE_DOCS_URL,
},
events::event_recorder::EventNote,
helm::chart::PromtailConfigClient,
};
use snafu::Snafu;
use std::path::PathBuf;
Expand Down Expand Up @@ -426,6 +427,49 @@ 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 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,14 +645,40 @@ pub(crate) enum Error {
std_err: String,
},

/// Error for when the yq command to update a yaml object returns an error.
/// 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` set-object-command returned an error,\ncommand: {},\nargs: {:?},\nstd_err: {}",
"`yq` append-to-object-command returned an error,\ncommand: {},\nargs: {:?},\nstd_err: {}",
command,
args,
std_err,
))]
YqSetObjCommand {
YqAppendToObjectCommand {
command: String,
args: Vec<String>,
std_err: String,
Expand Down
Loading

0 comments on commit 2e74712

Please sign in to comment.