Skip to content
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

MAIN-2129 prevent popeye from running on arm nodes #1608

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions playbooks/robusta_playbooks/popeye.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@
from collections import defaultdict
from datetime import datetime
from json import JSONDecodeError
from typing import Any, Dict, List, Literal, Optional

from hikaru.model.rel_1_26 import Container, PodSpec, ResourceRequirements
from typing import Any, Dict, List, Optional

from hikaru.model.rel_1_26 import (
Affinity,
Container,
NodeAffinity,
NodeSelector,
NodeSelectorRequirement,
NodeSelectorTerm,
PodSpec,
ResourceRequirements,
)
from pydantic import BaseModel, ValidationError

from robusta.api import (
RUNNER_SERVICE_ACCOUNT,
EnrichmentAnnotation,
Expand All @@ -18,8 +28,8 @@
FindingSource,
FindingType,
PodRunningParams,
RobustaJob,
PopeyeScanReportBlock,
RobustaJob,
ScanReportRow,
ScanType,
action,
Expand Down Expand Up @@ -128,6 +138,23 @@ def popeye_scan(event: ExecutionBaseEvent, params: PopeyeParams):
resources = ResourceRequirements(
limits={"memory": (str(POPEYE_MEMORY_LIMIT))},
)
affinity = Affinity(
nodeAffinity=NodeAffinity(
requiredDuringSchedulingIgnoredDuringExecution=NodeSelector(
nodeSelectorTerms=[
NodeSelectorTerm(
matchExpressions=[
NodeSelectorRequirement(
key="kubernetes.io/arch",
operator="NotIn",
values=["arm64"],
)
]
)
]
)
)
)
spec = PodSpec(
serviceAccountName=params.service_account_name,
containers=[
Expand All @@ -142,6 +169,7 @@ def popeye_scan(event: ExecutionBaseEvent, params: PopeyeParams):
resources=resources,
)
],
affinity=affinity,
restartPolicy="Never",
**params.popeye_job_spec,
)
Expand Down Expand Up @@ -257,5 +285,5 @@ def clean_up_k8s_logs_from_job_output(logs: str) -> str:
if endline_pos == -1:
logs = ""
else:
logs = logs[endline_pos + 1:]
logs = logs[endline_pos + 1 :]
return logs
Loading