#1223 Fix/improve the release-candidate script.
Opened 6 months ago by patrikp. Modified 21 days ago
patrikp/pungi-fedora release_candidate  into  main

file modified
+178 -37
@@ -1,50 +1,107 @@ 

  #!/bin/sh

+ # This script is used to generate Beta and Final release candidate composes.

+ # Relevant SOPs:

+ # Beta RC: https://docs.fedoraproject.org/en-US/infra/release_guide/beta_RC_compose/

+ # Final RC: https://docs.fedoraproject.org/en-US/infra/release_guide/final_RC_compose/

+ # It can be run in dry mode by adding the -d option.

+ # The -d option is a POSITIONAL argument and must be added AFTER the label.

+ # Example usage: `./release-candidate.sh 39_Beta-1.3 -d`

  export LC_ALL=C

- # Remove the label from arguments. It gets special treatment. Other arguments

- # to the script are passed to pungi-koji directly.

+ # Remove the label from arguments. It gets special treatment.

+ # Other arguments to the script are passed to `pungi-koji` directly.

  LABEL=$1

  shift

- CONFIG="fedora-final.conf"

+ 

+ # Find out which config file to use based on the label.

+ if [[ "$LABEL" = *"Beta"* ]]; then

+     CONFIG="fedora-beta.conf"

+     echo "========================================"

+     echo "CONFIG: $CONFIG"

+     echo ""

+ elif [[ "$LABEL" = *"RC"* ]]; then

+     CONFIG="fedora-final.conf"

+     echo "========================================"

+     echo "CONFIG: $CONFIG"

+     echo ""

+ else

+     echo "ERROR: Invalid label."

+     exit 1

+ fi

+ 

+ # Extract the Fedora version from the label. Example label: 39_RC-1.1

  FEDORA_VERSION="${LABEL%%_*}"

  TARGET_DIR="/mnt/koji/compose/${FEDORA_VERSION}"

- #OLD_COMPOSES_DIR="--old-composes=/mnt/fedora_koji/compose/f23 --old-composes=${TARGET_DIR}"

+ # OLD_COMPOSES_DIR="--old-composes=/mnt/fedora_koji/compose/f23 --old-composes=${TARGET_DIR}"

  NIGHTLY=""

  SKIP_PHASES="--skip-phase=productimg"

- DEST=$(pwd)

+ # DEST=$(pwd)

  DATE=$(date "+%Y%m%d")

- COMPSFILE="comps-f39.xml"

+ # Comps file nomenclature example: comps-f39.xml

+ # COMPSFILE="comps-f${FEDORA_VERSION}.xml"

  TMPDIR=$(mktemp -d /tmp/fedoraRC."${DATE}".XXXX)

- RELEASE="f39"

+ RELEASE="f${FEDORA_VERSION}"

  SHORT="Fedora"

  RSYNCPREFIX="sudo -u ftpsync"

  RSYNCTARGET="/pub/alt/stage/${LABEL}"

  # Uncomment and edit for resuming a failed compose, e.g. "COMPOSE_ID="Fedora-23-20150530.n.0"

  # COMPOSE_ID="Fedora-23-20150530.n.0"

  

- # Set up our fedora messaging function, using the releng repo definition

+ # Find out if the dry run (-d) option was invoked.

+ DRY_RUN=false

+ while getopts 'd' opt; do

+     case "$opt" in

+         d) DRY_RUN=true ;;

+         *) echo "Error in command line parsing." >&2

+            exit 1

+     esac

+ done

+ 

+ if "$DRY_RUN"; then

+     printf "THIS IS A DRY RUN.\n\n"

+     CMD_PREFIX="echo"

+ else

+     printf "THIS IS NOT A DRY RUN.\n\n"

+     CMD_PREFIX=''

+ fi

+ 

+ echo "========================================"

+ echo "ASSUME THAT THE RELENG REPOSITORY IS AVAILABLE AND REBASE. CLONE IT IF IT'S NOT."

+ echo ""

+ if [ -d releng ]; then

+     $CMD_PREFIX pushd releng

+     $CMD_PREFIX git pull --rebase

+     $CMD_PREFIX popd

+     echo ""

+ else

+     $CMD_PREFIX git clone https://pagure.io/releng.git

+     echo ""

+ fi

+ 

+ # Set up our fedora-messaging function using the releng repository definition.

+ # https://pagure.io/releng/blob/main/f/scripts/fedora-messaging.sh

  FEDMSG_MODNAME="compose"

  FEDMSG_CERTPREFIX="releng"

  . ./releng/scripts/fedora-messaging.sh

  

- # Announce that we are starting, even though we don't know the compose_id yet..

- fedora_message_json_start=$(printf '{"log": "start", "branch": "%s", "arch": "%s", "short": "%s"}' "$RELEASE" "$ARCH" "$SHORT")

- send_fedora_message "${fedora_message_json_start}" ${RELEASE} start

+ echo "========================================"

+ echo "ANNOUNCE THAT WE ARE STARTING (EVEN THOUGH THE COMPOSE_ID IS NOT YET KNOWN)."

+ echo ""

  

- # Public URL the synced compose will wind up at, we put them in fedora-messaging

- LOCATION="https://dl.fedoraproject.org$RSYNCTARGET"

+ fedora_message_json_start=$(printf '{"log": "start", "branch": "%s", "short": "%s"}' \

+                                    "$RELEASE" "$SHORT")

+ $CMD_PREFIX send_fedora_message "${fedora_message_json_start} ${RELEASE} start"

+ echo ""

  

- # Update fedora_message template

- fedora_message_json_start=$(printf '{"log": "start", "branch": "%s", "arch": "%s", "short": "%s", "compose_id": "%s", "location"}' "$RELEASE" "$ARCH" "$SHORT" "$LOCATION")

- fedora_message_json_done=$(printf '{"log": "done", "branch": "%s", "arch": "%s", "short": "%s", "location": "%s"}' "$RELEASE" "$ARCH" "$SHORT" "$LOCATION")

- 

- pushd "${TMPDIR}"

- git clone https://pagure.io/fedora-comps.git && {

-     pushd fedora-comps

-     make "${COMPSFILE}"

-     cp "${COMPSFILE}" "${DEST}"/

-     popd

- }

- popd

+ # The `pungi-koji` script checks out the fedora-comps repository so this can be removed (commented out for now).

+ #pushd "${TMPDIR}"

+ #git clone https://pagure.io/fedora-comps.git && {

+ #    pushd fedora-comps

+ #    make "${COMPSFILE}"

+ #    cp "${COMPSFILE}" "${DEST}"/

+ #    popd

+ #}

+ #popd

+ #echo ""

  

  CMD="pungi-koji --notification-script=/usr/bin/pungi-fedmsg-notification \

      --notification-script=pungi-wait-for-signed-ostree-handler \
@@ -52,25 +109,109 @@ 

      --label=${LABEL}"

  

  if [ -z "${COMPOSE_ID}" ]; then

-     CMD="${CMD} --target-dir=${TARGET_DIR}"

+     CMD="${CMD_PREFIX} ${CMD} --target-dir=${TARGET_DIR}"

+ else

+     CMD="${CMD_PREFIX} ${CMD} --debug-mode --compose-dir=${TARGET_DIR}/${COMPOSE_ID}"

+ fi

+ 

+ echo "========================================"

+ echo "RUN THE COMPOSE. EXIT IF THE EXIT STATUS IS NOT ZERO."

+ echo ""

+ 

+ if ! time ${CMD}; then

+     echo "ERROR: Command failed with a non-zero exit status."

+     "$CMD_PREFIX" exit 1

+     echo ""

+ fi

+ echo ""

+ 

+ # Check if the compose ID exists and exit if it does not.

+ if [ ! -f "${TARGET_DIR}"/latest-$SHORT-"${FEDORA_VERSION}"/COMPOSE_ID ]; then

+     echo "ERROR: No compose ID available."

+     "$CMD_PREFIX" exit 1

+     echo ""

+ fi

+ 

+ # Get the compose ID if it exists, exit if it does not.

+ # Note: The COMPOSE_ID variable is used for debugging purposes so another variable with the same value is needed.

+ if [ -e "${TARGET_DIR}"/latest-$SHORT-"${FEDORA_VERSION}"/COMPOSE_ID ]; then

+     COMPOSE_ID_2=$(cat "${TARGET_DIR}"/latest-$SHORT-"${FEDORA_VERSION}"/COMPOSE_ID)

+ else

+     echo "ERROR: Compose ID not found."

+     "$CMD_PREFIX" exit 1

+     echo ""

+ fi

+ 

+ # Check if the compose STATUS exists and exit if it does not.

+ if [ ! -f "/mnt/koji/compose/${FEDORA_VERSION}/${COMPOSE_ID_2}/STATUS" ]; then

+     echo "ERROR: No compose STATUS available."

+     "$CMD_PREFIX" exit 1

+     echo ""

+ fi

+ 

+ # Find out what the status of the compose is. Do not proceed if the status is DOOMED.

+ COMPOSE_STATUS=$(cat "/mnt/koji/compose/${FEDORA_VERSION}/${COMPOSE_ID_2}/STATUS")

+ echo "========================================"

+ echo "COMPOSE DETAILS"

+ echo "Compose ID: ${COMPOSE_ID_2}"

+ echo "Compose status: ${COMPOSE_STATUS}"

+ if [ "$COMPOSE_STATUS" = "DOOMED" ]; then

+     echo "ERROR: The compose status is DOOMED."

+     "$CMD_PREFIX" exit 1

+     echo ""

  else

-     CMD="${CMD} --debug-mode --compose-dir=${TARGET_DIR}/${COMPOSE_ID}"

+     echo "Proceeding to rsync."

+     echo ""

  fi

  

- time "$CMD" "$@"

+ # Update the fedora_message template.

+ fedora_message_json_start=$(printf '{"log": "start", "branch": "%s", "short": "%s", "compose_id": "%s"}' \

+                                    "$RELEASE" "$SHORT" "$COMPOSE_ID_2")

+ fedora_message_json_done=$(printf '{"log": "done", "branch": "%s", "short": "%s", "compose_id": "%s"}' \

+                                   "$RELEASE" "$SHORT" "$COMPOSE_ID_2")

  

- # Tell interested persons that the rsync is starting

- send_fedora_message "${fedora_message_json_start}" ${RELEASE} rsync.start

+ echo "========================================"

+ echo "LET INTERESTED PERSONS KNOW ABOUT THE COMPOSE."

+ echo ""

+ $CMD_PREFIX send_fedora_message "${fedora_message_json_done} ${RELEASE} complete"

+ echo ""

  

+ echo "========================================"

+ echo "TELL INTERESTED PERSONS THAT THE RSYNC IS STARTING."

+ echo ""

+ $CMD_PREFIX send_fedora_message "${fedora_message_json_start} ${RELEASE} rsync.start"

+ echo ""

+ 

+ echo "========================================"

+ echo "CREATE THE DIRECTORY TARGETED FOR THE COPY (IF IT DOESN'T EXIST)."

+ echo ""

  if [ ! -d "${RSYNCTARGET}" ]; then

-     $(RSYNCPREFIX) mkdir -m 750 -p "${RSYNCTARGET}"

+     "${CMD_PREFIX}" "${RSYNCPREFIX}" mkdir -m 750 -p "${RSYNCTARGET}"

  fi

+ echo ""

+ 

+ echo "========================================"

+ echo "RUN THE SYNCHRONIZATION."

+ echo ""

+ ARTIFACTS="Everything Cloud Container Kinoite Labs Server Silverblue Spins \

+            Workstation Onyx Sericea metadata"

  

- # Note from documentation:

- # If multiple composes are run like 1.2, 1.3, add multiple --link-dest arguments above with multiple composes

- ${RSYNCPREFIX} sh -c 'for dir in Everything Cloud Container Kinoite Labs Modular Server Silverblue Spins Workstation Onyx Sericea metadata; do rsync -avhH ${TARGET_DIR}/${COMPOSE_ID}/compose/$dir/ ${RSYNCTARGET}/$dir/ --link-dest=/pub/fedora/linux/development/${FEDORA_VERSION}/Everything/ --link-dest=${RSYNCTARGET}/Everything/; done'

+ for dir in ${ARTIFACTS}; do

+     ${CMD_PREFIX} "${RSYNCPREFIX} sh -c rsync -avhH ${TARGET_DIR}/${COMPOSE_ID_2}/compose/$dir/ \

+ ${RSYNCTARGET}/$dir/ --link-dest=/pub/fedora/linux/development/${FEDORA_VERSION}/Everything/ \

+ --link-dest=${RSYNCTARGET}/Everything"

+ done

+ echo ""

  

- ${RSYNCPREFIX} chmod 755 "${RSYNCTARGET}"

+ echo "========================================"

+ echo "SET THE PERMISSIONS OF THE SYNCED COMPOSE."

+ echo ""

+ if [ -d "${RSYNCTARGET}" ]; then

+     "${CMD_PREFIX}" "${RSYNCPREFIX}" chmod 755 "${RSYNCTARGET}"

+ fi

+ echo ""

  

- # Let interested persons know the rsync is complete

- send_fedora_message "${fedora_message_json_done}" ${RELEASE} rsync.complete

+ echo "========================================"

+ echo "LET INTERESTED PERSONS KNOW THAT THE RSYNC IS COMPLETE."

+ echo ""

+ $CMD_PREFIX send_fedora_message "${fedora_message_json_done} ${RELEASE} rsync.complete"

rebased onto 3320b576ce87c942adfab52072d992150ea5330f

5 months ago

Can you create a corresponding PR to releng SOP docs? The new expected parameter with fedora version should be reflected in all compose SOP's using this script

rebased onto 76df5b5

2 months ago

looking much better! :)

Some minor comments:

  • What would you think about making it detect the config? right now it's hard coded (to fedora-final.conf right now). But if "Beta" appears in the label it should be fedora-beta.conf otherwise fedora-final.conf.

  • The dry-run / debugging '-d' is getting passed to commands, not that it matters, but minor nitpick. ie,

pungi-koji --notification-script=/usr/bin/pungi-fedmsg-notification --notification-script=pungi-wait
-for-signed-ostree-handler --config=fedora-final.conf --old-composes=/mnt/koji/compose/40 --skip-pha
se=productimg --label=40_Beta-1.1 --target-dir=/mnt/koji/compose/40 -d

(the -d at the end)

  • For compose id, might check that it exists and exit if not:

COMPOSE_ID_2=$(cat "${TARGET_DIR}"/latest-$SHORT-"${FEDORA_VERSION}"/COMPOSE_ID)

ie, check for that existing before setting it. It should if pungi finished ok, but just in case, we don't want to mess up with the syncs if something weird happened to the compose.

Aside those minor things I think it might be ready. :)

@patrikp, any updates on this? Do you have any blockers for this?

rebased onto 2c74789

a month ago

rebased onto db4dff2

a month ago

@kevin I updated the script based on your feedback. The three things should now be fixed.
CC: @jnsamyak

@patrikp, the changes look ok to me, did you get a chance to dry run and check things? I still see -d being used in the actual script, any specific reason for it? Also, Can you write a corresponding SOP, Or, at least mention in the comments on how once can run this, what are the things it expects to pass in arguments?

Sadly, we weren't able to test it this release cycle as well

Metadata