Closed reubenmiller closed 9 months ago
Further debugging shows that the tedge-agent running on the child device registered all of the command support correctly, however the tedge-mapper-c8y didn't send the appropriate messages to Cumulocity IoT.
Below shows the MQTT messages related to the operations registration for the child device:
tedge mqtt sub 'te/device/TST_cut_blocky_foie_gras///cmd/#'
INFO: Connected
[te/device/TST_cut_blocky_foie_gras///cmd/restart] {}
[te/device/TST_cut_blocky_foie_gras///cmd/software_list] {}
[te/device/TST_cut_blocky_foie_gras///cmd/software_update] {}
[te/device/TST_cut_blocky_foie_gras///cmd/log_upload] {"types":["example","multiple_logfiles"]}
[te/device/TST_cut_blocky_foie_gras///cmd/config_snapshot] {"types":["/etc/tedge/tedge.toml","system.toml","tedge-configuration-plugin"]}
[te/device/TST_cut_blocky_foie_gras///cmd/config_update] {"types":["/etc/tedge/tedge.toml","system.toml","tedge-configuration-plugin"]}
On the main device, clearing the entity_store.jsonl file, and restarting the tedge-mapper-c8y seems to trigger sending the correct operation registration messages to Cumulocity IoT.
sudo systemctl stop tedge-mapper-c8y
sudo rm /etc/tedge/.tedge-mapper-c8y/entity_store.jsonl
sudo systemctl start tedge-mapper-c8y
Afterwards, the child device managed object in Cumulocity IoT has the expected supported operations (below is an extern from th):
{
"additionParents": {
"references": [],
"self": "https://t493319102.eu-latest.cumulocity.com/inventory/managedObjects/8133460072/additionParents"
},
"assetParents": {
"references": [],
"self": "https://t493319102.eu-latest.cumulocity.com/inventory/managedObjects/8133460072/assetParents"
},
"c8y_SoftwareList": [],
"c8y_SupportedConfigurations": [
"/etc/tedge/tedge.toml",
"system.toml",
"tedge-configuration-plugin"
],
"c8y_SupportedLogs": ["example", "multiple_logfiles"],
"c8y_SupportedOperations": [
"c8y_DownloadConfigFile",
"c8y_LogfileRequest",
"c8y_Restart",
"c8y_SoftwareUpdate",
"c8y_UploadConfigFile"
],
"childAdditions": {
"references": [
{
"managedObject": {
"id": "3033460073",
"name": "tedge-agent",
"self": "https://t493319102.eu-latest.cumulocity.com/inventory/managedObjects/3033460073"
},
"self": "https://t493319102.eu-latest.cumulocity.com/inventory/managedObjects/8133460072/childAdditions/3033460073"
}
],
"self": "https://t493319102.eu-latest.cumulocity.com/inventory/managedObjects/8133460072/childAdditions"
},
"childAssets": {
"references": [],
"self": "https://t493319102.eu-latest.cumulocity.com/inventory/managedObjects/8133460072/childAssets"
},
"childDevices": {
"references": [],
"self": "https://t493319102.eu-latest.cumulocity.com/inventory/managedObjects/8133460072/childDevices"
},
"creationTime": "2024-02-01T08:03:42.543Z",
"deviceParents": {
"references": [],
"self": "https://t493319102.eu-latest.cumulocity.com/inventory/managedObjects/8133460072/deviceParents"
},
"id": "8133460072",
"lastUpdated": "2024-02-01T08:33:20.599Z",
"name": "TST_cut_blocky_foie_gras",
"owner": "device_TST_raise_religious_gig",
"self": "https://t493319102.eu-latest.cumulocity.com/inventory/managedObjects/8133460072",
"type": "thin-edge.io-child"
}
Running the flake-finder
tasks reveals that the tests is failing about 50% of the time.
invoke flake-finder --test-name "Successful log operation" --iterations 10 --clean --suite "Log Operation Child"
Overall: FAILED
Results: 10 iterations, 5 passed, 5 failed
Elapsed time: 0:05:13.918494
Failed iterations: [3, 4, 6, 7, 8]
The bug has been fixed by making sure that the supported operations message (SmartREST 114) is sent whenever a command capability message is received, as long as it adds a new supported operation. If a command capability message does not change the aggregated list (e.g: an already registered capability is resent) of supported operations, then this 114 message is not sent unnecessarily.
QA has thoroughly checked the bug and here are the results:
Describe the bug
Operations registered by a child device (e.g. tedge-agent running as a child device), are sometimes not translated to the Cumulocity IoT cloud registration messages (e.g.
114
).Currently the problem has only been observed when the tedge-agent is running as a child device, however it should be verified that it is also not an issue with the main device as well.
Problem was discovered when investigating https://github.com/thin-edge/thin-edge.io/issues/2346
Symptoms
tedge-apt-plugin
package installed.c8y_DownloadConfigFile
andc8y_UploadConfigFile
from thec8y_SupportedConfigurations
fragmentc8y_LogfileRequest
in thec8y_SupportedConfigurations
fragment (e.g. there is no trace of a114
message containing thec8y_LogfileRequest
, only forc8y_Restart
andc8y_SoftwareUpdate
)To Reproduce
The problem is observable by running the following command from the repository:
Expected behavior
Screenshots
Environment (please complete the following information):
Debian GNU/Linux 12 (bookworm)
unknown
Linux 55e141da3961 6.5.0-15-generic #15-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 9 22:39:36 UTC 2024 aarch64 GNU/Linux
tedge 0.13.2~449+g9dbd1ad
Additional context
MQTT Messages
Child Device - Managed Object
Child device - tedge-agent logs
Main Device - entity_store.jsonl