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

Changes for testing 'upgrade' from develop branch #341

Merged
merged 3 commits into from
Oct 5, 2023
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
15 changes: 12 additions & 3 deletions .github/workflows/main-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,30 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: cachix/install-nix-action@v22
- name: Pre-populate nix-shell
run: |
export NIX_PATH=nixpkgs=$(jq '.nixpkgs.url' nix/sources.json -r)
echo "NIX_PATH=$NIX_PATH" >> $GITHUB_ENV
nix-shell --pure --run "echo" ./scripts/helm/shell.nix
- name: Update loglevel to debug
- name: Update chart
run: |
# Update logLevel to 'debug'
sed -Ei "s~(logLevel: .*)~logLevel: debug~" chart/values.yaml
- name: Prepare chart for publishing
# Update repo url/name across all chart files
sed -i "s/mayastor-extensions/mayastor-chart-donotuse/g" chart/*.*
- name: Check if the chart is publishable
run: |
branch="${{ github.ref_name }}"
nix-shell --pure --run "./scripts/helm/publish-chart-yaml.sh --app-tag "0.0.0-$branch"" ./scripts/helm/shell.nix
nix-shell --pure --run "./scripts/helm/publish-chart-yaml.sh --check-chart "$branch"" ./scripts/helm/shell.nix
- name: Publish Mayastor Helm chart
uses: stefanprodan/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
charts_dir: .
charts_url: https://openebs.github.io/mayastor-chart-donotuse
owner: openebs
repository: mayastor-chart-donotuse
branch: gh-pages
tiagolobocastro marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -30,5 +30,8 @@ pub(crate) const UMBRELLA_CHART_UPGRADE_DOCS_URL: &str =
/// This defines the range of helm chart versions for the 2.0 release of the Core helm chart.
pub(crate) const TWO_DOT_O: &str = ">=2.0.0-rc.0, <2.1.0";

/// This defines the range of helm chart versions 2.1 and higher, of the Core helm chart.
pub(crate) const TWO_DOT_ONE_AND_UP: &str = ">=2.1.0";

/// This defines the range of helm chart versions for the 2.3 release of the Core helm chart.
pub(crate) const TWO_DOT_THREE: &str = ">=2.3.0-rc.0, <2.4.0";
74 changes: 74 additions & 0 deletions k8s/upgrade/src/bin/upgrade-job/helm/chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ impl CoreValues {
self.image.tag()
}

/// This is a getter for the control-plane repoTag image tag set on a helm chart.
pub(crate) fn control_plane_repotag(&self) -> &str {
self.image.control_plane_repotag()
}

/// This is a getter for the data-plane repoTag image tag set on a helm chart.
pub(crate) fn data_plane_repotag(&self) -> &str {
self.image.data_plane_repotag()
}

/// This is a getter for the extensions repoTag image tag set on a helm chart.
pub(crate) fn extensions_repotag(&self) -> &str {
self.image.extensions_repotag()
}

/// This is a getter for the io-engine DaemonSet Pods' logLevel.
pub(crate) fn io_engine_log_level(&self) -> &str {
self.io_engine.log_level()
Expand Down Expand Up @@ -82,16 +97,67 @@ impl CoreValues {
/// This is used to deserialize the yaml object "image", which contains details required for pulling
/// container images.
#[derive(Deserialize)]
#[serde(rename_all(deserialize = "camelCase"))]
pub(crate) struct Image {
/// The container image tag.
tag: String,
/// This contains image tags set based on which PRODUCT repository the microservice originates
/// from.
#[serde(default)]
repo_tags: RepoTags,
}

impl Image {
/// This is a getter for the container image tag used across the helm chart release.
pub(crate) fn tag(&self) -> &str {
self.tag.as_str()
}

/// This is a getter for the control-plane repoTag set on a helm chart.
pub(crate) fn control_plane_repotag(&self) -> &str {
self.repo_tags.control_plane()
}

/// This is a getter for the data-plane repoTag set on a helm chart.
pub(crate) fn data_plane_repotag(&self) -> &str {
self.repo_tags.data_plane()
}

/// This is a getter for the extensions repoTag set on a helm chart.
pub(crate) fn extensions_repotag(&self) -> &str {
self.repo_tags.extensions()
}
}

/// This contains image tags for PRODUCT components based on the repository for the specific
/// component.
#[derive(Deserialize, Default)]
#[serde(rename_all(deserialize = "camelCase"))]
pub(crate) struct RepoTags {
/// This member of repoTags is used to set image tags for components from the control-plane
/// repo.
control_plane: String,
/// This member of repoTags is used to set image tags for components from the data-plane repo.
data_plane: String,
/// This member of repoTags is used to set image tags for components from the extensions repo.
extensions: String,
}

impl RepoTags {
/// This is a getter for the control-plane image tag set on a helm chart.
pub(crate) fn control_plane(&self) -> &str {
self.control_plane.as_str()
}

/// This is a getter for the data-plane image tag set on a helm chart.
pub(crate) fn data_plane(&self) -> &str {
self.data_plane.as_str()
}

/// This is a getter for the extensions image tag set on a helm chart.
pub(crate) fn extensions(&self) -> &str {
self.extensions.as_str()
}
}

/// This is used to deserialize the yaml object "io_engine", which contains configuration for the
Expand Down Expand Up @@ -121,6 +187,7 @@ pub(crate) struct Eventing {
// to compare against new values (those bundled with the chart in the upgrade-job's
// local filesystem) and decide if a yq 'set' is required. This default is not a
// fallback value that is set in case the user's value's yaml is missing the value.
/// This enables eventing and components when enabled.
enabled: bool,
}

Expand All @@ -134,6 +201,7 @@ impl Eventing {
/// This is used to deserialize the yaml object 'csi'.
#[derive(Deserialize)]
pub(crate) struct Csi {
/// This contains the image tags for the kubernetes-csi sidecar containers.
image: CsiImage,
}

Expand Down Expand Up @@ -164,15 +232,21 @@ impl Csi {
}
}

/// This contains the image tags for the CSI sidecar containers.
#[derive(Deserialize)]
#[serde(rename_all(deserialize = "camelCase"))]
pub(crate) struct CsiImage {
/// This is the image tag for the csi-provisioner container.
provisioner_tag: String,
/// This is the image tag for the csi-attacher container.
attacher_tag: String,
/// This is the image tag for the csi-snapshotter container.
#[serde(default)]
snapshotter_tag: String,
/// This is the image tag for the snapshot-controller container.
#[serde(default)]
snapshot_controller_tag: String,
/// This is the image tag for the csi-node-driver-registrar container.
registrar_tag: String,
}

Expand Down
1 change: 1 addition & 0 deletions k8s/upgrade/src/bin/upgrade-job/helm/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ impl HelmUpgradeBuilder {
// Generate values yaml file for upgrade
let _upgrade_values_file = generate_values_yaml_file(
&from_version,
&to_version,
chart_dir.as_path(),
&client,
release_name.clone(),
Expand Down
48 changes: 28 additions & 20 deletions k8s/upgrade/src/bin/upgrade-job/helm/values.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
common::{
constants::{TWO_DOT_O, TWO_DOT_THREE},
constants::{TWO_DOT_O, TWO_DOT_ONE_AND_UP, TWO_DOT_THREE},
error::{
ReadingFile, Result, SemverParse, TempFileCreation, U8VectorToString, WriteToTempFile,
YamlParseFromFile, YamlParseFromSlice,
Expand All @@ -20,6 +20,7 @@ use tempfile::NamedTempFile as TempFile;
/// This compiles all of the helm values options to be passed during the helm chart upgrade.
pub(crate) fn generate_values_yaml_file(
from_version: &Version,
to_version: &Version,
chart_dir: &Path,
client: &HelmReleaseClient,
release_name: String,
Expand Down Expand Up @@ -81,6 +82,32 @@ pub(crate) fn generate_values_yaml_file(
}
}

// Specific special-case values for to-version >=2.1.x.
let version_two_dot_one_and_up =
VersionReq::parse(TWO_DOT_ONE_AND_UP).context(SemverParse {
version_string: TWO_DOT_ONE_AND_UP.to_string(),
})?;
if version_two_dot_one_and_up.matches(to_version) {
// RepoTags fields will also be set to the values found in the target helm values file
// (low_priority file). This is so integration tests which use specific repo commits can
// upgrade to a custom helm chart.
yq.set_value(
YamlKey::try_from(".image.repoTags.controlPlane")?,
to_values.control_plane_repotag(),
upgrade_values_file.path(),
)?;
yq.set_value(
YamlKey::try_from(".image.repoTags.dataPlane")?,
to_values.data_plane_repotag(),
upgrade_values_file.path(),
)?;
yq.set_value(
YamlKey::try_from(".image.repoTags.extensions")?,
to_values.extensions_repotag(),
upgrade_values_file.path(),
)?;
}

// Specific special-case values for version 2.3.x.
let version_two_dot_three = VersionReq::parse(TWO_DOT_THREE).context(SemverParse {
version_string: TWO_DOT_THREE.to_string(),
Expand All @@ -106,25 +133,6 @@ pub(crate) fn generate_values_yaml_file(
upgrade_values_file.path(),
)?;

// RepoTags fields will be set to empty strings. This is required because we are trying
// to get to the target container images, without setting versions for repo-specific
// components.
yq.set_value(
YamlKey::try_from(".image.repoTags.controlPlane")?,
"",
upgrade_values_file.path(),
)?;
yq.set_value(
YamlKey::try_from(".image.repoTags.dataPlane")?,
"",
upgrade_values_file.path(),
)?;
yq.set_value(
YamlKey::try_from(".image.repoTags.extensions")?,
"",
upgrade_values_file.path(),
)?;

// The CSI sidecar images need to always be the versions set on the chart by default.
yq.set_value(
YamlKey::try_from(".csi.image.provisionerTag")?,
Expand Down
Loading