Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

It is not possible to determine if a server channel can be applied to a device or not. #12

Closed
UniversalSuperBox opened this issue Jul 6, 2020 · 0 comments · Fixed by #13
Assignees

Comments

@UniversalSuperBox
Copy link
Member

The dbus method com.canonical.SystemImage GetChannels returns all channels from the system-image server. This would be acceptable if every device had its own system-image server, but we have many devices and channels on a single server. This causes a huge list of channels to be returned for the call:

qml: CHANNEL IS 16.04,arm64,mainline,rc
qml: CHANNEL IS 16.04,arm64,mainline,stable
qml: CHANNEL IS 16.04,armhf,hybris,devel
qml: CHANNEL IS 16.04,community,anpok,devel
qml: CHANNEL IS 16.04,community,fredldotme,devel
qml: CHANNEL IS 16.04,community,guf,devel
qml: CHANNEL IS 16.04,community,kuailexs,devel
qml: CHANNEL IS 16.04,community,walid,devel
qml: CHANNEL IS ubports-touch,16.04,devel
qml: CHANNEL IS ubports-touch,16.04,edge
qml: CHANNEL IS ubports-touch,16.04,rc
qml: CHANNEL IS ubports-touch,16.04,stable

This is not desirable, as it puts the work on the client to determine if a channel is appropriate for the device or not. This is not possible using any of the data which can be returned by system-image via dbus. Instead, we should only return a list of channels which are applicable for the current device.

The current code for returning this list inside system-image is not terribly smart. It only checks to make sure the channel is not hidden, an alias, or a redirect. If none of those are the case, the channel is fine as far as it's concerned.

def GetChannels(self):
"""Get channels from system server."""
ret = list()
channels = self._api.get_channels()
if channels:
for key in channels:
if not key["hidden"] and not key["alias"] and not key["redirect"]:
ret.append(key["name"])
log.info('Channels {}', ret)
return ret

The code which it eventually calls back to is in the Mediator:

self._channels = list()
for key in sorted(self._state.channels):
self._channels.append(dict(
hidden=self._state.channels[key].get('hidden'),
alias=self._state.channels[key].get('alias'),
redirect=self._state.channels[key].get('redirect'),
name=key
))

And, through a couple more levels of indirection, the Channels class:

class Channels(Bag):
@classmethod
def from_json(cls, data):
mapping = json.loads(data)
channels = {}
for channel_name, mapping_1 in mapping.items():
hidden = mapping_1.pop('hidden', None)
if hidden is None:
hidden = False
else:
assert hidden in (True, False), (
"Unexpected value for 'hidden': {}".format(hidden))
mapping_1['hidden'] = hidden
device_mapping = mapping_1.pop('devices')
mapping_1['devices'] = _parse_device_mappings(device_mapping)
channels[channel_name] = Bag(**mapping_1)
return cls(**channels)

We should be able to change GetChannels so it only returns the channels applicable for the current device.

@UniversalSuperBox UniversalSuperBox self-assigned this Jul 6, 2020
UniversalSuperBox added a commit that referenced this issue Jul 6, 2020
Prior to this commit, get_channels would return every channel which was
available on the system-image server, which was not at all desirable.

Some changes to the test helpers were needed to make this happen. All
tests were previously written to assume only the nexus7 was available,
and my new test cases needed a different device as well.

Fixes #12
UniversalSuperBox added a commit that referenced this issue Jul 17, 2020
Prior to this commit, get_channels would return every channel which was
available on the system-image server, which was not at all desirable.

Some changes to the test helpers were needed to make this happen. All
tests were previously written to assume only the nexus7 was available,
and my new test cases needed a different device as well.

Fixes #12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant