Skip to content
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# DO NOT EDIT; this file is auto-generated using https://github.com/openshift/ci-tools.
# Fetched from https://github.com/rh-ecosystem-edge/assisted-chat root OWNERS
# If the repo had OWNERS_ALIASES then the aliases were expanded
# Logins who are not members of 'openshift' organization were filtered out
# See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md

approvers:
- carbonin
- eranco74
- jhernand
- omertuc
options: {}
reviewers:
- carbonin
- eranco74
- jhernand
- omertuc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

set -o nounset
set -o errexit
set -o pipefail

OC_URL="https://api.stage.openshift.com/api/assisted-install/v2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this is called OC_URL, it's the assisted service url...


n=4 # number of hours to subtract
current_time=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
past_time=$(date -u -d "$current_time -$n hours" +"%Y-%m-%dT%H:%M")

echo "Current UTC time: $current_time"
echo "Time $n hours ago (UTC): $past_time"

if ! command -v ocm >/dev/null 2>&1; then \
mkdir -p "${HOME}/.local/bin" && \
curl -sSL -o "${HOME}/.local/bin/ocm" "https://github.com/openshift-online/ocm-cli/releases/latest/download/ocm-linux-amd64" && \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use the API directly (curl) with the secret and id elsewhere, right? Let's just do the same here and not have to download this binary.

chmod +x "${HOME}/.local/bin/ocm"; \
export PATH="${HOME}/.local/bin:${PATH}"
fi

ocm login --client-id "$(cat /var/run/secrets/sso-ci/client_id)" \
--client-secret "$(cat /var/run/secrets/sso-ci/client_secret)" \
--url "${OC_URL}"

curl -H "Authorization: Bearer $(ocm token)" "${OC_URL}/clusters" > ${ARTIFACT_DIR}/available_clusters.json
cat ${ARTIFACT_DIR}/available_clusters.json | jq '[.[] |{id, name, created_at}]' > ${ARTIFACT_DIR}/relevant_cluster_data.json
cat ${ARTIFACT_DIR}/relevant_cluster_data.json | jq -r ".[] | select(.created_at < \"${past_time}\") | .id" > ${ARTIFACT_DIR}/clusters_to_delete
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we don't expect to have too many of these, right? Maybe 100 at most?
Seems like we could do something a bit more well defined (that doesn't rely on string comparing dates) if we first convert the date we're interested in and created_at to unix timestamps then compare those.


cat ${ARTIFACT_DIR}/clusters_to_delete | xargs -I@ curl -X DELETE -H "Authorization: Bearer $(ocm token)" "${OC_URL}/clusters/@"
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"path": "rh-ecosystem-edge/assisted-chat/clean-up/rh-ecosystem-edge-assisted-chat-clean-up-ref.yaml",
"owners": {
"approvers": [
"carbonin",
"eranco74",
"jhernand",
"omertuc"
],
"reviewers": [
"carbonin",
"eranco74",
"jhernand",
"omertuc"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ref:
as: rh-ecosystem-edge-assisted-chat-clean-up
from: src
cli: latest
timeout: 0h30m0s
commands: rh-ecosystem-edge-assisted-chat-clean-up-commands.sh
credentials:
- namespace: test-credentials
name: assisted-chat-sso-ci
mount_path: /var/run/secrets/sso-ci
resources:
requests:
cpu: 1000m
memory: 500Mi
documentation: |-
Run the evaluation tests
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ workflow:
test:
- ref: rh-ecosystem-edge-assisted-chat-test
post:
- ref: rh-ecosystem-edge-assisted-chat-clean-up
- chain: gather
documentation: |-
Install assisted-chat with all it's dependencies