Skip to content

Commit bfe1b7a

Browse files
author
datacore-bolt-ci
committed
ci(stability): merge the develop branch
2 parents 066c6d4 + 155492f commit bfe1b7a

File tree

25 files changed

+1128
-124
lines changed

25 files changed

+1128
-124
lines changed

.github/workflows/helm-pins.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Helm Pins
2+
on:
3+
workflow_call:
4+
workflow_dispatch:
5+
6+
jobs:
7+
ci:
8+
uses: ./.github/workflows/k8s-ci.yml
9+
secrets: inherit
10+
with:
11+
helm-pins: true
12+
registry: 'ghcr.io'
13+
namespace: 'openebs/helm-pins'

.github/workflows/k8s-ci.yml

Lines changed: 83 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
name: K8s CI
22
on:
33
workflow_call:
4+
inputs:
5+
helm-pins:
6+
required: false
7+
type: boolean
8+
default: false
9+
registry:
10+
required: false
11+
type: string
12+
default: ghcr.io
13+
namespace:
14+
required: false
15+
type: string
16+
default: openebs/helm-pins
417

518
jobs:
619
k8s-ci:
720
runs-on: ubuntu-latest-8-cores
821
steps:
9-
- name: Bind mount /dev/sda1 to /nix
10-
run: |
11-
sudo mkdir -p /nix
12-
sudo mount --bind /mnt /nix
13-
lsblk
1422
- uses: actions/checkout@v4
1523
with:
24+
fetch-depth: 0
1625
submodules: recursive
1726
- uses: cachix/[email protected]
1827
with:
@@ -33,39 +42,100 @@ jobs:
3342
sudo dpkg-reconfigure man-db || true
3443
nix-shell ./scripts/k8s/shell.nix --run "./scripts/k8s/deployer.sh start --label"
3544
- name: Prepare v-next images and binary
45+
if: ${{ !inputs.helm-pins }}
3646
run: nix-shell ./scripts/python/shell.nix --run "./scripts/python/upgrade-test-helper.sh --build --chart-tag --chart ./chart"
3747
- name: Load images to kind cluster
48+
if: ${{ !inputs.helm-pins }}
3849
run: nix-shell ./scripts/python/shell.nix --run "./scripts/python/upgrade-test-helper.sh --load"
50+
- name: Login to Helm Pins Registry
51+
if: ${{ inputs.helm-pins }}
52+
uses: docker/login-action@v3
53+
with:
54+
registry: ${{ inputs.registry }}
55+
username: ${{ github.actor }}
56+
password: ${{ secrets.GITHUB_TOKEN }}
57+
- name: Create Pinned Helm Chart
58+
id: pin
59+
if: ${{ inputs.helm-pins }}
60+
run: |
61+
nix-shell ./scripts/helm/shell.nix --run "./scripts/helm/pin.sh --registry ${{ inputs.registry }} --namespace ${{ inputs.namespace }} --kind"
62+
if ! git diff --exit-code "./chart"; then
63+
echo "update=true" >> $GITHUB_OUTPUT
64+
else
65+
echo "update=false" >> $GITHUB_OUTPUT
66+
fi
3967
- name: Run pytest
68+
if: ${{ inputs.helm-pins && steps.pin.outputs.update == 'true' }}
69+
env:
70+
CHART_VNEXT_REGISTRY: ${{ inputs.registry }}
71+
CHART_VNEXT_NAMESPACE: ${{ inputs.namespace }}
72+
CHART_VNEXT_PLUGIN: "./kubectl-plugin/bin/kubectl-mayastor"
73+
REUSE_CLUSTER: 1
74+
CHART_VNEXT_SKIP: 1
75+
CLEAN: 0
76+
run: nix-shell ./scripts/python/shell.nix --run "./scripts/python/test.sh"
77+
- name: Run pytest
78+
if: ${{ !inputs.helm-pins }}
79+
env:
80+
REUSE_CLUSTER: 1
81+
CHART_VNEXT_SKIP: 1
82+
CLEAN: 0
83+
run: nix-shell ./scripts/python/shell.nix --run "./scripts/python/test.sh"
84+
- name: Push Pinned Helm Chart
85+
if: ${{ inputs.helm-pins && steps.pin.outputs.update == 'true' }}
4086
run: |
41-
export REUSE_CLUSTER=1
42-
export CHART_VNEXT_SKIP=1
43-
export CLEAN=0
44-
nix-shell ./scripts/python/shell.nix --run "./scripts/python/test.sh"
87+
# Push pinned with specific version
88+
nix-shell ./scripts/helm/shell.nix --run "./scripts/helm/push-oci.sh -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} --registry ${{ inputs.registry }} --namespace ${{ inputs.namespace }} -k -j"
89+
# Push pinned latest
90+
nix-shell ./scripts/helm/shell.nix --run "./scripts/helm/pin.sh --registry ${{ inputs.registry }} --namespace ${{ inputs.namespace }} --latest"
91+
nix-shell ./scripts/helm/shell.nix --run "./scripts/helm/push-oci.sh -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} --registry ${{ inputs.registry }} --namespace ${{ inputs.namespace }} -k"
4592
- name: Collect logs
4693
if: ${{ failure() }}
4794
run: |
4895
nix-shell ./scripts/k8s/shell.nix --run "kubectl get pods -A -o wide"
49-
nix-shell ./scripts/k8s/shell.nix --run "kubectl -n mayastor logs -l openebs.io/release=mayastor --all-containers=true"
50-
nix-shell ./scripts/k8s/shell.nix --run "kubectl -n mayastor logs -l app=upgrade --all-containers=true"
96+
nix-shell ./scripts/k8s/shell.nix --run "kubectl -n mayastor logs -l openebs.io/release=mayastor --all-containers=true --tail=-1"
97+
nix-shell ./scripts/k8s/shell.nix --run "kubectl -n mayastor logs -l app=upgrade --all-containers=true --tail=-1"
5198
- name: Upload pytest logs
52-
if: always()
99+
if: ${{ always() && inputs.helm-pins && steps.pin.outputs.update == 'true' }}
100+
uses: actions/upload-artifact@v4
101+
with:
102+
name: pytest-pins.log
103+
path: pytest.log
104+
- name: Upload pytest logs
105+
if: ${{ always() && !inputs.helm-pins }}
53106
uses: actions/upload-artifact@v4
54107
with:
55108
name: pytest.log
56109
path: pytest.log
57110
- name: Report pytest results
58-
if: always()
111+
if: ${{ always() && steps.pin.outputs.update != 'false' }}
59112
uses: pmeier/pytest-results-action@main
60113
with:
61114
path: report.xml
62115
summary: true
63116
display-options: a
64117
fail-on-empty: true
65118
title: Test results
119+
- name: Collect dump
120+
if: failure()
121+
run: |
122+
nix-shell ./scripts/k8s/shell.nix --run "kind export logs ./dump/kind"
123+
nix-shell ./scripts/k8s/shell.nix --run "kubectl cluster-info dump --output-directory=./dump/k8s --namespaces=mayastor"
124+
- name: Upload cluster dump
125+
if: failure()
126+
uses: actions/upload-artifact@v4
127+
with:
128+
name: k8s-dump
129+
path: dump
130+
# debugging
131+
# - name: Setup tmate session
132+
# if: ${{ failure() }}
133+
# timeout-minutes: 120
134+
# uses: mxschmitt/action-tmate@v3
66135

67136
k8s-ci-vm:
68137
runs-on: ubuntu-latest-8-cores
138+
if: ${{ !inputs.helm-pins }}
69139
steps:
70140
- uses: actions/checkout@v4
71141
- uses: cachix/[email protected]

.github/workflows/nightly-ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ on:
55
jobs:
66
ci:
77
uses: ./.github/workflows/pr-ci.yml
8+
helm-pins:
9+
uses: ./.github/workflows/helm-pins.yml
10+
secrets: inherit
811
nightly-ci:
912
if: ${{ success() }}
1013
needs:
1114
- ci
15+
- helm-pins
1216
runs-on: ubuntu-latest
1317
steps:
1418
- name: CI succeeded
1519
run: exit 0
16-

.github/workflows/pr-ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@ jobs:
2929
steps:
3030
- name: CI succeeded
3131
run: exit 0
32-

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ tests/bdd/venv
2727
pytest.log
2828
#/tests/bdd/chart-vnext/
2929
/chart/kubectl-plugin
30+
/report.xml
31+

chart/shell.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ pkgs.mkShell {
1212
semver-tool
1313
yq-go
1414
jq
15+
oras
1516
];
1617
}

k8s/upgrade/src/plugin/constants.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ pub(crate) const DEFAULT_IMAGE_REGISTRY: &str = "docker.io";
6969
/// The upgrade job will use the UPGRADE_JOB_IMAGE_NAME image (below) with this tag.
7070
pub(crate) const UPGRADE_JOB_IMAGE_TAG: &str = "develop";
7171

72-
/// Upgrade job container image repository.
73-
pub(crate) const UPGRADE_JOB_IMAGE_REPO: &str = constants::UPGRADE_JOB_IMAGE_REPO;
74-
7572
pub(crate) use constants::upgrade_job_img;
7673

7774
/// Upgrade job name suffix.

k8s/upgrade/src/plugin/upgrade.rs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::plugin::{
55
DEFAULT_IMAGE_REGISTRY, DEFAULT_RELEASE_NAME, IO_ENGINE_POD_LABEL, MAX_RETRY_ATTEMPTS,
66
UPGRADE_CONFIG_MAP_MOUNT_PATH, UPGRADE_CONFIG_MAP_NAME_SUFFIX,
77
UPGRADE_JOB_CLUSTERROLEBINDING_NAME_SUFFIX, UPGRADE_JOB_CLUSTERROLE_NAME_SUFFIX,
8-
UPGRADE_JOB_IMAGE_REPO, UPGRADE_JOB_NAME_SUFFIX, UPGRADE_JOB_SERVICEACCOUNT_NAME_SUFFIX,
8+
UPGRADE_JOB_NAME_SUFFIX, UPGRADE_JOB_SERVICEACCOUNT_NAME_SUFFIX,
99
},
1010
error, objects,
1111
user_prompt::{
@@ -83,6 +83,10 @@ pub struct UpgradeArgs {
8383
#[clap(global = true, long)]
8484
registry: Option<String>,
8585

86+
/// Specify the container namespace for the upgrade-job image.
87+
#[clap(global = true, long)]
88+
repo_namespace: Option<String>,
89+
8690
/// Allow upgrade from stable versions to unstable versions. This is implied when the
8791
/// '--skip-upgrade-path-validation-for-unsupported-version' option is used.
8892
#[clap(global = true, long, hide = true)]
@@ -138,6 +142,7 @@ impl UpgradeArgs {
138142
pub fn new() -> Self {
139143
Self {
140144
registry: None,
145+
repo_namespace: None,
141146
allow_unstable: false,
142147
dry_run: false,
143148
skip_data_plane_restart: false,
@@ -710,17 +715,21 @@ impl UpgradeResources {
710715
let img = ImageProperties::try_from(rest_deployment)?;
711716
let set_file = create_helm_set_file_args(args, set_file_map).await?;
712717

713-
// Image registry override check.
718+
// Image registry/namespace override check.
714719
let registry: &str = match args.registry {
715720
Some(ref registry_override) => registry_override,
716721
None => img.registry(),
717722
};
723+
let namespace: &str = match args.repo_namespace {
724+
Some(ref namespace) => namespace,
725+
None => img.namespace(),
726+
};
718727

719728
let upgrade_deploy = objects::upgrade_job(
720729
ns,
721730
upgrade_image_concat(
722731
registry,
723-
UPGRADE_JOB_IMAGE_REPO,
732+
namespace,
724733
&upgrade_job_img(),
725734
upgrade_job_image_tag.as_str(),
726735
),
@@ -884,6 +893,7 @@ pub(crate) async fn is_upgrade_job_completed(ns: &str) -> error::Result<bool> {
884893
struct ImageProperties {
885894
pull_secrets: Option<Vec<k8s_openapi::api::core::v1::LocalObjectReference>>,
886895
registry: String,
896+
namespace: String,
887897
pull_policy: Option<String>,
888898
}
889899

@@ -912,16 +922,18 @@ impl TryFrom<Deployment> for ImageProperties {
912922
if image_sections.is_empty() || image_sections.len() == 1 {
913923
return error::ReferenceDeploymentInvalidImage.fail();
914924
}
915-
916-
let registry = match image_sections.len() {
917-
3 => image_sections[0],
918-
_ => DEFAULT_IMAGE_REGISTRY,
919-
}
920-
.to_string();
925+
// todo: isn't the registry always explicitly shown anyway?
926+
let (registry, namespace) = if image_sections.len() >= 3 {
927+
let namespace = image_sections[1..image_sections.len() - 1].join("/");
928+
(image_sections[0], namespace)
929+
} else {
930+
(DEFAULT_IMAGE_REGISTRY, image_sections[0].to_string())
931+
};
921932

922933
Ok(Self {
923934
pull_secrets: pod_spec.image_pull_secrets.clone(),
924-
registry,
935+
registry: registry.to_string(),
936+
namespace,
925937
pull_policy: container.image_pull_policy.clone(),
926938
})
927939
}
@@ -936,6 +948,10 @@ impl ImageProperties {
936948
self.registry.as_str()
937949
}
938950

951+
fn namespace(&self) -> &str {
952+
self.namespace.as_str()
953+
}
954+
939955
fn pull_policy(&self) -> Option<String> {
940956
self.pull_policy.clone()
941957
}

nix/pkgs/images/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ let
5858
# Script doesn't need to be used with main branch `--alias-tag <main-branch-style-tag>`.
5959
# The repo chart is already prepared.
6060
if [[ "$(semver validate ${tag})" == "valid" ]] &&
61+
[[ ! ${tag} =~ ^(v?[0-9]+\.[0-9]+\.[0-9]+-pin-(dev|devrel).([0-9]+))$ ]] &&
6162
[[ ! ${tag} =~ ^(v?[0-9]+\.[0-9]+\.[0-9]+-0-(main|release)-unstable(-[0-9]+){6}-0)$ ]]; then
6263
CHART_FILE=build/chart/Chart.yaml build/scripts/helm/publish-chart-yaml.sh --app-tag ${tag} --override-index ""
6364
fi

scripts/helm/chart-version.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
SCRIPT_DIR="$(dirname "$(realpath "${BASH_SOURCE[0]:-"$0"}")")"
6+
ROOT_DIR="$SCRIPT_DIR/../.."
7+
CHART_DIR="$ROOT_DIR/chart"
8+
CHART="$CHART_DIR/Chart.yaml"
9+
HELM="helm"
10+
11+
source "$ROOT_DIR/scripts/utils/helm.sh"
12+
13+
echo -n "$(helm_chart_version)"

0 commit comments

Comments
 (0)