project-codeflare / multi-cluster-app-dispatcher

Holistic job manager on Kubernetes
Apache License 2.0
107 stars 62 forks source link

[quota management] Create test for exceeding soft limit #376

Open KPostOffice opened 1 year ago

KPostOffice commented 1 year ago

If quota exceeds limits on a node where hardLimit is not true the excess quota should be borrowed from a sibling node

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:
        requests:
          cpu: 1000
          memory: 4000Mi
    - name: beta
      quotas:
        requests:
          cpu: 1000
          memory: 4000Mi

exceed-softlimit.yaml

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

Expected

AppWrapper successfully reaches running state:

Name:         exceed-softlimit
Namespace:    test1
Labels:       quota_context=alpha
Annotations:  <none>
API Version:  mcad.ibm.com/v1beta1
Kind:         AppWrapper
...
Status:
  Canrun:  true
  Conditions:
    Last Transition Micro Time:  2023-05-16T19:26:34.067044Z
    Last Update Micro Time:      2023-05-16T19:26:34.067044Z
    Status:                      True
    Type:                        Init
    Last Transition Micro Time:  2023-05-16T19:26:34.067310Z
    Last Update Micro Time:      2023-05-16T19:26:34.067310Z
    Reason:                      AwaitingHeadOfLine
    Status:                      True
    Type:                        Queueing
    Last Transition Micro Time:  2023-05-16T19:26:34.079820Z
    Last Update Micro Time:      2023-05-16T19:26:34.079820Z
    Reason:                      FrontOfQueue.
    Status:                      True
    Type:                        HeadOfLine
    Last Transition Micro Time:  2023-05-16T19:26:35.781047Z
    Last Update Micro Time:      2023-05-16T19:26:35.781047Z
    Reason:                      AppWrapperRunnable
    Status:                      True
    Type:                        Dispatched
    Last Transition Micro Time:  2023-05-16T19:26:37.635105Z
    Last Update Micro Time:      2023-05-16T19:26:37.635105Z
    Reason:                      PodsRunning
    Status:                      True
    Type:                        Running
  Controllerfirsttimestamp:      2023-05-16T19:26:34.066850Z
  Filterignore:                  true
  Queuejobstate:                 Running
  Running:                       1
  Sender:                        before [syncQueueJob] setRunning
  State:                         Running
KPostOffice commented 1 year ago

359