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

Upmerge to edge #1864

Merged
merged 10 commits into from
Oct 9, 2024
23 changes: 21 additions & 2 deletions .github/scripts/install-radius.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

set -xe

# VERSION is the version of the rad CLI to download
# e.g. 0.1, 0.1.0, 0.1.0-rc1, edge
VERSION=$1
RAD_CLI_URL=https://raw.githubusercontent.com/radius-project/radius/main/deploy/install.sh
RAD_CLI_EDGE_URL=ghcr.io/radius-project/rad/linux-amd64:latest
Expand All @@ -26,8 +28,25 @@ if [[ $VERSION == "edge" ]]; then
chmod +x ./rad
mv ./rad /usr/local/bin/rad
elif [[ -n $VERSION ]]; then
echo Downloading rad CLI version $VERSION
wget -q $RAD_CLI_URL -O - | /bin/bash -s $VERSION
RADIUS_VERSION=$VERSION
# if version is a channel, e.g. 0.1
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then
echo "Querying the most recent version of the specified channel: $VERSION"
RADIUS_VERSION=$(curl -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/radius-project/radius/releases | jq -r '.[] | .tag_name | select(startswith("v'$VERSION'"))' | head -n 1)
echo "Found version $RADIUS_VERSION"
if [[ -z "$RADIUS_VERSION" ]]; then
echo "No releases found for channel $VERSION"
exit 1
fi
else
echo "The string does not match the pattern [anynumber].[anynumber]"
fi

# remove the 'v' prefix
RADIUS_VERSION=$(echo $RADIUS_VERSION | cut -d "v" -f 2)

echo Downloading rad CLI version $RADIUS_VERSION
wget -q $RAD_CLI_URL -O - | /bin/bash -s $RADIUS_VERSION
else
echo Downloading latest rad CLI
wget -q $RAD_CLI_URL -O - | /bin/bash
Expand Down
34 changes: 26 additions & 8 deletions .github/scripts/purge-aws-eks-clusters.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#!/bin/bash

set -ex

# Current time in seconds since epoch
current_time=$(date +%s)

Expand All @@ -24,15 +26,31 @@ age_limit=$((6 * 3600))

echo "Starting cluster purge script."

# List clusters and their creation times, filter and delete those older than 6 hours and starting with 'eks-samplestest-'
aws eks list-clusters --query "clusters[]" --output text | xargs -I {} aws eks describe-cluster --name {} --query "cluster.{name: name, createdAt: createdAt}" --output text | while read -r created_at name; do
# Convert creation time to seconds since the epoch
# Remove milliseconds and adjust timezone format from "-07:00" to "-0700"
formatted_created_at="${created_at%.*}${created_at##*.}"
formatted_created_at="${formatted_created_at%:*}${formatted_created_at##*:}"
# List clusters
clusters=$(aws eks list-clusters --query "clusters[]" --output text)

# Loop through each cluster
for cluster in $clusters; do
# Get the creation time and name of the cluster
cluster_info=$(aws eks describe-cluster --name "$cluster" --query "cluster.{name: name, createdAt: createdAt}" --output text)
created_at=$(echo "$cluster_info" | awk '{print $1}')
name=$(echo "$cluster_info" | awk '{print $2}')

# Ensure created_at is in the correct format
created_at=$(echo "$created_at" | sed 's/\.[0-9]*Z//')

# Convert creation time to seconds
created_at_seconds=$(date -d "$formatted_created_at" +%s)
# Convert creation time to seconds since the epoch using date
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
if ! command -v gdate &> /dev/null; then
echo "gdate could not be found. Please install coreutils: brew install coreutils"
exit 1
fi
created_at_seconds=$(gdate -d "$created_at" +%s)
else
# Linux
created_at_seconds=$(date -d "$created_at" +%s)
fi

# Calculate age in seconds
age=$((current_time - created_at_seconds))
Expand Down
6 changes: 3 additions & 3 deletions bicepconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"dynamicTypeLoading": true
},
"extensions": {
"radius": "br:biceptypes.azurecr.io/radius:latest",
"aws": "br:biceptypes.azurecr.io/aws:latest"
"radius": "br:biceptypes.azurecr.io/radius:0.38",
"aws": "br:biceptypes.azurecr.io/aws:0.38"
},
"cloud": {
"credentialPrecedence": [ "Environment" ]
}
}
}
Loading
Loading