Skip to content

Commit

Permalink
Enable ClusterPool filtering for ClusterClaims
Browse files Browse the repository at this point in the history
Signed-off-by: Dale Haiducek <19750917+dhaiducek@users.noreply.github.com>
  • Loading branch information
dhaiducek committed May 22, 2024
1 parent a744b48 commit 4a95c19
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ log() {
}

checkoutCluster() {
cluster_claim=""
cluster_type=${1}
cluster_idx=${2}
tmp_claim="${cluster_type}-${cluster_idx}-$suffix"
for pool in $pools; do
local cluster_type="${1}"
local cluster_idx="${2}"
local pool_filter="${3}"

local cluster_claim=""
local tmp_claim="${cluster_type}-${cluster_idx}-$suffix"
local filtered_pools=""
filtered_pools="$(echo "${pools}" | grep -e "${pool_filter}")"

for pool in ${filtered_pools}; do
log "Provisioning claim ${tmp_claim} from ClusterPool ${pool} ..."
make clusterpool/checkout \
CLUSTERPOOL_NAME=${pool} \
Expand All @@ -27,7 +32,7 @@ checkoutCluster() {

if [[ -z "${cluster_claim}" ]]; then
log "No cluster was checked out for ${cluster_type} ${cluster_idx}. Tried these cluster pools:"
echo "${pools}"
echo "${filtered_pools}"
return 1
fi

Expand Down Expand Up @@ -58,18 +63,24 @@ suffix=$(cat /dev/urandom | tr -dc "a-z0-9" | head -c 5)

# Checkout hub clusters
log "Provisioning ${CLUSTERPOOL_HUB_COUNT} hub clusters ..."
if [[ -n "${CLUSTERPOOL_HUB_FILTER}" ]]; then
log "Filtering ClusterPool list using filter: '${CLUSTERPOOL_HUB_FILTER}' ..."
fi

for ((i = 1; i <= CLUSTERPOOL_HUB_COUNT; i++)); do
checkoutCluster hub $i &
checkoutCluster hub ${i} "${CLUSTERPOOL_HUB_FILTER}" &
pids+=($!)
sleep 60
done

# Checkout managed clusters
log "Provisioning ${CLUSTERPOOL_MANAGED_COUNT} managed clusters ..."
if [[ -n "${CLUSTERPOOL_MANAGED_FILTER}" ]]; then
log "Filtering ClusterPool list using filter: '${CLUSTERPOOL_MANAGED_FILTER}' ..."
fi

for ((i = 1; i <= CLUSTERPOOL_MANAGED_COUNT; i++)); do
checkoutCluster managed $i &
checkoutCluster managed ${i} "${CLUSTERPOOL_MANAGED_FILTER}" &
pids+=($!)
sleep 60
done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@ ref:
cpu: 100m
memory: 100Mi
credentials:
- namespace: test-credentials
name: acm-cicd-clusterpool-shared
mount_path: /etc/acm-cicd-clusterpool-shared
- namespace: test-credentials
name: ocm-obs-usa-clusterpool
mount_path: /etc/ocm-obs-usa-clusterpool
- namespace: test-credentials
name: ocm-obs-china-clusterpool
mount_path: /etc/ocm-obs-china-clusterpool
- namespace: test-credentials
name: ocm-console-clusterpool
mount_path: /etc/ocm-console-clusterpool
- namespace: test-credentials
name: ocm-grc-clusterpool
mount_path: /etc/ocm-grc-clusterpool
- namespace: test-credentials
name: ocm-mgdsvcs-clusterpool
mount_path: /etc/ocm-mgdsvcs-clusterpool
- namespace: test-credentials
name: ocm-hub-of-hubs-clusterpool
mount_path: /etc/ocm-hub-of-hubs-clusterpool
- namespace: test-credentials
name: ocm-app-clusterpool
mount_path: /etc/ocm-app-clusterpool
- namespace: test-credentials
name: ocm-sf-clusterpool
mount_path: /etc/ocm-sf-clusterpool
- namespace: test-credentials
name: acm-cicd-clusterpool-shared
mount_path: /etc/acm-cicd-clusterpool-shared
- namespace: test-credentials
name: ocm-obs-usa-clusterpool
mount_path: /etc/ocm-obs-usa-clusterpool
- namespace: test-credentials
name: ocm-obs-china-clusterpool
mount_path: /etc/ocm-obs-china-clusterpool
- namespace: test-credentials
name: ocm-console-clusterpool
mount_path: /etc/ocm-console-clusterpool
- namespace: test-credentials
name: ocm-grc-clusterpool
mount_path: /etc/ocm-grc-clusterpool
- namespace: test-credentials
name: ocm-mgdsvcs-clusterpool
mount_path: /etc/ocm-mgdsvcs-clusterpool
- namespace: test-credentials
name: ocm-hub-of-hubs-clusterpool
mount_path: /etc/ocm-hub-of-hubs-clusterpool
- namespace: test-credentials
name: ocm-app-clusterpool
mount_path: /etc/ocm-app-clusterpool
- namespace: test-credentials
name: ocm-sf-clusterpool
mount_path: /etc/ocm-sf-clusterpool
env:
- name: MAKEFILE
default: "/opt/build-harness/Makefile.prow"
Expand Down Expand Up @@ -76,10 +76,22 @@ ref:
default: "1"
documentation: |-
The number of hub clusters to checkout.
- name: CLUSTERPOOL_HUB_FILTER
default: ""
documentation: |-
A filter used by grep to select a set of cluster pools to use when
checking out hub clusters. If the filter is empty, all cluster pools
from the list results will be used.
- name: CLUSTERPOOL_MANAGED_COUNT
default: "0"
documentation: |-
The number of managed clusters to checkout.
- name: CLUSTERPOOL_MANAGED_FILTER
default: ""
documentation: |-
A filter used by grep to select a set of cluster pools to use when
checking out managed clusters. If the filter is empty, all cluster
pools from the list results will be used.
- name: CLUSTER_CLAIM_FILE
default: "cluster-claims"
documentation: |-
Expand Down

0 comments on commit 4a95c19

Please sign in to comment.