project-codeflare / multi-cluster-app-dispatcher

Holistic job manager on Kubernetes
Apache License 2.0
108 stars 63 forks source link

[quota management] Create test for exceeding hardLimit #375

Open KPostOffice opened 1 year ago

KPostOffice commented 1 year ago

When a hardLimit is exceeded, the AppWrapper should fail due to insufficient quota.

Files used

testing-forest.yaml

apiVersion: ibm.com/v1
kind: QuotaSubtree
metadata:
  name: context-root
  namespace: kube-system
  labels:
    tree: quota_context
spec:
  children:
    - name: context-root
      quotas:
        hardLimit: true
        requests:
          cpu: 2000
          memory: 8000Mi
---
apiVersion: ibm.com/v1
kind: QuotaSubtree
metadata:
  name: context-root-children
  namespace: kube-system
  labels:
    tree: quota_context
spec:
  parent: context-root
  children:
    - name: alpha
      quotas:
        hardLimit: true
        requests:
          cpu: 1000
          memory: 4000Mi
    - name: beta
      quotas:
        requests:
          cpu: 1000
          memory: 4000Mi

exceed-hardlimit.yaml

apiVersion: mcad.ibm.com/v1beta1
kind: AppWrapper
metadata:
  name: exceed-hardlimit
  namespace: test1
  labels:
    quota_context: "alpha"
spec:
  service:
    spec: {}
  resources:
    metadata: {}
    GenericItems:
      - metadata: {}
        replicas: 1
        custompodresources:
        - replicas:  1
          requests:
            cpu: 1001m
            memory: 4000Mi
          limits:
            cpu: 1001m
            memory: 4000Mi
        generictemplate:
          apiVersion: apps/v1
          kind: StatefulSet
          metadata:
            name: exceed-hardlimit
            namespace: test1
            labels:
              app: exceed-hardlimit
          spec:
            selector:
              matchLabels:
                app: exceed-hardlimit
            replicas: 1
            template:
              metadata:
                labels:
                  app: exceed-hardlimit
                  size: "1"
              spec:
                containers:
                  - name: exceed-hardlimit
                    image: registry.access.redhat.com/ubi8/ubi:latest
                    command:
                      - /bin/sh
                      - -c
                      - while true; do sleep 10; done
                    resources:
                      requests:
                        cpu: "1001m"
                        memory: "4000Mi"
                      limits:
                        cpu: "1001m"
                        memory: "4000Mi"

Expect

Status of AppWrapper to update with status indicating insufficient quota

Status:
  Conditions:
    Last Transition Micro Time:  2023-05-16T18:38:22.050023Z
    Last Update Micro Time:      2023-05-16T18:38:22.050023Z
    Status:                      True
    Type:                        Init
    Last Transition Micro Time:  2023-05-16T18:38:22.050216Z
    Last Update Micro Time:      2023-05-16T18:38:22.050216Z
    Reason:                      AwaitingHeadOfLine
    Status:                      True
    Type:                        Queueing
    Last Transition Micro Time:  2023-05-16T18:38:22.087504Z
    Last Update Micro Time:      2023-05-16T18:38:22.087504Z
    Reason:                      FrontOfQueue.
    Status:                      True
    Type:                        HeadOfLine
    Last Transition Micro Time:  2023-05-16T18:38:42.115353Z
    Last Update Micro Time:      2023-05-16T18:38:42.115353Z
    Message:                     Insufficient quota to dispatch AppWrapper.
    Reason:                      AppWrapperNotRunnable.  Failed to allocate quota on quota designation 'quota_context'
    Status:                      True
    Type:                        Backoff
KPostOffice commented 1 year ago

359