-
Notifications
You must be signed in to change notification settings - Fork 41
Include livepatches variables in openqa.cmd #322
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
Draft
d3flex
wants to merge
1
commit into
os-autoinst:master
Choose a base branch
from
d3flex:try/investigate_possible_issue
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
import os | ||
import re | ||
import requests | ||
from bs4 import BeautifulSoup | ||
from datetime import datetime | ||
|
||
header = '''# GENERATED FILE - DO NOT EDIT | ||
set -e | ||
|
@@ -306,10 +310,80 @@ def openqa_call_start_meta_variables(meta_variables): | |
def pre_openqa_call_start(repos): | ||
return '' | ||
|
||
# def pre_openqa_call_find_kernel_livepatch_versions(): | ||
# return f"($(grep -oP '(?<=kernel-livepatch-)\d+_\d+_\d+-\d+' \"/var/lib/openqa/factory/iso/${{iso}}\" | uniq))" | ||
def _find_latest_livepatches(url): | ||
""" | ||
Scrapes a URL to find all kernel-livepatch-* with the | ||
most recent date. | ||
""" | ||
try: | ||
response = requests.get(url) | ||
response.raise_for_status() | ||
except requests.exceptions.RequestException as e: | ||
print(f"Error fetching URL: {e}") | ||
return [] | ||
|
||
soup = BeautifulSoup(response.text, 'html.parser') | ||
|
||
livepatches_unfiltered = [] | ||
latest_date = None | ||
lp_regex = r'kernel-livepatch-((?:\d+_?)+-\d+)' | ||
#pdb.set_trace() | ||
for row in soup.find_all('tr'): | ||
elem = row.find_all('td') | ||
if len(elem) < 2: | ||
continue | ||
|
||
link = elem[0].find('a') | ||
if (link and link.text.startswith('kernel-livepatch-')): | ||
#and '-rt' in link.text): | ||
#pdb.set_trace() | ||
date_str = elem[1].text.strip().split()[0] | ||
try: | ||
current_date = datetime.strptime(date_str, '%d-%b-%Y') | ||
livepatches_unfiltered.append({'name': link.text, 'date': current_date}) | ||
|
||
if latest_date is None or current_date > latest_date: | ||
latest_date = current_date | ||
except ValueError: | ||
continue | ||
|
||
if latest_date is None: | ||
return [] | ||
# to list only the recent ones | ||
latest_patches_list = [] | ||
for patch in livepatches_unfiltered: | ||
if patch['date'] == latest_date: | ||
kernel_version = re.search(lp_regex, patch['name']) | ||
latest_patches_list.append(kernel_version.group(1)) | ||
|
||
return latest_patches_list | ||
|
||
def openqa_fetch_livepatch_list(): | ||
kpatches = {} | ||
for arch in ['x86_64','aarch64','s390x','ppc64le']: | ||
totest_url = f"https://download.suse.de/ibs/SUSE:/ALP:/Products:/Marble:/6.0:/ToTest/product/repo/SL-Micro-6.0-{arch}/{arch}/" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can append |
||
|
||
latest_kernel_livepatches = _find_latest_livepatches(totest_url) | ||
|
||
if latest_kernel_livepatches: | ||
for livepatch in latest_kernel_livepatches: | ||
kpatches.update({arch: latest_kernel_livepatches}) | ||
return kpatches | ||
|
||
#openqa_livepatches = lambda arch: ' '.join(openqa_fetch_livepatch_list().get(arch, [])) or 'NONE' | ||
openqa_livepatches = { | ||
f"{arch}:{' '.join(versions)}" | ||
for arch, versions in openqa_fetch_livepatch_list().items() | ||
if versions | ||
}; | ||
openqa_call_start = lambda distri, version, archs, staging, news, news_archs, flavor_distri, meta_variables, assets_flavor, repo0folder, openqa_cli: ''' | ||
archs=(ARCHITECTURS) | ||
[ ! -f __envsub/files_repo.lst ] || ! grep -q -- "-POOL-" __envsub/files_repo.lst || additional_repo_suffix=-POOL | ||
|
||
declare -a livepatches | ||
livepatches=(NONE) | ||
livepatches_all="''' + str(openqa_livepatches) + '''" | ||
for flavor in {FLAVORALIASLIST,}; do | ||
for arch in "${archs[@]}"; do | ||
filter=$flavor | ||
|
@@ -326,6 +400,10 @@ def pre_openqa_call_start(repos): | |
[ -n "$iso" ] || [ "$flavor" != "''' + assets_flavor + r'''" ] || buildex=$(grep -o -E '(Build|Snapshot)[^-]*' __envsub/files_asset.lst | head -n 1) | ||
[ -n "$iso$build" ] || build=$(grep -h -o -E '(Build|Snapshot)[^-]*' __envsub/Media1*.lst 2>/dev/null | head -n 1 | grep -o -E '[0-9]\.?[0-9]+(\.[0-9]+)*')|| : | ||
[ -n "$build" ] || continue | ||
livepatches=($(echo "$livepatches_all" | sed "s/[{}']//g" | sed 's/, /\n/g' | awk -F':' -v arch="$arch" '$1 == arch {print $2}')) | ||
if [ ${#livepatches[@]} -eq 0 ]; then | ||
livepatches=(NONE) | ||
fi | ||
buildex=${buildex/.install.iso/} | ||
buildex=${buildex/.iso/} | ||
buildex=${buildex/.raw.xz/} | ||
|
@@ -342,7 +420,12 @@ def pre_openqa_call_start(repos): | |
} | ||
fi | ||
# test "$destiso" != "" || continue | ||
for livepatch in "${livepatches[@]}"; do | ||
echo "''' + openqa_cli + ''' \\\\\" | ||
if [[ "${livepatch}" != "NONE" ]]; then | ||
echo \" KGRAFT=1 \\\\ | ||
KERNEL_VERSION=${livepatch} \\\\\" | ||
fi | ||
( | ||
echo \" DISTRI=$distri \\\\ | ||
ARCH=$arch \\\\ | ||
|
@@ -583,6 +666,7 @@ def openqa_call_end(version): | |
echo " FLAVOR=${flavor//Tumbleweed-/} \\\\" | ||
) | LANG=C.UTF-8 sort | ||
echo "" | ||
done | ||
done | ||
done | ||
''' | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would probably make sense to be able to execute this standalone (in the absence of unit tests, so it can at least be tested easily manually).