Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 6
Cleaned simple kubernetes manager#66
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
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
a689958b7f46ae879ae8e3a75fbdd78de89cea667795011b3File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
| components: | ||
| - type: generic | ||
| category: manager | ||
| name: Generic Manager | ||
| location: VM Iris | ||
| uuid: eddb51a0-557b-4848-ac7a-faccc7c51fa3 | ||
| - category: manager | ||
| type: kubernetes-simple | ||
| name: Simple Kubernetes Manager | ||
| location: VM Iris | ||
| uuid: 4f8fb73e-7e74-11eb-8f63-f3ccc3ab82f6 | ||
| namespace: villas-controller |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| from villas.controller.components.managers.kubernetes import KubernetesManager | ||
| from villas.controller.components.simulators.kubernetes import KubernetesJob | ||
| def build_parameters(sim_name, jobname, image, adls=3600, | ||
| privileged=False, name=None, uuid=None): | ||
| parameters = { | ||
| 'type': 'kubernetes', | ||
| 'category': 'simulator', | ||
| 'uuid': uuid, | ||
| 'name': name or sim_name, | ||
| 'properties': { | ||
| 'job': { | ||
| 'apiVersion': 'batch/v1', | ||
| 'kind': 'Job', | ||
| 'metadata': { | ||
| 'name': jobname | ||
| }, | ||
| 'spec': { | ||
| 'activeDeadlineSeconds': adls, | ||
| 'backoffLimit': 2, | ||
| 'template': { | ||
| 'spec': { | ||
| 'restartPolicy': 'Never', | ||
| 'containers': [ | ||
| { | ||
| 'image': image, | ||
| 'imagePullPolicy': 'Always', | ||
| 'name': 'jobcontainer', | ||
| 'securityContext': { | ||
| 'privileged': privileged | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| return parameters | ||
| class KubernetesManagerSimple(KubernetesManager): | ||
| def __init__(self, **args): | ||
| super().__init__(**args) | ||
| def create(self, payload): | ||
| params = payload.get('parameters', {}) | ||
| sim_name = payload.get('name', 'Kubernetes Simulator') | ||
| jobname = params.get('jobname', 'noname') | ||
| adls = params.get('activeDeadlineSeconds', 3600) | ||
| if type(adls) is str: | ||
| adls = int(adls) | ||
| image = params.get('image') | ||
| name = params.get('name') | ||
| privileged = params.get('privileged', False) | ||
| uuid = params.get('uuid') | ||
| self.logger.info('uuid:') | ||
| self.logger.info(uuid) | ||
| if image is None: | ||
| self.logger.error('No image given, will try super.create') | ||
| super().create(payload) | ||
| return | ||
| parameters = build_parameters( | ||
| sim_name=sim_name, | ||
| jobname=jobname, | ||
| image=image, | ||
| adls=adls, | ||
| privileged=privileged, | ||
| name=name, | ||
| uuid=uuid | ||
| ) | ||
| comp = KubernetesJob(self, **parameters) | ||
| self.add_component(comp) |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -84,6 +84,8 @@ def _drain_publish_queue(self): | ||||||||||
| self.producer.publish(body, **kwargs) | ||||||||||
| except queue.Empty: | ||||||||||
| pass | ||||||||||
| except TimeoutError: | ||||||||||
| LOGGER.warn('TimeoutError, let kombu reconnect..') | ||||||||||
Comment on lines
+87
to
+88
CopilotAI | ||||||||||
| exceptTimeoutError: | |
| LOGGER.warn('TimeoutError, let kombu reconnect..') | |
| exceptTimeoutErroraserr: | |
| LOGGER.warn('TimeoutError occurred, let kombu reconnect: %s', err) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| --- | ||
| $schema: http://json-schema.org/draft-04/schema# | ||
| type: object | ||
| title: 'Simple Kubernetes Job' | ||
| required: | ||
| - image | ||
| properties: | ||
| name: | ||
| type: string | ||
| title: 'Simulator Name' | ||
| default: 'Kubernetes Simulator' | ||
| uuid: | ||
| type: string | ||
| title: UUID | ||
| default: 8dfd03b2-1c78-11ec-9621-0242ac130002 | ||
| jobname: | ||
| type: string | ||
| title: 'Jobname' | ||
| default: myjob | ||
| activeDeadlineSeconds: | ||
| type: number | ||
| title: activeDeadlineSeconds | ||
| default: 3600 | ||
| image: | ||
| type: string | ||
| title: Image | ||
| default: perl | ||
| privileged: | ||
| type: boolean | ||
| title: Privileged | ||
| default: false | ||
| description: 'WARNING: If true, the container has root privileges on the host' |
CopilotAIJul 1, 2025
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.
Use LOGGER.warning instead of the deprecated LOGGER.warn for consistency with the Python logging API.