Skip to content

Commit

Permalink
Merge pull request #3111 from g7/slfo-staging-do-not-endless-wait
Browse files Browse the repository at this point in the history
slfo-stagings: add a timeout for Build.product, and do not run if repo is missing
  • Loading branch information
dirkmueller committed Jun 17, 2024
2 parents 0928376 + 41c61c3 commit 9b466e6
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 15 deletions.
77 changes: 66 additions & 11 deletions gocd/slfo-stagings.gocd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,18 @@ pipelines:
fi
- Build.product:
timeout: 180
resources:
- staging-bot
tasks:
- script: |-
osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=product&flag=build"
export PYTHONPATH=$PWD/scripts
while ! ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; do
while ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; ret=$?; [ ${ret} -ne 0 ]; do
if [ ${ret} -eq 2 ]; then
echo "product repository not found. Project configuration issue?" >&2
exit 1
fi
sleep 60
done
Expand Down Expand Up @@ -138,13 +143,18 @@ pipelines:
fi
- Build.product:
timeout: 180
resources:
- staging-bot
tasks:
- script: |-
osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=product&flag=build"
export PYTHONPATH=$PWD/scripts
while ! ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; do
while ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; ret=$?; [ ${ret} -ne 0 ]; do
if [ ${ret} -eq 2 ]; then
echo "product repository not found. Project configuration issue?" >&2
exit 1
fi
sleep 60
done
Expand Down Expand Up @@ -217,13 +227,18 @@ pipelines:
fi
- Build.product:
timeout: 180
resources:
- staging-bot
tasks:
- script: |-
osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=product&flag=build"
export PYTHONPATH=$PWD/scripts
while ! ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; do
while ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; ret=$?; [ ${ret} -ne 0 ]; do
if [ ${ret} -eq 2 ]; then
echo "product repository not found. Project configuration issue?" >&2
exit 1
fi
sleep 60
done
Expand Down Expand Up @@ -296,13 +311,18 @@ pipelines:
fi
- Build.product:
timeout: 180
resources:
- staging-bot
tasks:
- script: |-
osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=product&flag=build"
export PYTHONPATH=$PWD/scripts
while ! ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; do
while ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; ret=$?; [ ${ret} -ne 0 ]; do
if [ ${ret} -eq 2 ]; then
echo "product repository not found. Project configuration issue?" >&2
exit 1
fi
sleep 60
done
Expand Down Expand Up @@ -375,13 +395,18 @@ pipelines:
fi
- Build.product:
timeout: 180
resources:
- staging-bot
tasks:
- script: |-
osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=product&flag=build"
export PYTHONPATH=$PWD/scripts
while ! ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; do
while ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; ret=$?; [ ${ret} -ne 0 ]; do
if [ ${ret} -eq 2 ]; then
echo "product repository not found. Project configuration issue?" >&2
exit 1
fi
sleep 60
done
Expand Down Expand Up @@ -454,13 +479,18 @@ pipelines:
fi
- Build.product:
timeout: 180
resources:
- staging-bot
tasks:
- script: |-
osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=product&flag=build"
export PYTHONPATH=$PWD/scripts
while ! ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; do
while ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; ret=$?; [ ${ret} -ne 0 ]; do
if [ ${ret} -eq 2 ]; then
echo "product repository not found. Project configuration issue?" >&2
exit 1
fi
sleep 60
done
Expand Down Expand Up @@ -533,13 +563,18 @@ pipelines:
fi
- Build.product:
timeout: 180
resources:
- staging-bot
tasks:
- script: |-
osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=product&flag=build"
export PYTHONPATH=$PWD/scripts
while ! ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; do
while ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; ret=$?; [ ${ret} -ne 0 ]; do
if [ ${ret} -eq 2 ]; then
echo "product repository not found. Project configuration issue?" >&2
exit 1
fi
sleep 60
done
Expand Down Expand Up @@ -612,13 +647,18 @@ pipelines:
fi
- Build.product:
timeout: 180
resources:
- staging-bot
tasks:
- script: |-
osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=product&flag=build"
export PYTHONPATH=$PWD/scripts
while ! ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; do
while ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; ret=$?; [ ${ret} -ne 0 ]; do
if [ ${ret} -eq 2 ]; then
echo "product repository not found. Project configuration issue?" >&2
exit 1
fi
sleep 60
done
Expand Down Expand Up @@ -691,13 +731,18 @@ pipelines:
fi
- Build.product:
timeout: 180
resources:
- staging-bot
tasks:
- script: |-
osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=product&flag=build"
export PYTHONPATH=$PWD/scripts
while ! ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; do
while ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; ret=$?; [ ${ret} -ne 0 ]; do
if [ ${ret} -eq 2 ]; then
echo "product repository not found. Project configuration issue?" >&2
exit 1
fi
sleep 60
done
Expand Down Expand Up @@ -770,13 +815,18 @@ pipelines:
fi
- Build.product:
timeout: 180
resources:
- staging-bot
tasks:
- script: |-
osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=product&flag=build"
export PYTHONPATH=$PWD/scripts
while ! ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; do
while ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; ret=$?; [ ${ret} -ne 0 ]; do
if [ ${ret} -eq 2 ]; then
echo "product repository not found. Project configuration issue?" >&2
exit 1
fi
sleep 60
done
Expand Down Expand Up @@ -849,13 +899,18 @@ pipelines:
fi
- Build.product:
timeout: 180
resources:
- staging-bot
tasks:
- script: |-
osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=product&flag=build"
export PYTHONPATH=$PWD/scripts
while ! ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; do
while ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; ret=$?; [ ${ret} -ne 0 ]; do
if [ ${ret} -eq 2 ]; then
echo "product repository not found. Project configuration issue?" >&2
exit 1
fi
sleep 60
done
Expand Down
7 changes: 6 additions & 1 deletion gocd/slfo-stagings.gocd.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,18 @@ pipelines:
fi

- Build.product:
timeout: 180
resources:
- staging-bot
tasks:
- script: |-
osc -A $STAGING_API api -X POST "/source/$STAGING_PROJECT?cmd=remove_flag&repository=product&flag=build"
export PYTHONPATH=$PWD/scripts
while ! ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; do
while ./scripts/gocd/verify-repo-built-successful.py -A $STAGING_API -p $STAGING_PROJECT -r product; ret=$?; [ ${ret} -ne 0 ]; do
if [ ${ret} -eq 2 ]; then
echo "product repository not found. Project configuration issue?" >&2
exit 1
fi
sleep 60
done

Expand Down
14 changes: 11 additions & 3 deletions gocd/verify-repo-built-successful.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Check if all packages built fine')
parser.add_argument('--apiurl', '-A', type=str, help='API URL of OBS')
parser.add_argument('-p', '--project', type=str, help='Project to check')
parser.add_argument('-p', '--project', type=str, help='Project to check',
required=True)
parser.add_argument('-r', '--repository', type=str,
help='Repository to check')
help='Repository to check', required=True)

args = parser.parse_args()

Expand All @@ -26,7 +27,14 @@
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

# first check if repo is finished
# first check if repo is available
url = makeurl(apiurl, ['source', args.project, "_meta"])
root = ET.parse(http_GET(url)).getroot()
if not root.xpath(f'repository[@name="{args.repository}"]'):
logger.error(f'Repository {args.repository} is not available in {args.project}')
sys.exit(2)

# then check if repo is finished
archs = target_archs(apiurl, args.project, args.repository)
for arch in archs:
url = makeurl(apiurl, ['build', args.project, args.repository, arch], {'view': 'status'})
Expand Down

0 comments on commit 9b466e6

Please sign in to comment.