Skip to content
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

Added script which can be used to delete old RAS records. with README mention #278

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ A complete list of supported parameters for the `runs download` command is avail
This command will reset a running test in the Ecosystem that is either stuck in a timeout condition or looping, by requeing the test. Note: The reset command does not wait for the server to complete the act of resetting the test, but if the command succeeds, then the server has accepted the request to reset the test.


## Example
### Example

The run "C1234" can be reset using the following command:

Expand All @@ -434,14 +434,25 @@ If after running `runs reset` the test is still not able to run through successf

This command will cancel a running test in the Ecosystem. It will not delete any information that is already stored in the RAS about the test, it will only cancel the execution of the test. Note: The cancel command does not wait for the server to complete the act of cancelling the test, but if the command succeeds, then the server has accepted the request to cancel the test.

## Example
### Example

The run "C1234" can be cancelled using the following command:

```
galasactl runs cancel --name C1234
```

## Runs delete
This command can delete test runs. Currently it can delete only one test run at a time.
But this command can be used in conjunction with the `galasactl runs get` command to first query the names of the runs you wish to delete, then delete them all.

### Example
```
galasactl runs delete --name C1234
```

Furthermore an example script demonstrates how old runs might be cleaned-out from your Result Archive Store (RAS), to reduce the size of the store and free up some space that can be used for more recent runs.
See [here](./test-scripts/runs-delete-too-old.sh)

## properties get
This command retrieves details of properties in a namespace.
Expand Down
59 changes: 59 additions & 0 deletions test-scripts/runs-delete-too-old.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#! /usr/bin/env bash

# Where is this script executing from ?
BASEDIR=$(dirname "$0");pushd $BASEDIR 2>&1 >> /dev/null ;BASEDIR=$(pwd);popd 2>&1 >> /dev/null
# echo "Running from directory ${BASEDIR}"
export ORIGINAL_DIR=$(pwd)
cd "${BASEDIR}"

#-----------------------------------------------------------------------------------------
#
# Set Colors
#
#-----------------------------------------------------------------------------------------
bold=$(tput bold)
underline=$(tput sgr 0 1)
reset=$(tput sgr0)
red=$(tput setaf 1)
green=$(tput setaf 76)
white=$(tput setaf 7)
tan=$(tput setaf 202)
blue=$(tput setaf 25)

#-----------------------------------------------------------------------------------------
#
# Headers and Logging
#
#-----------------------------------------------------------------------------------------
underline() { printf "${underline}${bold}%s${reset}\n" "$@" ;}
h1() { printf "\n${underline}${bold}${blue}%s${reset}\n" "$@" ;}
h2() { printf "\n${underline}${bold}${white}%s${reset}\n" "$@" ;}
debug() { printf "${white}%s${reset}\n" "$@" ;}
info() { printf "${white}➜ %s${reset}\n" "$@" ;}
success() { printf "${green}✔ %s${reset}\n" "$@" ;}
error() { printf "${red}✖ %s${reset}\n" "$@" ;}
warn() { printf "${tan}➜ %s${reset}\n" "$@" ;}
bold() { printf "${bold}%s${reset}\n" "$@" ;}
note() { printf "\n${underline}${bold}${blue}Note:${reset} ${blue}%s${reset}\n" "$@" ;}

h2 "Querying the RAS for old records we don't want any longer."
mkdir -p $BASEDIR/temp
cd $BASEDIR/temp >> /dev/null

set -o pipefail

galasactl runs get --age 120d:90d --format raw | cut -f1 -d'|' | sort | uniq > files-to-delete.txt
rc=$? ; if [[ "${rc}" != "0" ]]; then error "Failed to query the test runs to delete." ; exit 1 ; fi
success "Queried the run records we want to delete."

h2 "Deleting the run records we don't care about."
while IFS="" read -r line
do
testRunName="$line"
info "Deleting test run $testRunName"
galasactl runs delete --name $testRunName
rc=$? ; if [[ "${rc}" != "0" ]]; then error "Failed to delete the test runs $testRunName" ; exit 1 ; fi
success "Deleted test run $testRunName"
done < files-to-delete.txt

cd - >> /dev/null