-
Notifications
You must be signed in to change notification settings - Fork 53
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
azure tedge mapper fails to translate health status messages #2273
azure tedge mapper fails to translate health status messages #2273
Conversation
Codecov Report
Additional details and impacted files
|
Robot Results
|
let mut payload_json: Map<String, Value> = | ||
serde_json::from_slice(input.payload.as_bytes())?; | ||
if let Some(timestamp) = default_timestamp { | ||
let timestamp = timestamp | ||
.format(&time::format_description::well_known::Rfc3339)? | ||
.as_str() | ||
.into(); | ||
payload_json.entry("time").or_insert(timestamp); | ||
} | ||
let payload = serde_json::to_string(&payload_json)?; | ||
Ok(vec![ | ||
(MqttMessage::new(&self.mapper_config.out_topic, payload)), | ||
]) |
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.
Why not simply publish the health status message unchanged?
This piece of code will only add a timestamp to down
status (the only ones without a time
field).
And this done using a different time format as for the up
status (as demonstrated by the converting_service_health_status
test).
An alternative, is to rewrite the time
field if not using the RFC 3339 format.
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.
Yes, we can push the whole time stamp
without doing any sort of translation.
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.
Why not simply publish the health status message unchanged?
This piece of code will only add a timestamp to
down
status (the only ones without atime
field). And this done using a different time format as for theup
status (as demonstrated by theconverting_service_health_status
test).An alternative, is to rewrite the
time
field if not using the RFC 3339 format.
@reubenmiller what's your thought on this? Shall we translate the time to RFC 3339 format or send out the message as it comes in?
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.
We need to be consistent, otherwise we'll have the same problem as we have in #2237.
I would align to what the majority is or if you can find best practises in azure about timestamps. RFC3339 is more human readable but less machine readable.
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.
@didier-wenzek The root cause is the API health_status_up_message(daemon_name: &str)
where the timestamp is added as a Unix
timestamp. So, shall we add in RFC 3339
format while adding a timestamp to the status message? then it will resolve all the issues and no need to re-write while parsing.
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.
So, shall we add in RFC 3339 format while adding a timestamp to the status message?
Indeed an idea to consider.
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.
Some comments.
-
Tests are missing! I believe adding them to converter.rs is the right thing.
-
I'm not fully sure if I knew the requirements correctly. So, azure converter should translate these kind of messages?
From
[tedge/health/tedge-mapper-az] {"pid":51367,"status":"down"}
[tedge/health/tedge-mapper-az] {"pid":13280,"status":"up","time":1675330667}
To
[az/messages/events/] {"pid":51367,"status":"down"}
[az/messages/events/] {"pid":13280,"status":"up","time": 2023-09-20T14:37:49+00:00}
if is_bridge_health(&input.topic.name) { | ||
Ok(vec![]) | ||
} else if input.topic.name.starts_with("tedge/health") { |
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.
This check is too wild. The mapper subscribes to tedge/health/+
and tedge/health/+/+
. Therefore, for example, I think this c8y message will be translated by the azure mapper.
tedge mqtt pub tedge/health/tedge-mapper-c8y '{"pid":19753,"status":"up","time":1694586060}'
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.
@rina23q Though shouldn't the az mapper forward all service status messages that are published in the json format? It should not care which service is actually behind it, as you can use Azure to monitor the c8y service.
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.
@reubenmiller Ah okay, but then simple forwarding the payload {"pid":19753,"status":"up","time":1694586060}
to the topic az/messages/events/
is not enough. How can user know which service is behind the message?
Honestly speaking, I'm still confused what is preferred conversion output for azure.
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.
@rina23q very good point regarding the sourceless messages about the service, though I think this will require more thought. Child devices are modelled as components using the $.sub nomenclature, but there isn't a great strategy for handling services of components.
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.
It may be for another PR, but I feel maybe we can use the {property-bag}
messages to send extra information. Find more info here.
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.
Yes we can do the adjustments to how to communicate which service it is in a follow service. Though someone needs to point some thought into how to do this following the best practices of Azure IoT Hub.
@PradeepKiruvale Can you create a follow up ticket?
I already added a test with |
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.
Looks a good bug fix!
Signed-off-by: Pradeep Kumar K J <pkj@softwareag.com>
f0232af
to
47248f9
Compare
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.
Approved
Proposed changes
Issue:
Azure mapper converter was failing to translate the service health message
timestamp
, because it's an integer number.Proposed solution/fix:
Forward the health status message payload to Azure Cloud without translating.
As a followup tasks
RFC3339
format across thin-edge.io tedge-mapper-aws health message uses two different timestamp formats for up and down messages #2237service name
in the health status message Improve the health status messages to azure cloud #2283Types of changes
Paste Link to the issue
#2256
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments