Skip to content

Commit

Permalink
feat(deployment): adds support for paramsync in device deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
amitsingh21 committed Sep 6, 2023
1 parent 17661c3 commit 3089eb3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 27 deletions.
7 changes: 7 additions & 0 deletions riocli/apply/manifests/deployment-ros-device-no-rosbag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ spec:
kind: device
nameOrGUID: device-docker
restart: always # Options: [always, onfailure, never]
features:
params:
enabled: true
trees:
- config01
- config02
disableSync: false
envArgs:
- name: TEST_KEY
value: test_value
Expand Down
55 changes: 28 additions & 27 deletions riocli/deployment/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def create_object(self, client: Client, **kwargs) -> typing.Any:

if 'runtime' in self.spec and runtime != self.spec.runtime:
raise Exception('>> runtime mismatch => deployment:{}.runtime !== package:{}.runtime '.format(
self.metadata.name, pkg['packageName']
))
self.metadata.name, pkg['packageName']
))

provision_config = pkg.get_provision_configuration(plan_id)

Expand Down Expand Up @@ -160,31 +160,6 @@ def create_object(self, client: Client, **kwargs) -> typing.Any:
"instance": "rio-internal-headscale"
}]

if 'params' in self.spec.features and self.spec.features.params.enabled:
component_id = internal_component.componentId
tree_names = self.spec.features.params.get('trees', [])
disable_sync = self.spec.features.params.get('disableSync',
False)

args = []
for e in executables:
args.append({
'executableId': e['id'],
'paramTreeNames': tree_names,
'enableParamSync': not disable_sync
})

context = provision_config.context
if 'component_context' not in context:
context['component_context'] = {}

component_context = context['component_context']
if component_id not in component_context:
component_context[component_id] = {}

component_context[component_id][
'param_sync_exec_args'] = args

if self.spec.runtime == 'device':
device_guid, device = self.rc.find_depends(
self.spec.device.depends)
Expand Down Expand Up @@ -214,6 +189,32 @@ def create_object(self, client: Client, **kwargs) -> typing.Any:
provision_config = add_mount_volume_provision_config(
provision_config, component_name, device, exec_mounts)

if 'features' in self.spec:
if 'params' in self.spec.features and self.spec.features.params.enabled:
component_id = internal_component.componentId
tree_names = self.spec.features.params.get('trees', [])
disable_sync = self.spec.features.params.get('disableSync',
False)

args = []
for e in executables:
args.append({
'executableId': e['id'],
'paramTreeNames': tree_names,
'enableParamSync': not disable_sync
})

context = provision_config.context
if 'component_context' not in context:
context['component_context'] = {}

component_context = context['component_context']
if component_id not in component_context:
component_context[component_id] = {}

component_context[component_id][
'param_sync_exec_args'] = args

provision_config.set_component_alias(component_name,
self.metadata.name)

Expand Down
17 changes: 17 additions & 0 deletions riocli/jsonschema/schemas/deployment-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,23 @@ definitions:
items:
"$ref": "#/definitions/deviceROSBagJobSpec"

features:
type: object
properties:
params:
type: object
properties:
enabled:
type: boolean
trees:
type: array
items:
type: string
disableSync:
type: boolean
required:
- enabled

- properties:
runtime:
type: string
Expand Down

0 comments on commit 3089eb3

Please sign in to comment.