Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
60467ee
Move POC rest impl. to quota plubins.
dmatch01 Dec 14, 2022
7c07738
Merge branch 'main' into quota-management
dmatch01 Jan 23, 2023
8948ab7
Initial checkin of new quota management.
dmatch01 Feb 8, 2023
7cd8090
Merged latest from main.
dmatch01 Feb 8, 2023
0378855
Partial update to e2e script to enable instatiate 2 differently confi…
dmatch01 Feb 8, 2023
5bc0778
Added kuttl installation to e2e test.
dmatch01 Feb 27, 2023
cbd3d75
Synced version file.
dmatch01 Feb 27, 2023
b13e19c
Modified kuttl installation to include sudo for commands.
dmatch01 Feb 27, 2023
bf63654
Added startup of MCAD with Quota Management enabled
dmatch01 Feb 27, 2023
1c78b03
Added kuttl test command to e2e testing.
dmatch01 Feb 27, 2023
ac23d9b
Provided an alternative to the travis_wait command.
dmatch01 Feb 27, 2023
2d41a5d
Added full e2e testing back.
dmatch01 Feb 27, 2023
2c69afa
Added explicit kuttl config file.
dmatch01 Feb 27, 2023
e92994a
Set e2e test to above if kuttl test fails.
dmatch01 Feb 28, 2023
d6a6bbd
Uptick of release number.
dmatch01 Feb 28, 2023
e7d6013
Fix syntax error.
dmatch01 Mar 1, 2023
98a4d0b
Merge branch 'main' into quota-management
dmatch01 Mar 1, 2023
8357cd5
Added creation of test namespace to kuttl testing steps.
dmatch01 Mar 1, 2023
7282c64
Test kuttl failure in Travis run.
dmatch01 Mar 1, 2023
499a7c2
Test fix to make e2e test failure in background mode.
dmatch01 Mar 1, 2023
f23f333
Test fix to make e2e test failure in background mode.
dmatch01 Mar 1, 2023
3b67951
Test fix to make e2e test kuttle success run in background mode.
dmatch01 Mar 1, 2023
f2930b1
Fix job names to match file names and increased timeout for preemptio…
dmatch01 Mar 1, 2023
5a38984
Increase kuttle timeout.
dmatch01 Mar 1, 2023
92e79e3
Test fix to make e2e test failure in background mode.
dmatch01 Mar 1, 2023
854a598
Test fix to make e2e test failure in background mode.
dmatch01 Mar 1, 2023
bf8af82
Test fix to make e2e test kuttle success run in background mode.
dmatch01 Mar 1, 2023
879c47e
Use different color code for e2e PID message.
dmatch01 Mar 1, 2023
1e969c8
Debugging kuttl failure.
dmatch01 Mar 1, 2023
42afea9
Rearrange setup of kuttl test for more stability of test.
dmatch01 Mar 1, 2023
293c8ad
Introduced forced error test to validate new Travis workaround for lo…
dmatch01 Mar 2, 2023
612b410
Force final failure test for e2e kuttl test.
dmatch01 Mar 2, 2023
140c13b
Removed forced failure for Travis testing.
dmatch01 Mar 2, 2023
07e57df
Added delay step 3 to give time for MCAD to process subtrees.
dmatch01 Mar 13, 2023
0eab6eb
Merged upstream changes.
dmatch01 Mar 24, 2023
a2e6e30
Updated QM test to use Helm3
dmatch01 Mar 24, 2023
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ before_script:
- export TEST_LOG_LEVEL=4

script:
# - make
- BLUE='\033[34m'
- make mcad-controller
- make run-test
# Process 'make images' when NOT a pull request
Expand All @@ -29,4 +29,11 @@ script:
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then unset quay_repository && make images; fi'
# Process 'make push-images' when NOT a pull request
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then make push-images; fi'
- travis_wait 80 make run-e2e
# Run the e2e and handle Travis condition where Travis fails on no output for 10 minutes. No output for 10 minutes
# is fine for our test cases that waits for 10 minutes before requeuing a job. The other workaround was to
# use 'travis_wait n' which unfortunately does not stream output until the very end so monitoring the Travis log
# during runtime is not possible.
- make run-e2e &
- PID=$! && echo -e "${BLUE}make run e2e pid=${PID}"
- while [ -e /proc/${PID} ]; do echo -n "." && sleep 30; done
- wait ${PID}
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ generate-code:
go build -o ${BIN_DIR}/deepcopy-gen ./cmd/deepcopy-gen/
$(info Generating deepcopy...)
${BIN_DIR}/deepcopy-gen -i ./pkg/apis/controller/v1beta1/ -O zz_generated.deepcopy
${BIN_DIR}/deepcopy-gen -i ./pkg/apis/quotaplugins/quotasubtree/v1 -O zz_generated.deepcopy

images: verify-tag-name
$(info List executable directory)
Expand Down
62 changes: 62 additions & 0 deletions config/crd/bases/ibm.com_quotasubtree-v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: quotasubtrees.ibm.com
finalizers: []
spec:
group: ibm.com
scope: Namespaced
names:
kind: QuotaSubtree
singular: quotasubtree
plural: quotasubtrees
shortNames:
- qst
versions:
- name: v1
served: true
storage: true
subresources:
status: {}
schema:
openAPIV3Schema:
type: object
properties:
status:
type: object
x-kubernetes-preserve-unknown-fields: true
spec:
type: object
properties:
parent:
type: string
parentNamespace:
type: string
children:
type: array
items:
type: object
properties:
name:
type: string
namespace:
type: string
quotas:
type: object
properties:
disabled:
type: boolean
hardLimit:
type: boolean
requests:
type: object
properties:
cpu:
x-kubernetes-int-or-string: true
pattern: '^[0-9]*(m)*$'
memory:
x-kubernetes-int-or-string: true
pattern: '^[0-9]*(Ei|Pi|Ti|Gi|Mi|Ki|E|P|T|G|M|K)*$'
nvidia.com/gpu:
x-kubernetes-int-or-string: true
pattern: '^[0-9]*$'
63 changes: 63 additions & 0 deletions deployment/mcad-controller/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,69 @@ subjects:
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: quotasubtrees.ibm.com
finalizers: []
spec:
group: ibm.com
scope: Namespaced
names:
kind: QuotaSubtree
singular: quotasubtree
plural: quotasubtrees
shortNames:
- qst
versions:
- name: v1
served: true
storage: true
subresources:
status: {}
schema:
openAPIV3Schema:
type: object
properties:
status:
type: object
x-kubernetes-preserve-unknown-fields: true
spec:
type: object
properties:
parent:
type: string
parentNamespace:
type: string
children:
type: array
items:
type: object
properties:
name:
type: string
namespace:
type: string
quotas:
type: object
properties:
disabled:
type: boolean
hardLimit:
type: boolean
requests:
type: object
properties:
cpu:
x-kubernetes-int-or-string: true
pattern: '^[0-9]*(m)*$'
memory:
x-kubernetes-int-or-string: true
pattern: '^[0-9]*(Ei|Pi|Ti|Gi|Mi|Ki|E|P|T|G|M|K)*$'
nvidia.com/gpu:
x-kubernetes-int-or-string: true
pattern: '^[0-9]*$'
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
Expand Down
2 changes: 1 addition & 1 deletion hack/boilerplate/boilerplate.go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Copyright 2019, 2021 The Multi-Cluster App Dispatcher Authors.
Copyright 2019, 2021, 2022, YEAR The Multi-Cluster App Dispatcher Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
87 changes: 79 additions & 8 deletions hack/run-e2e-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,25 @@ export IMAGE_REPOSITORY_MCAD="${1}"
export IMAGE_TAG_MCAD="${2}"
export MCAD_IMAGE_PULL_POLICY="${3-Always}"
export IMAGE_MCAD="${IMAGE_REPOSITORY_MCAD}:${IMAGE_TAG_MCAD}"
export KUTTL_VERSION=0.15.0
export KUTTL_TEST_OPT="--config ${ROOT_DIR}/kuttl-test.yaml"
# FOR DEBUGGING
#export KUTTL_TEST_OPT="--config ${ROOT_DIR}/kuttl-test.yaml --skip-delete"

sudo apt-get update && sudo apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
# Using older version due to older version of kubernetes cluster"
sudo apt-get install -y --allow-unauthenticated kubectl=1.17.0-00
sudo apt-get install -y --allow-unauthenticated kubectl=1.17.0-00

# Download kind binary (0.6.1)
sudo curl -o /usr/local/bin/kind -L https://github.com/kubernetes-sigs/kind/releases/download/v0.11.0/kind-linux-amd64
sudo chmod +x /usr/local/bin/kind

# Download kuttl plugin
sudo curl -sSLf --output /tmp/kubectl-kuttl https://github.com/kudobuilder/kuttl/releases/download/v${KUTTL_VERSION}/kubectl-kuttl_${KUTTL_VERSION}_linux_x86_64 && sudo mv /tmp/kubectl-kuttl /usr/local/bin && sudo chmod a+x /usr/local/bin/kubectl-kuttl

# check if kind installed
function check-prerequisites {
echo "checking prerequisites"
Expand All @@ -71,7 +78,15 @@ function check-prerequisites {
else
echo -n "found kubectl, " && kubectl version --short --client
fi


kubectl kuttl version >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo "kuttl plugin for kubectl not installed, exiting."
exit 1
else
echo -n "found kuttl plugin for kubectl, " && kubectl kuttl version
fi

if [[ $IMAGE_REPOSITORY_MCAD == "" ]]
then
echo "No MCAD image was provided."
Expand Down Expand Up @@ -289,16 +304,49 @@ function kube-test-env-up {

echo "Installing Podgroup CRD"

helm version

# Turn off master taints
kubectl taint nodes --all node-role.kubernetes.io/master-

}

function mcad-quota-management-up {
cd $ROOT_DIR/deployment

# start mcad controller
echo "Starting MCAD Controller for Quota Management Testing..."
echo "helm upgrade --install mcad-controller . namespace kube-system wait set loglevel=10 set resources.requests.cpu=1000m set resources.requests.memory=1024Mi set resources.limits.cpu=4000m set resources.limits.memory=4096Mi set image.repository=$IMAGE_REPOSITORY_MCAD set image.tag=$IMAGE_TAG_MCAD set image.pullPolicy=$MCAD_IMAGE_PULL_POLICY set configMap.quotaEnabled='true' set quotaManagement.rbac.apiGroup=ibm.com set quotaManagement.rbac.resource=quotasubtrees set configMap.name=mcad-controller-configmap set configMap.preemptionEnabled='true'"
helm upgrade --install mcad-controller . --namespace kube-system --wait --set loglevel=10 --set resources.requests.cpu=1000m --set resources.requests.memory=1024Mi --set resources.limits.cpu=4000m --set resources.limits.memory=4096Mi --set image.repository=$IMAGE_REPOSITORY_MCAD --set image.tag=$IMAGE_TAG_MCAD --set image.pullPolicy=$MCAD_IMAGE_PULL_POLICY --set configMap.quotaEnabled='"true"' --set quotaManagement.rbac.apiGroup=ibm.com --set quotaManagement.rbac.resource=quotasubtrees --set configMap.name=mcad-controller-configmap --set configMap.preemptionEnabled='"true"'
sleep 10
}

function mcad-quota-management-down {

# Helm chart install name
helm_chart_name=$(helm list --short)

# start mcad controller
echo "Stopping MCAD Controller for Quota Management Testing..."
echo "helm delete ${helm_chart_name}"
helm delete ${helm_chart_name}
sleep 20
}

function mcad-up {
kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/scheduler-plugins/277b6bdec18f8a9e9ccd1bfeaf4b66495bfc6f92/config/crd/bases/scheduling.sigs.k8s.io_podgroups.yaml

cd deployment/mcad-controller
cd $ROOT_DIR/deployment/mcad-controller

# start mcad controller
echo "Starting MCAD Controller..."
echo "helm install mcad-controller namespace kube-system wait set loglevel=2 set resources.requests.cpu=1000m set resources.requests.memory=1024Mi set resources.limits.cpu=4000m set resources.limits.memory=4096Mi set image.repository=$IMAGE_REPOSITORY_MCAD set image.tag=$IMAGE_TAG_MCAD set image.pullPolicy=$MCAD_IMAGE_PULL_POLICY"
helm upgrade --install mcad-controller . --namespace kube-system --wait --set loglevel=2 --set resources.requests.cpu=1000m --set resources.requests.memory=1024Mi --set resources.limits.cpu=4000m --set resources.limits.memory=4096Mi --set configMap.name=mcad-controller-configmap --set configMap.podCreationTimeout='"120000"' --set configMap.quotaEnabled='"false"' --set coscheduler.rbac.apiGroup=scheduling.sigs.k8s.io --set coscheduler.rbac.resource=podgroups --set image.repository=$IMAGE_REPOSITORY_MCAD --set image.tag=$IMAGE_TAG_MCAD --set image.pullPolicy=$MCAD_IMAGE_PULL_POLICY

sleep 10
}

function mcad-env-status {
echo "Listing MCAD Controller Helm Chart and Pod YAML..."
helm list
mcad_pod=$(kubectl get pods -n kube-system | grep mcad-controller | awk '{print $1}')
Expand All @@ -307,7 +355,6 @@ function kube-test-env-up {
kubectl get pod ${mcad_pod} -n kube-system -o yaml
fi


sleep 10
echo "Listing MCAD Controller Helm Chart and Pod YAML..."
helm list
Expand All @@ -317,10 +364,6 @@ function kube-test-env-up {
kubectl get pod ${mcad_pod} -n kube-system -o yaml
fi

# Turn off master taints
kubectl taint nodes --all node-role.kubernetes.io/master-


# This is meant to orchestrate initial cluster configuration such that accounting tests can be consistent
echo "---"
echo "Orchestrate cluster..."
Expand All @@ -341,13 +384,41 @@ function kube-test-env-up {
kubectl describe nodes
}

function kuttl-tests {
mcad-quota-management-up
mcad-env-status
cd ${ROOT_DIR}
echo "==============>>>>> Running Quota Management Kuttl E2E tests... <<<<<=============="
echo "kubectl kuttl test ${KUTTL_TEST_OPT}"
kubectl kuttl test ${KUTTL_TEST_OPT}
if [[ $? -ne 0 ]]; then
echo "quota management kuttl e2e tests failure, exiting."
exit 1
else
# Takes a bit of time for namespace created in kuttl testing to completely delete.
sleep 40
fi
mcad-quota-management-down
}

trap cleanup EXIT

kind-up-cluster

kube-test-env-up

###
# Quota management testing
###
kuttl-tests

###
# Non-quota management testing
###
mcad-up

mcad-env-status

cd ${ROOT_DIR}

echo "==========================>>>>> Running E2E tests... <<<<<=========================="
Expand Down
5 changes: 5 additions & 0 deletions kuttl-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kuttl.dev/v1beta1
kind: TestSuite
testDirs:
- ./test/e2e-kuttl/
timeout: 180
Loading