Skip to content

Commit a98e940

Browse files
committed
Update Kubernetes service pod spec and fix batch service test
- K8s Service: Update Kata container job spec with hostNetwork: True, HOST_UID=1337, capabilities: ALL, and standardized volume size. Skip default credential loading if K8S_E2E env var is set. - K8s Tests: Update unit tests to verify spec generation and mock correctly. Update e2e tests to verify job Running status instead of completion to avoid timeouts with default command. Skip e2e test if K8S_E2E env var is not set. - Local Tests: Update kubernetes e2e test script with correct filename. - Batch Service Test: Fix mock return value to be a Job object to resolve AttributeError. - Deps: Add google-api-python-client to root Pipfile.
1 parent 9f8c848 commit a98e940

File tree

4 files changed

+61
-43
lines changed

4 files changed

+61
-43
lines changed

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ protobuf = "==4.23.4"
1111
psutil = "==5.9.4"
1212
google-cloud-ndb = "==2.3.4"
1313
kubernetes = "==34.1.0"
14+
google-api-python-client = "==2.93.0"
1415

1516
[dev-packages]
1617
Fabric = "==1.14.1"

Pipfile.lock

Lines changed: 56 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/clusterfuzz/_internal/k8s/service.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,10 @@ def _create_job_body(config: KubernetesJobConfig, input_url: str) -> dict:
219219
class KubernetesService(RemoteTaskInterface):
220220
"""A remote task execution client for Kubernetes."""
221221

222-
def __init__(self):
222+
def __init__(self, k8s_config_loaded: bool = False):
223223
# In e2e tests, the kubeconfig is already loaded by the test setup.
224-
if not os.getenv('K8S_E2E'):
225-
try:
226-
k8s_config.load_kube_config()
227-
except (k8s_config.ConfigException, TypeError):
228-
self._load_gke_credentials()
224+
if not k8s_config_loaded:
225+
self._load_gke_credentials()
229226

230227
self._core_api = k8s_client.CoreV1Api()
231228
self._batch_api = k8s_client.BatchV1Api()

src/clusterfuzz/_internal/tests/core/k8s/k8s_service_e2e_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def get_batch_config(key):
152152
k8s_config.load_kube_config(config_file=cls.kubeconfig_path)
153153
cls.api_client = k8s_client.BatchV1Api()
154154

155-
cls.kubernetes_client = kubernetes_service.KubernetesService()
155+
cls.kubernetes_client = kubernetes_service.KubernetesService(k8s_config_loaded=True)
156156
data_types.Job(name='test-job', platform='LINUX').put()
157157
data_types.Job(name='test-job1', platform='LINUX').put()
158158
data_types.Job(name='test-job2', platform='LINUX').put()

0 commit comments

Comments
 (0)