Skip to content

6‐Auto Chart Bumps

Nicholas openSUSE Software Engineer edited this page Nov 6, 2024 · 1 revision

There is an automatic chart bump feature available to each chart owner who may want to use it.

WORK IN PROGRESS

The auto-chart-bump will:

  1. Check the upstream chart repository for new updates.
  2. Fetch and Pull the changes to the rancher/charts repository.
  3. Calculate the proper versioning standard on a new version to bump the chart.
  4. Create a PR targeting the proper dev-v2.X branch.

The goal is to avoid any manual changes in the development branches by the chart owners. This way, they will have to handle only one upstream chart repository.

The feature is currently under testing for the rancher-cis-benchmark chart coming from the rancher-cis-operator upstream repository


Process details

The current auto chart bump can be understood as an automation of the default manual chart bump process, with the addition of an extra step that is to calculate the next version according to the repository versioning rules:

flowchart LR;
    A[make prepare] --> B[Calculate New Version] --> C[make patch] --> D[make clean] --> E[make chart]

Loading

Standards

To use this feature, there are 3 defined standards the chart owner must adhere to:

  1. the packages folder and the package.yaml file.
  2. the upstream repository sub-directories.
  3. the branch versioning lifecycle.

packages

For reference, see the following commits:

The packages/<chart> folder must only contain the package.yaml file.

The package.yaml file must follow this standard:

auto: true
url: https://github.com/<chart_git_repo_url>.git
chartRepoBranch: <git_release_branch>
subdirectory: <chart_folder_on_upstream_repository>
additionalCharts:
  - workingDir: <additional_chart_local_folder_for_executing_the_bump>(arbitrary)
    upstreamOptions:
      url: https://github.com/<chart_CRD_git_repo_url>.git
      chartRepoBranch: <chart_active_release_branch>
      subdirectory: <chart_subddir_crd_folder_on_upstream_repository>
    crdOptions:
      templateDirectory: <crd_local_template_dir_for_executing_the_bump>(arbitrary)
      crdDirectory: <crd_dir_where_templates_will_be_saved>
      addCRDValidationToMainChart: true

upstream repository dir structure

  • charts folder

    • This must be the same folder for the chart files, in the upstream repository
    • (rancher-cis-benchmark chart folder example)[https://github.com/rancher/cis-operator/tree/release/v1.3/chart]
    • subdirectory: <chart_folder_on_upstream_repository> in the package.yaml file.
  • crds folder

    • This must be the same folder for the crd templates, if any in the upstream repository
    • (rancher-cis-benchmark crds folder example)[https://github.com/rancher/cis-operator/tree/release/v1.3/crds]
    • additionalCharts.upstreamOptions.subdirectory: <chart_subddir_crd_folder_on_upstream_repository>
  • crds templates folder

    • This will be the sub-directory where the templates for the CRD will be saved after the bump.
    • additionalCharts.crdOptions.crdDirectory: <crd_dir_where_templates_will_be_saved>

branch versioning lifecycle

  • The upstream repository must have separated active release branches from the development branches.
  • These branches will automatically trigger the auto-chart-bump whenever they merge a new PR.
  • The upstream repository active release branches must correspond to the rancher/rancher and rancher/charts release lines.

See the example for rancher-cis-benchmark chart:

rancher branch charts branch chart repo-prefix-version cis-operator branch cis-operator chart versions
release/v2.8 dev-v2.8 103.x.y+up release/v1.1 5.x.y
release/v2.9 dev-v2.9 104.x.y+up release/v1.2 6.x.y
release/v2.10 dev-v2.10 105.x.y+up release/v1.3 7.x.y

This will correspond in the package.yaml file as:

  • chartRepoBranch: <git_release_branch> for the chart.
  • additionalCharts.upstreamOptions.chartRepoBranch: <git_release_branch> for the CRD.

How do you use this feature in your chart?

  1. Apply the described standards above (only open the PRs; wait to merge them).
  2. Schedule a specific support meeting with (Nicholas) from the release team.
  3. Upon validation, merge the PRs.
  4. The release team will execute 1 first manual execution.
  5. The release team will implement the automatic trigger.

How the versions are calculated?

Only the repo-prefix versions (the version for the charts inside the rancher/charts repo) are calculated.

The chart upstream version is used as it comes from the upstream repository.

Final result is always something like: 10X.y.z(repo-prefix)+upa.b.c(upstream chart)

The repo prefix versions will be calculated:

  • considering the configured branch in the package.yaml: chartRepoBranch: <git_release_branch>:
    • this must be defined according to the Major version of the repo-prefix version (i.e., 105.; 104.... etc)
  • considering the target dev-v2.X branch in the rancher/charts repository.
    • this must be defined according to the previous table considering the rancher and charts repository release lines.
  • considering the latest chart version present in the rancher/charts repository.
    • the latest chart version vs the to-release-chart-version will be used to calculate if it is a:
      • patch bump
      • minor bump

See the following examples:

rancher branch charts branch chart repo-prefix-version cis-operator branch cis-operator chart version to release latest chart version present on charts repo final calculated version
release/v2.9 dev-v2.9 104.x.y+up release/v1.2 6.0.0 103.9.9+up5.9.9 104.0.0+up6.0.0
release/v2.9 dev-v2.9 104.x.y+up release/v1.2 6.1.2 104.0.0+up6.1.1 104.0.1+up6.1.2
release/v2.10 dev-v2.10 105.x.y+up release/v1.3 7.0.0 6.9.9 105.0.0+up7.0.0
release/v2.10 dev-v2.10 105.x.y+up release/v1.3 7.1.0 105.0.0+up7.0.0 105.1.0+up7.1.0
release/v2.10 dev-v2.10 105.x.y+up release/v1.3 8.0.0 105.1.0+up7.1.0 105.2.0+up8.0.0

In a nutshell.

  • Major bumps only happen when there is a new release line for Rancher (e.g., 2.7 -> 2.8)
  • Minor bumps happen when the to-be-released version has a Major or Minor bump to the latest version.
  • Patch bumps happen when the to-be-released version has a Patch bump to the latest version.