Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
11 changes: 7 additions & 4 deletions pkg/admin/prerun/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ type versionFile struct {
BootID string `json:"boot_id"`
}

const MAX_VERSION_SKEW = 2

func (hi *versionFile) BackupName() data.BackupName {
return data.BackupName(fmt.Sprintf("%s_%s", hi.DeploymentID, hi.BootID))
}
Expand Down Expand Up @@ -317,12 +319,13 @@ func checkVersionCompatibility(execVer, dataVer versionMetadata) error {
}

if execVer.Minor > dataVer.Minor {
if execVer.Minor-1 == dataVer.Minor {
klog.InfoS("Executable is newer than data by 1 - continuing")
versionSkew := execVer.Minor - dataVer.Minor
if versionSkew <= MAX_VERSION_SKEW {
klog.Infof("Executable is newer than data by %d minor versions, continuing", versionSkew)
return nil
} else {
return fmt.Errorf("executable (%s) is too recent compared to existing data (%s): version difference is %d, maximum allowed difference is 1",
execVer.String(), dataVer.String(), execVer.Minor-dataVer.Minor)
return fmt.Errorf("executable (%s) is too recent compared to existing data (%s): minor version difference is %d, maximum allowed difference is %d",
execVer.String(), dataVer.String(), versionSkew, MAX_VERSION_SKEW)
}
}

Expand Down
12 changes: 9 additions & 3 deletions pkg/admin/prerun/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,20 @@ func TestCheckVersionDiff(t *testing.T) {
errExpected: true,
},
{
name: "binary must be newer only by one minor version",
name: "binary may be newer by one minor version",
execVer: versionMetadata{Major: 4, Minor: 15},
dataVer: versionMetadata{Major: 4, Minor: 14},
errExpected: false,
},
{
name: "binary newer more than one minor version is not supported",
execVer: versionMetadata{Major: 4, Minor: 15},
name: "binary may be newer by two minor versions",
execVer: versionMetadata{Major: 4, Minor: 16},
dataVer: versionMetadata{Major: 4, Minor: 14},
errExpected: false,
},
{
name: "binary must not be newer by more than 2 minor versions",
execVer: versionMetadata{Major: 4, Minor: 16},
dataVer: versionMetadata{Major: 4, Minor: 13},
errExpected: true,
},
Expand Down
9 changes: 0 additions & 9 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ REPO := $(shell git rev-parse --show-toplevel)
include $(REPO)/Makefile

NEXT_MINOR = $(shell expr $(MINOR) + 1)
YPLUS2_MINOR = $(shell expr $(MINOR) + 2)

.PHONY: fake-next-minor-rpm
fake-next-minor-rpm: RPMBUILD_DIR := $(REPO)/_output/rpmbuild-fake-next-minor/
Expand All @@ -12,14 +11,6 @@ fake-next-minor-rpm:
RPMBUILD_DIR=$(RPMBUILD_DIR) \
$(MAKE) -C $(REPO) rpm

.PHONY: fake-yplus2-minor-rpm
fake-yplus2-minor-rpm: RPMBUILD_DIR := $(REPO)/_output/rpmbuild-fake-yplus2-minor/
fake-yplus2-minor-rpm:
rm -rf $(RPMBUILD_DIR)
MICROSHIFT_VERSION="$(MAJOR).$(YPLUS2_MINOR).$(PATCH)_fake_YPLUS2_minor" \
RPMBUILD_DIR=$(RPMBUILD_DIR) \
$(MAKE) -C $(REPO) rpm

# build-base-branch
# By default, BASE_BRANCH is derived from the microshift/Makefile.version.$(uname -i).var string.
# The BASE_BRANCH is pulled from the remote repo. This is because OpenShift-CI fetches only PR commit tree
Expand Down
16 changes: 12 additions & 4 deletions test/bin/build_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,21 @@ configure_package_sources() {
export LOCAL_REPO # defined in common.sh
export NEXT_REPO # defined in common.sh
export BASE_REPO # defined in common.sh
export YPLUS2_REPO # defined in common.sh
export CURRENT_RELEASE_REPO
export PREVIOUS_RELEASE_REPO

export SOURCE_VERSION
export FAKE_NEXT_MINOR_VERSION
export FAKE_YPLUS2_MINOR_VERSION
export MINOR_VERSION
export PREVIOUS_MINOR_VERSION
export YMINUS2_MINOR_VERSION
export SOURCE_VERSION_BASE
export CURRENT_RELEASE_VERSION
export PREVIOUS_RELEASE_VERSION
export YMINUS2_RELEASE_VERSION
export RHOCP_MINOR_Y
export RHOCP_MINOR_Y1
export RHOCP_MINOR_Y2

# Add our sources. It is OK to run these steps repeatedly, if the
# details change they are updated in the service.
Expand Down Expand Up @@ -681,8 +682,8 @@ fi
SOURCE_VERSION=$(rpm -q --queryformat '%{version}' "${release_info_rpm}")
MINOR_VERSION=$(echo "${SOURCE_VERSION}" | cut -f2 -d.)
PREVIOUS_MINOR_VERSION=$(( "${MINOR_VERSION}" - 1 ))
YMINUS2_MINOR_VERSION=$(( "${MINOR_VERSION}" - 2 ))
FAKE_NEXT_MINOR_VERSION=$(( "${MINOR_VERSION}" + 1 ))
FAKE_YPLUS2_MINOR_VERSION=$(( "${MINOR_VERSION}" + 2 ))
SOURCE_VERSION_BASE=$(rpm -q --queryformat '%{version}' "${release_info_rpm_base}")

current_version_repo=$(get_rel_version_repo "${MINOR_VERSION}")
Expand All @@ -702,6 +703,13 @@ if is_rhocp_available "${PREVIOUS_MINOR_VERSION}"; then
RHOCP_MINOR_Y1="${PREVIOUS_MINOR_VERSION}"
fi

# For Y-2, there will always be a real repository, so we can always
# set the template variable for enabling that package source.
yminus2_version_repo=$(get_rel_version_repo "${YMINUS2_MINOR_VERSION}")
YMINUS2_RELEASE_VERSION=$(echo "${yminus2_version_repo}" | cut -d, -f1)
YMINUS2_RELEASE_REPO=$(echo "${yminus2_version_repo}" | cut -d, -f1)
RHOCP_MINOR_Y2="${YMINUS2_MINOR_VERSION}"

mkdir -p "${IMAGEDIR}"
LOGDIR="${IMAGEDIR}/build-logs"
mkdir -p "${LOGDIR}"
Expand All @@ -717,8 +725,8 @@ if ${EXTRACT_CONTAINER_IMAGES}; then
extract_container_images "${SOURCE_VERSION}" "${LOCAL_REPO}" "${CONTAINER_LIST}"
# The following images are specific to layers that use fake rpms built from source.
extract_container_images "4.${FAKE_NEXT_MINOR_VERSION}.*" "${NEXT_REPO}" "${CONTAINER_LIST}"
extract_container_images "4.${FAKE_YPLUS2_MINOR_VERSION}.*" "${YPLUS2_REPO}" "${CONTAINER_LIST}"
Comment thread
dhellmann marked this conversation as resolved.
Outdated
extract_container_images "${PREVIOUS_RELEASE_VERSION}" "${PREVIOUS_RELEASE_REPO}" "${CONTAINER_LIST}"
extract_container_images "${YMINUS2_RELEASE_VERSION}" "${YMINUS2_RELEASE_REPO}" "${CONTAINER_LIST}"
fi

trap 'osbuild_logs' EXIT
Expand Down
3 changes: 0 additions & 3 deletions test/bin/build_rpms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ BUILD_CMDS+=(
# Build RPMs with the version number of the next minor release,
# but using the same source code as the normal build.
'make -C test/ fake-next-minor-rpm' \
# Build RPMs with the version number of the y+2 minor release,
# but using the same source code as the normal build.
'make -C test/ fake-yplus2-minor-rpm' \
# Build RPMs from release-$MAJOR.$MINOR of this repo.
# These RPMs are useful in providing a layer to upgrade from.
'make -C test/ build-base-branch' \
Expand Down
10 changes: 1 addition & 9 deletions test/bin/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ NEXT_RPM_SOURCE="${OUTPUTDIR}/rpmbuild-fake-next-minor"

# Location of RPMs built from source
# shellcheck disable=SC2034 # used elsewhere
YPLUS2_RPM_SOURCE="${OUTPUTDIR}/rpmbuild-fake-yplus2-minor"

# Location of RPMs built from source
# shellcheck disable=SC2034 # used elsewhere
BASE_RPM_SOURCE="${OUTPUTDIR}/rpmbuild-base"
BASE_RPM_SOURCE="${ROOTDIR}/_output/rpmbuild-base"
Comment thread
dhellmann marked this conversation as resolved.
Outdated

# Location of local repository used by composer
# shellcheck disable=SC2034 # used elsewhere
Expand All @@ -60,10 +56,6 @@ LOCAL_REPO="${IMAGEDIR}/rpm-repos/microshift-local"
# shellcheck disable=SC2034 # used elsewhere
NEXT_REPO="${IMAGEDIR}/rpm-repos/microshift-fake-next-minor"

# Location of local repository used by composer
# shellcheck disable=SC2034 # used elsewhere
YPLUS2_REPO="${IMAGEDIR}/rpm-repos/microshift-fake-yplus2-minor"

# Location of local repository used by composer
# shellcheck disable=SC2034 # used elsewhere
BASE_REPO="${IMAGEDIR}/rpm-repos/microshift-base"
Expand Down
1 change: 0 additions & 1 deletion test/bin/create_local_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@ cd "${IMAGEDIR}"

make_repo "${LOCAL_REPO}" "${RPM_SOURCE}"
make_repo "${NEXT_REPO}" "${NEXT_RPM_SOURCE}"
make_repo "${YPLUS2_REPO}" "${YPLUS2_RPM_SOURCE}"
make_repo "${BASE_REPO}" "${BASE_RPM_SOURCE}"
14 changes: 5 additions & 9 deletions test/bin/get_rel_version_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,11 @@ get_current_release_from_sub_repos() {
local -r minor="${1}"
local -r rhsm_repo="rhocp-4.${minor}-for-rhel-9-${UNAME_M}-rpms"

# getting version of RPM within a rhocp repo depends on the repo being enabled,
# which is done in configure_vm.sh
if dnf_repo_is_enabled "${rhsm_repo}"; then
local newest
newest=$(sudo dnf repoquery microshift --quiet --queryformat '%{version}-%{release}' --repo "${rhsm_repo}" | sort --version-sort | tail -n1)
if [ -n "${newest}" ]; then
echo "${newest}"
return
fi
local newest
newest=$(sudo dnf repoquery microshift --quiet --queryformat '%{version}-%{release}' --repo "${rhsm_repo}" | sort --version-sort | tail -n1)
if [ -n "${newest}" ]; then
echo "${newest}"
return

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmtk I think this is the change you've mentioned that we need, please take a look when you have a few minutes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so.
BTW. command can be changed to sudo dnf repoquery --quiet --latest-limit 1 --qf "%{version}-%{release}" --repo "${rhsm_repo}" microshift - --latest-limit instead of | sort | tail

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that function were to return "version,repo", then YMINUS2_RELEASE_REPO="$(get_ocp_repo_name_for_version ${YMINUS2_MINOR_VERSION})" could be cut -d, -f2 but I'm fine with either

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that. I liked the simplicity of that repo being explicitly known to exist in the caller, but maybe the symmetry of always having some repo reference returned is better? I'll defer to you, let me know if I should change it.

fi
echo ""
}
Expand Down
6 changes: 6 additions & 0 deletions test/bin/scenario.sh
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,12 @@ previous_minor_version() {
echo $(( $(current_minor_version) - 1 ))
}

# Function to report the minor version for 2 releases back. If the current
# version is "4.16.0", reports "14".
yminus2_minor_version() {
echo $(( $(current_minor_version) - 2 ))
}

# Function to report the *next* minor version. If the current
# version is "4.14.5", reports "15".
next_minor_version() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
name = "rhel-9.2-microshift-source-fake-yplus2-minor"
description = "A RHEL 9.2 image with the RPMs built from source from the current PR but with the _version_ set to the current+2 y-stream."
name = "rhel-9.2-microshift-4.{{ .Env.YMINUS2_MINOR_VERSION }}"
description = "RHEL 9.2 with MicroShift from two minor versions back installed."
version = "0.0.1"
modules = []
groups = []
distro = "rhel-92"

[[packages]]
name = "microshift"
version = "4.{{ .Env.FAKE_YPLUS2_MINOR_VERSION }}.*"
version = "{{ .Env.YMINUS2_RELEASE_VERSION }}*"

[[packages]]
name = "microshift-greenboot"
version = "4.{{ .Env.FAKE_YPLUS2_MINOR_VERSION }}.*"
version = "{{ .Env.YMINUS2_RELEASE_VERSION }}*"

[[packages]]
name = "microshift-networking"
version = "4.{{ .Env.FAKE_YPLUS2_MINOR_VERSION }}.*"
version = "{{ .Env.YMINUS2_RELEASE_VERSION }}*"

[[packages]]
name = "microshift-selinux"
version = "4.{{ .Env.FAKE_YPLUS2_MINOR_VERSION }}.*"
version = "{{ .Env.YMINUS2_RELEASE_VERSION }}*"

[[packages]]
name = "microshift-test-agent"
Expand All @@ -29,15 +29,7 @@ version = "*"
enabled = ["microshift", "microshift-test-agent"]

[customizations.firewall]
ports = [
"22:tcp",
"80:tcp",
"443:tcp",
"5353:udp",
"6443:tcp",
"30000-32767:tcp",
"30000-32767:udp",
]
ports = ["22:tcp", "80:tcp", "443:tcp", "5353:udp", "6443:tcp", "30000-32767:tcp", "30000-32767:udp"]

[customizations.firewall.services]
enabled = ["mdns", "ssh", "http", "https"]
Expand Down
7 changes: 0 additions & 7 deletions test/package-sources/microshift-fake-yplus2-minor.toml

This file was deleted.

10 changes: 10 additions & 0 deletions test/package-sources/rhocp-y2.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if env.Getenv "RHOCP_MINOR_Y2" "" -}}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comment said RHOCP for y-2 will always be available - do we need if here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I can remove that.

id = "rhocp-y2"
name = "Red Hat OpenShift Container Platform 4.{{ .Env.RHOCP_MINOR_Y2 }} for RHEL 9"
type = "yum-baseurl"
url = "https://cdn.redhat.com/content/dist/layered/rhel9/{{ .Env.UNAME_M }}/rhocp/4.{{ .Env.RHOCP_MINOR_Y2 }}/os"
check_gpg = true
check_ssl = true
system = false
rhsm = true
{{- end -}}
18 changes: 0 additions & 18 deletions test/scenarios/el92-src@upgrade-block-to-fake-y2.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
# Sourced from scenario.sh and uses functions defined there.

scenario_create_vms() {
# Determine the starting image based on the source tree current
# version, minus one.
local start_image
start_image="rhel-9.2-microshift-4.$(previous_minor_version)"
start_image="rhel-9.2-microshift-4.$(yminus2_minor_version)"

prepare_kickstart host1 kickstart.ks.template "${start_image}"
launch_vm host1
}
Expand All @@ -15,6 +18,6 @@ scenario_remove_vms() {

scenario_run_tests() {
run_tests host1 \
--variable "TOO_NEW_MICROSHIFT_REF:rhel-9.2-microshift-source-fake-next-minor" \
suites/upgrade/upgrade-block-2-minor.robot
--variable "TARGET_REF:rhel-9.2-microshift-source" \
suites/upgrade/upgrade-successful.robot
}
74 changes: 0 additions & 74 deletions test/suites/upgrade/upgrade-block-2-minor.robot

This file was deleted.