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 migration for logSilenceLevel and pluginMounthPath #443

Merged
merged 1 commit into from
Mar 19, 2024
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
40 changes: 39 additions & 1 deletion k8s/upgrade/src/bin/upgrade-job/helm/chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ impl HelmValuesCollection for UmbrellaValues {
/// This is used to deserialize the values.yaml of the Core chart.
#[derive(Deserialize)]
pub(crate) struct CoreValues {
/// This contains values for all of the agents.
/// This contains values for all the agents.
agents: Agents,
/// This contains values for all the base components.
base: Base,
/// This is the yaml object which contains values for the container image registry, repository,
/// tag, etc.
image: Image,
Expand Down Expand Up @@ -182,6 +184,11 @@ impl CoreValues {
self.csi.node_nvme_io_timeout()
}

/// This returns the value of the removed key for CSI socket mount path.
pub(crate) fn deprecated_node_csi_mount_path(&self) -> &str {
self.csi.deprecated_node_csi_mount_path()
}

/// This is a getter for the grafana/loki container image tag.
pub(crate) fn loki_stack_loki_image_tag(&self) -> &str {
self.loki_stack.loki_image_tag()
Expand Down Expand Up @@ -298,6 +305,11 @@ impl CoreValues {
pub(crate) fn prometheus_server_image_tag(&self) -> &str {
self.loki_stack.prometheus_server_image_tag()
}

/// This is the value of the deprecated key for log silence configuration.
pub(crate) fn deprecated_log_silence_level(&self) -> &str {
self.base.deprecated_log_silence_level()
}
}

/// This is used to deserialize the yaml object agents.
Expand All @@ -313,6 +325,20 @@ impl Agents {
}
}

/// This is used to deserialize the yaml object base.
#[derive(Deserialize)]
struct Base {
#[serde(default, rename(deserialize = "logSilenceLevel"))]
deprecated_log_silence_level: String,
}

impl Base {
/// This returns the value for the removed base.logSilenceLevel YAML key.
fn deprecated_log_silence_level(&self) -> &str {
self.deprecated_log_silence_level.as_str()
}
}

/// This is used to deserialize the yaml object 'agents.ha'.
#[derive(Deserialize)]
struct Ha {
Expand Down Expand Up @@ -475,6 +501,11 @@ impl Csi {
fn node_nvme_io_timeout(&self) -> &str {
self.node.nvme_io_timeout()
}

/// This returns the mount path value's key, the old one with the typo.
fn deprecated_node_csi_mount_path(&self) -> &str {
self.node.deprecated_plugin_mount_path()
}
}

/// This contains the image tags for the CSI sidecar containers.
Expand Down Expand Up @@ -534,13 +565,20 @@ impl CsiImage {
#[derive(Deserialize)]
struct CsiNode {
nvme: CsiNodeNvme,
#[serde(default, rename(deserialize = "pluginMounthPath"))]
Abhinandan-Purkait marked this conversation as resolved.
Show resolved Hide resolved
deprecated_plugin_mount_path: String,
}

impl CsiNode {
/// This is a getter for the NVMe IO timeout.
fn nvme_io_timeout(&self) -> &str {
self.nvme.io_timeout()
}

/// This returns the csi node mount path key's value. The key had a typo, it's been removed.
fn deprecated_plugin_mount_path(&self) -> &str {
self.deprecated_plugin_mount_path.as_str()
}
}

/// This is used to deserialize the yaml object 'csi.node.nvme'.
Expand Down
30 changes: 24 additions & 6 deletions k8s/upgrade/src/bin/upgrade-job/helm/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,7 @@ where
upgrade_values_file.path(),
)?;
}
}

// Special-case values for 2.6.x.
let two_dot_six = Version::parse(TWO_DOT_SIX).context(SemverParse {
version_string: TWO_DOT_SIX.to_string(),
})?;
if source_version.ge(&two_dot_o_rc_zero) && source_version.lt(&two_dot_six) {
// Switch out image tag for the latest one.
yq.set_literal_value(
YamlKey::try_from(".loki-stack.loki.image.tag")?,
Expand Down Expand Up @@ -361,6 +355,30 @@ where
target_values.promtail_readiness_probe_http_get_path(),
upgrade_values_file.path(),
)?;

// This helm value key was changed:
// Ref: https://github.com/openebs/mayastor-extensions/pull/419
yq.set_literal_value(
YamlKey::try_from(".base.logging.silenceLevel")?,
source_values.deprecated_log_silence_level(),
upgrade_values_file.path(),
)?;
yq.delete_object(
YamlKey::try_from(".base.logSilenceLevel")?,
upgrade_values_file.path(),
)?;

// This is a fix for a typo in the .csi.node.pluginMounthPath key.
// It was fixed, and the key now is called .csi.node.pluginMountPath.
yq.set_literal_value(
YamlKey::try_from(".csi.node.pluginMountPath")?,
Abhinandan-Purkait marked this conversation as resolved.
Show resolved Hide resolved
source_values.deprecated_node_csi_mount_path(),
upgrade_values_file.path(),
)?;
yq.delete_object(
YamlKey::try_from(".csi.node.pluginMounthPath")?,
upgrade_values_file.path(),
)?;
}

// Default options.
Expand Down
Loading