Bug 1374737

Summary: spacewalk-repo-sync python error
Product: [Community] Spacewalk Reporter: stoupsi <labonte.stephane>
Component: APIAssignee: Jan Dobes <jdobes>
Status: CLOSED EOL QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: high Docs Contact:
Priority: unspecified    
Version: 2.5CC: michal.walkiewicz, mmraka, wdh
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-06 13:35:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description stoupsi 2016-09-09 13:45:23 UTC
Description of problem:
I using spacewalk 2.5 on rhel7. For some redhat repos, we facing errors.

executing reposync for repos (ex: rhel-7-server-rpms,rhel-7-server-optional-rpms,rhel-7-server-extras-rpms,rhel-server-rhscl-7-rpms). After that a createrepo update (including all the metadata... and updateinfo.xml file) follow by /bin/spacewalk-repo-sync --channel ${swreponame} --type yum 

With some repos (epel,rhel-server-rhscl-7-rpms and rhel-7-server-extras-rpms) , it's suceed and no error during spacewalk-repo-sync execution. All informations (products, version, erratas...) are imported properly to spacewalk.

But on repo names rhel-7-server-optional-rpms and rhel-7-server-rpms, we facing python error. --->>>  
ERROR: invalid literal for int() with base 10: 'RHBA-2014:2014'
ERROR: invalid literal for int() with base 10: 'RHBA-2014:1871'

Version-Release number of selected component (if applicable):
spacewalk 2.5
rhel7.2


How reproducible:
execute the following commands
Steps to Reproduce:

1. /usr/bin/reposync --arch=x86_64 --repoid=rhel-7-server-rpms,rhel-7-server-optional-rpms --gpgcheck --downloadcomps --download-metadata --plugins --delete --download_path=/var/satellite/repo/

2. cp /var/satellite/repo/$REPONAME/comps.xml /var/satellite/repo/$REPONAME/Packages/
3. createrepo  --update -p --workers 2 -g /var/satellite/repo/$REPONAME/Packages/comps.xml /var/satellite/repo/$REPONAME
4.  #copy latest *-updateinfo.xml.gz 
4.1 cp /var/satellite/repo/$REPONAME/*-updateinfo.xml.gz /var/satellite/repo/$REPONAME/updateinfo.xml.gz
5. gunzip -df /var/satellite/repo/$REPONAME/updateinfo.xml.gz
6. modifyrepo /var/satellite/repo/$REPONAME/updateinfo.xml /var/satellite/repo/$REPONAME/repodata/
7. /bin/spacewalk-repo-sync --channel ${swreponame} --type yum #and yes my spacewalk channels and repositories are properly configured with correct path.

Actual results:
get the following errors during spacewalk reposync and no erratas are import in my spacewalk channel.
ERROR: invalid literal for int() with base 10: 'RHBA-2014:1871'
ERROR: invalid literal for int() with base 10: 'RHBA-2014:2014'
ERROR: invalid literal for int() with base 10: 'RHBA-2014:1871'


Expected results:
erratas properly publish into my spacewalk channel

Additional info:

Comment 1 stoupsi 2016-09-09 15:59:52 UTC
Probably the same issue than 1354496. Is it possible to adapt the python script of spacewalk-repo-sync command to validate and discards every erratas with errors?

8)

Comment 2 stoupsi 2016-09-09 19:03:35 UTC
Pretty sure is cause by some accent used in french "À" 

Fist of all, if you check the file format of the updateinfo.xml, they use utf-8. File of repo where it's working correctly are in ASCII.

I've try to convert from utf-8 to ascii, then BOOM!

Erreur append and I found the letters with accent "Ã" who is not compatible with the script python used for spacewalk reposync.

Comment 3 W. de Heiden 2016-09-22 11:48:53 UTC
Any news on this? I also hit this issue...:(

Comment 4 stoupsi 2016-09-22 11:58:12 UTC
(In reply to W. de Heiden from comment #3)
> Any news on this? I also hit this issue...:(

No news! But it's the same issue of 1354496.

What I did;
Scripting to eleminate the presente of bugzilla containing ALPHANUMERIC version ID. See section where I written "Correction des erratas bugzilla non-numerique ". 

Here's a section of my reposync and script


____________________________________


#!/bin/bash
# Createur: Stephane Labonte
# Outil de synchro des repos de RedHat
# Date de Creation: 2016-09-09
# Prerequis: yum-utils createrepo
# Utilite: Synchronisation des repositories RedHat et au channel de spacewalk

root_repo_dir="/var/satellite/repo/"
logfile="/var/log/pai_reposync.log"
arch="x86_64"
repoidnames="rhel-7-server-rpms,rhel-7-server-optional-rpms,rhel-7-server-extras-rpms,rhel-server-rhscl-7-rpms,spacewalk-client-rhel7,rhel7-epel,rhel-6-server-rpms,rhel-6-server-extras-rpms,rhel-6-server-optional-rpms,rhel-server-rhscl-6-rpms,spacewalk-client-rhel6,rhel6-epel"

echo "========================= DEBUT ================================"
echo "Debut de l'execution du script de synchronisation pai_reposync.sh"
echo "================================================================"
echo ""
echo "========================= DEBUT ================================"
echo "Synchro des repos ${repoidnames}"
echo "================================================================"
echo ""

/usr/bin/reposync --arch=${arch} --repoid=${repoidnames} --gpgcheck --newest-only --downloadcomps --download-metadata --plugins --delete --download_path=${root_repo_dir} # >> ${logfile} 2>&1

echo ""
echo "========================== FIN ================================="
echo "Synchro des repos ${repoidnames}"
echo "================================================================"
echo ""

for reponame in `echo "${repoidnames}" | sed 's/,/\ /g'`; do
        echo "================================================================"
        echo "Traitement et manipulation du repo: ${reponame}"
        echo "================================================================"
        echo ""

        if [ -f "${root_repo_dir}${reponame}/comps.xml" -a -d "$${root_repo_dir}${reponame}/Packages" ]; then
                echo "Copie du comps.xml dans ${root_repo_dir}${reponame}/Packages/ ."
                cp -f ${root_repo_dir}${reponame}/comps.xml ${root_repo_dir}${reponame}/Packages/ # >> ${logfile} 2>&1
                echo "MAJ du repo vers ${root_repo_dir}${reponame}/Packages/ et ayant un fichier comps.xml"
                createrepo  --update -p --workers 2 -g ${root_repo_dir}${reponame}/Packages/comps.xml ${root_repo_dir}${reponame} # >> ${logfile} 2>&1
        else
                echo "MAJ du repo vers ${root_repo_dir}${reponame} sans fichier comps.xml"
                createrepo  --update -p --workers 2 ${root_repo_dir}${reponame}/ >> ${logfile} # 2>&1
        fi

        set -o pipefail
        updateinfo=$(ls -1t  ${root_repo_dir}${reponame}/*-updateinfo.xml.gz 2>/dev/null | head -1 )

        if [[ -f $updateinfo  &&  $? -eq 0 ]]; then
                echo "MAJ des erratas du repo ${root_repo_dir}${reponame}" # >> # ${logfile} 2>&1
                \cp -f $updateinfo ${root_repo_dir}${reponame}/updateinfo.xml.gz #  >> ${logfile} 2>&1
                gunzip -df ${root_repo_dir}${reponame}/updateinfo.xml.gz #  >> ${logfile} 2>&1
                if ($( grep "type=\"bugzilla\" id=\"RH" ${root_repo_dir}${reponame}/updateinfo.xml >/dev/null )) ; then
                        #Correction de la presence de version en reference bugzilla qui ne serait pas numerique
                        #Ceci faisait planter l'importation des erratas dans spacewalk.
                        echo "Correction des erratas bugzilla non-numerique depuis ${root_repo_dir}${reponame}/updateinfo.xml"
                        sed 's/=\([0-9]*\)\(" type="bugzilla" id="\)RH[BS]A-[0-9]\{4\}:[0-9]\{4\}/=\1\2\1/' -i ${root_repo_dir}${reponame}/updateinfo.xml >/dev/null
                fi
                echo "Modification du repo ${root_repo_dir}${reponame}/updateinfo.xml vers repertoire repodata"
                modifyrepo ${root_repo_dir}${reponame}/updateinfo.xml ${root_repo_dir}${reponame}/repodata/ #  >> ${logfile} 2>&1
        else
                updateinfo=$(ls -1t  ${root_repo_dir}${reponame}/*-updateinfo.xml.bz2 2>/dev/null | head -1 )
                if [[ -f $updateinfo  &&  $? -eq 0 ]]; then
                        echo "MAJ des erratas du repo ${root_repo_dir}${reponame}" # >> ${logfile} 2>&1
                        \cp -f $updateinfo ${root_repo_dir}${reponame}/updateinfo.xml.bz2 #  >> ${logfile} 2>&1
                        bunzip2 -df ${root_repo_dir}${reponame}/updateinfo.xml.bz2 #  >> ${logfile} 2>&1
                        echo "Modification du repo ${root_repo_dir}${reponame}/updateinfo.xml vers repertoire repodata"
                        modifyrepo ${root_repo_dir}${reponame}/updateinfo.xml ${root_repo_dir}${reponame}/repodata/ #  >> ${logfile} 2>&1
                else
                        echo "Aucun errata pour ${root_repo_dir}${reponame}" # >> ${logfile} 2>&1
                fi
        fi

        # Synchro du repo de spacewalk portant le meme nom
        echo "Synchro des packages et erratas de ${swreponame} dans Spacewalk"
        /bin/spacewalk-repo-sync --channel ${reponame} --type yum # >> ${logfile} 2>&1
done
echo ""
echo "========================= FIN =================================="
echo "Fin de l'execution du script de synchronisation pai_reposync.sh "
echo "================================================================"

Comment 5 W. de Heiden 2016-09-26 12:37:43 UTC
MM, script does not work as expected....:

1 errata skipped because of empty package list.
ERROR: invalid literal for int() with base 10: 'RHSA-2014:1827'
Sync completed.
Total time: 0:04:17

========================= FIN ==================================
Fin de l'execution du script de synchronisation pai_reposync.sh
================================================================

Comment 6 stoupsi 2016-09-26 12:46:40 UTC
What is your reponame for witch you hit this error?

Also, be sure to configure properly your repository path from your spacewalk configuration. If you modify (modifyrepo) them, like I do in my script, your need to specify it in your url configuration properly.


(In reply to W. de Heiden from comment #5)
> MM, script does not work as expected....:
> 
> 1 errata skipped because of empty package list.
> ERROR: invalid literal for int() with base 10: 'RHSA-2014:1827'
> Sync completed.
> Total time: 0:04:17
> 
> ========================= FIN ==================================
> Fin de l'execution du script de synchronisation pai_reposync.sh
> ================================================================

Comment 7 Michael Mráka 2020-03-06 13:35:56 UTC
Spacewalk 2.8 (and older) has already reached it's End Of Life.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before end of life. If you would still like
to see this bug fixed and are able to reproduce it against current version
of Spacewalk 2.9, you are encouraged change the 'version' and re-open it.