Skip to content

Commit 44613ee

Browse files
authored
feat: move external cronjob to run timely cleanup to goroutine+configable for internval of cleanup (#934)
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> - save resource, no spin up job every 15mins - less image to pull down for disconnect - should cleanup endpoint later if needed - less security concern as one less networkpolicy and patch - make internval configable: - either pass as flag `--cleanup-internval `to main or env variable `CLEANUP_INTERNVAL_MINUTES` in deployment for customized value - if not set any or set to '0', use default 15mins - if set to a negative value, skip cleanup goroutine totally ## How Has This Been Tested? <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ## Merge criteria: <!--- This PR will be merged by any repository approver when it meets all the points in the checklist --> <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> - [ ] The commits are squashed in a cohesive manner and have meaningful messages. - [ ] Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious). - [ ] The developer has manually tested the changes and verified that the changes work <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * API key cleanup moved from external scheduled jobs into a built-in background task within the service. * Removed external cleanup scheduling and related network restrictions; deployment wiring simplified and related image/parameter removed. * Added internal TODOs and small runtime shutdown sequencing improvements. * **Chores** * Cleaned up deployment overlays, patches, and params to remove now-unused cleanup artifacts. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Wen Zhou <wenzhou@redhat.com>
1 parent a7f20f0 commit 44613ee

16 files changed

Lines changed: 106 additions & 144 deletions

File tree

.github/hack/cleanup-odh.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ cleanup_maas_resources() {
100100
kubectl delete authpolicy maas-api-auth-policy -n "$ns" --ignore-not-found 2>/dev/null || true
101101
kubectl delete httproute maas-api-route -n "$ns" --ignore-not-found 2>/dev/null || true
102102
kubectl delete destinationrule maas-api-backend-tls -n "$ns" --ignore-not-found 2>/dev/null || true
103-
kubectl delete networkpolicy maas-api-cleanup-restrict maas-authorino-allow -n "$ns" --ignore-not-found 2>/dev/null || true
104-
kubectl delete cronjob maas-api-key-cleanup -n "$ns" --ignore-not-found 2>/dev/null || true
103+
kubectl delete networkpolicy maas-authorino-allow -n "$ns" --ignore-not-found 2>/dev/null || true
105104
kubectl delete role maas-api-db-secret maas-controller-leader-election-role -n "$ns" --ignore-not-found 2>/dev/null || true
106105
kubectl delete rolebinding maas-api-db-secret maas-controller-leader-election-rolebinding -n "$ns" --ignore-not-found 2>/dev/null || true
107106
kubectl delete serviceaccount maas-api maas-controller -n "$ns" --ignore-not-found 2>/dev/null || true

deployment/base/maas-api/core/cronjob-cleanup.yaml

Lines changed: 0 additions & 44 deletions
This file was deleted.

deployment/base/maas-api/core/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ spec:
3131
value: "models-as-a-service"
3232
- name: METRICS_PORT
3333
value: "9090"
34+
- name: CLEANUP_INTERVAL_MINUTES
35+
value: "15"
3436
resources:
3537
requests:
3638
memory: "64Mi"

deployment/base/maas-api/core/kustomization.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ kind: Kustomization
44
resources:
55
- deployment.yaml
66
- service.yaml
7-
- cronjob-cleanup.yaml
8-
- networkpolicy-cleanup.yaml
97

108
images:
119
- name: maas-api

deployment/base/maas-api/core/networkpolicy-cleanup.yaml

Lines changed: 0 additions & 37 deletions
This file was deleted.

deployment/base/maas-api/overlays/tls/cronjob-cleanup-patch.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.

deployment/base/maas-api/overlays/tls/kustomization.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ resources:
88
patches:
99
- path: deployment-patch.yaml
1010
- path: service-patch.yaml
11-
- path: cronjob-cleanup-patch.yaml
12-
- path: networkpolicy-cleanup-patch.yaml
1311
- target:
1412
group: gateway.networking.k8s.io
1513
version: v1

deployment/base/maas-api/overlays/tls/networkpolicy-cleanup-patch.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

deployment/base/maas-controller/manager/manager.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@ spec:
5757
key: payload-processing-image
5858
name: maas-parameters
5959
optional: true
60-
- name: RELATED_IMAGE_UBI_MINIMAL_IMAGE
61-
valueFrom:
62-
configMapKeyRef:
63-
key: maas-api-key-cleanup-image
64-
name: maas-parameters
65-
optional: true
6660
image: maas-controller
6761
name: manager
6862
imagePullPolicy: Always

deployment/overlays/odh/params.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
maas-api-image=quay.io/opendatahub/maas-api:odh-stable
22
maas-controller-image=quay.io/opendatahub/maas-controller:odh-stable
33
payload-processing-image=quay.io/opendatahub/odh-ai-gateway-payload-processing:odh-stable
4-
maas-api-key-cleanup-image=registry.redhat.io/ubi9/ubi-minimal:9.7
54
payload-processing-replicas=1
65
gateway-namespace=openshift-ingress
76
gateway-name=maas-default-gateway

0 commit comments

Comments
 (0)