-
Notifications
You must be signed in to change notification settings - Fork 15
worker process #323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
worker process #323
Changes from all commits
6bdb990
023f76a
39e7c8a
ddfec09
c66840f
d91f4d3
480ca78
9b3ba62
3284638
ec1501d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,14 @@ metadata: | |
| pipelinesascode.tekton.dev/task: "[git-clone, ./.tekton/post-integration-evaluation.yaml]" | ||
| pipelinesascode.tekton.dev/max-keep-runs: "100" | ||
| spec: | ||
| # Cluster-specific: requires p4d.24xlarge GPU nodes with matching taint; update if migrating to a different cluster. | ||
| podTemplate: | ||
| tolerations: | ||
| - key: "p4d-gpu" | ||
| operator: "Exists" | ||
| effect: "NoSchedule" | ||
| nodeSelector: | ||
| node.kubernetes.io/instance-type: p4d.24xlarge | ||
| timeouts: | ||
| pipeline: 10h30m0s # Timeout for the entire PipelineRun | ||
| params: | ||
|
|
@@ -124,6 +132,14 @@ spec: | |
| - name: source | ||
| - name: basic-auth | ||
| - name: exploit-iq-data | ||
| # Cluster-specific: requires p4d.24xlarge GPU nodes with matching taint; update if migrating to a different cluster. | ||
| podTemplate: | ||
| tolerations: | ||
| - key: "p4d-gpu" | ||
| operator: "Exists" | ||
| effect: "NoSchedule" | ||
| nodeSelector: | ||
| node.kubernetes.io/instance-type: p4d.24xlarge | ||
|
Comment on lines
+136
to
+142
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tmihalac This currently works in current cluster, but if you'll move to a new cluster, then it might fail to schedule the task and the pipeline will fail. consider adding a comment about that that this is ocp infrastructure dependent
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
| volumes: | ||
| - name: google-creds-volume | ||
| secret: | ||
|
|
@@ -137,7 +153,7 @@ spec: | |
| items: | ||
| - key: service-ca.crt | ||
| path: service-ca.crt # Mounts as a file named service-ca.crt | ||
|
|
||
| # >>> THE SERVER (Sidecar) <<< | ||
| sidecars: | ||
| - name: server-application | ||
|
|
@@ -148,10 +164,10 @@ spec: | |
| resources: | ||
| requests: | ||
| cpu: "3000m" # CPU request (3 cores) | ||
| memory: "12Gi" # Memory request (8 gigabytes) | ||
| memory: "32Gi" # Memory request | ||
| limits: | ||
| cpu: "3000m" # CPU limit (3 cores) | ||
| memory: "32Gi" # Memory limit (16 gigabytes) | ||
| memory: "64Gi" # Memory limit | ||
|
|
||
| volumeMounts: | ||
| - name: google-creds-volume | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import math | ||
| import os | ||
|
|
||
|
|
||
| def available_cpus() -> int: | ||
| """Return the number of CPUs available to this process. | ||
|
|
||
| Respects container CPU limits from cgroup v2/v1 before falling back to | ||
| process affinity and Python CPU APIs. | ||
| """ | ||
|
|
||
| # cgroup v2 | ||
| try: | ||
| with open("/sys/fs/cgroup/cpu.max", encoding="utf-8") as f: | ||
| quota_s, period_s = f.read().strip().split() | ||
|
|
||
| if quota_s != "max": | ||
| quota = int(quota_s) | ||
| period = int(period_s) | ||
|
|
||
| if quota > 0 and period > 0: | ||
| return max(1, math.ceil(quota / period)) | ||
| except (OSError, ValueError): | ||
| pass | ||
|
|
||
| # cgroup v1 | ||
| for base in ( | ||
| "/sys/fs/cgroup/cpu", | ||
| "/sys/fs/cgroup/cpu,cpuacct", | ||
| ): | ||
| try: | ||
| with open(f"{base}/cpu.cfs_quota_us", encoding="utf-8") as f: | ||
| quota = int(f.read().strip()) | ||
|
|
||
| with open(f"{base}/cpu.cfs_period_us", encoding="utf-8") as f: | ||
| period = int(f.read().strip()) | ||
|
|
||
| # cgroup v1 uses quota == -1 to mean "no CPU quota". | ||
| if quota > 0 and period > 0: | ||
| return max(1, math.ceil(quota / period)) | ||
| except (OSError, ValueError): | ||
| pass | ||
|
|
||
| # CPU affinity fallback. | ||
| try: | ||
| return max(1, len(os.sched_getaffinity(0))) | ||
| except (AttributeError, OSError): | ||
| pass | ||
|
|
||
| # Python 3.13+ fallback. | ||
| # Keep this after cgroup checks: in OpenShift/Kubernetes it may expose | ||
| # the full node-visible CPU set rather than the pod CPU limit. | ||
| if hasattr(os, "process_cpu_count"): | ||
| count = os.process_cpu_count() | ||
| if count: | ||
| return max(1, count) | ||
|
|
||
| return os.cpu_count() or 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tmihalac This currently works in current cluster, but if you'll move to a new cluster, then it might fail to schedule the task and the pipeline will fail. consider adding a comment about that that this is ocp cluster infrastructure dependent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK