Skip to content

Commit

Permalink
fix(upgrade-job): update scrapeConfigs only if source is default
Browse files Browse the repository at this point in the history
Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
  • Loading branch information
niladrih committed Dec 27, 2023
1 parent 5bd7eaa commit e74f6ca
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
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";
57 changes: 55 additions & 2 deletions k8s/upgrade/src/bin/upgrade-job/helm/values.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::{
common::{
constants::{TWO_DOT_FIVE, TWO_DOT_FOUR, TWO_DOT_ONE, TWO_DOT_O_RC_ONE, TWO_DOT_THREE},
constants::{
TWO_DOT_FIVE, TWO_DOT_FOUR, TWO_DOT_ONE, TWO_DOT_O_RC_ONE, TWO_DOT_SIX, TWO_DOT_THREE,
},
error::{Result, SemverParse},
file::write_to_tempfile,
},
Expand Down Expand Up @@ -134,9 +136,50 @@ where
})?;
if source_version.ge(&two_dot_o_rc_zero) && source_version.lt(&two_dot_five) {
// promtail
let scrape_configs_to_replace = r"- job_name: {{ .Release.Name }}-pods-name
pipeline_stages:
- docker: {}
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels:
- __meta_kubernetes_pod_node_name
target_label: hostname
action: replace
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- action: keep
source_labels:
- __meta_kubernetes_pod_label_openebs_io_logging
regex: true
target_label: {{ .Release.Name }}_component
- action: replace
replacement: $1
separator: /
source_labels:
- __meta_kubernetes_namespace
target_label: job
- action: replace
source_labels:
- __meta_kubernetes_pod_name
target_label: pod
- action: replace
source_labels:
- __meta_kubernetes_pod_container_name
target_label: container
- replacement: /var/log/pods/*$1/*.log
separator: /
source_labels:
- __meta_kubernetes_pod_uid
- __meta_kubernetes_pod_container_name
target_label: __path__
";
if source_values
.loki_promtail_scrape_configs()
.ne(target_values.loki_promtail_scrape_configs())
.eq(scrape_configs_to_replace)
&& target_values
.loki_promtail_scrape_configs()
.ne(scrape_configs_to_replace)
{
yq.set_value(
YamlKey::try_from(".loki-stack.promtail.config.snippets.scrapeConfigs")?,
Expand All @@ -160,8 +203,18 @@ 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) {
// Update localpv-provisioner helm chart.
// This change is meant for versions from 2.0.0 to 2.4.0. However, this code wasn't checked
// into 2.5.0, and likely users of upgrade-job 2.5.0 are using the localpv image tag
// from 2.4.0 (i.e. 3.4.0) with the 3.5.0 localpv helm chart. So these options should
// also be set for source version 2.5.0.
let localpv_version_to_replace = "3.4.0";
if source_values
.localpv_release_version()
Expand Down

0 comments on commit e74f6ca

Please sign in to comment.