Skip to content
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

Fix how duplicates are handled in ONVIF [SAME VERSION] #393

Merged
merged 1 commit into from
Sep 30, 2021

Conversation

kate-goldenring
Copy link
Contributor

@kate-goldenring kate-goldenring commented Sep 30, 2021

What this PR does / why we need it:
There is an ONVIF discovery bug caused by this PR #382, which means that ONVIF discovery doesn't work for Akri versions 0.6.17-0.6.19. Any thoughts on how this should be handled? This is further compounded by the fact that I discovered this after creating the release, so currently latest points to 0.6.19 which means helm install akri akri-helm-charts/akri installs the faulty version.

My proposed fix: push this fix as version 0.6.19 and create new release and in the release CHANGELOG (see #394) put that ONVIF discovery does not work in versions 0.6.17 and 0.6.18 .

Thoughts?

Special notes for your reviewer:
The bug was caused by the fact that we were applying to_lowercase() on xml strings to be passed to later parts of discovery and leaving cameras un-discovered. To fix this, this PR removes duplicates on only the URIs returned from get_scope_filtered_uris_from_discovery_response is more ideal.
Example of issue: original string:

<?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl"><SOAP-ENV:Header><wsa:MessageID>urn:uuid:b7b46c8b-16e3-4b77-920e-edd1374a3fe6</wsa:MessageID><wsa:RelatesTo>uuid:b800c7f9-24b5-4817-b87d-446e8fb76e49</wsa:RelatesTo><wsa:ReplyTo SOAP-ENV:mustUnderstand="true"><wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address></wsa:ReplyTo><wsa:To SOAP-ENV:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To><wsa:Action SOAP-ENV:mustUnderstand="true">http://schemas.xmlsoap.org/ws/2005/04/discovery/ProbeMatches</wsa:Action><wsdd:AppSequence InstanceId="0" MessageNumber="36"></wsdd:AppSequence></SOAP-ENV:Header><SOAP-ENV:Body><wsdd:ProbeMatches><wsdd:ProbeMatch><wsa:EndpointReference><wsa:Address>urn:uuid:fb03dab7-1787-4e12-ab8b-4567327b23c6</wsa:Address></wsa:EndpointReference><wsdd:Types>tdn:NetworkVideoTransmitter</wsdd:Types><wsdd:Scopes>onvif://www.onvif.org/name/Unknown onvif://www.onvif.org/Profile/Streaming</wsdd:Scopes><wsdd:XAddrs>http://10.0.0.4:1000/onvif/device_service</wsdd:XAddrs><wsdd:MetadataVersion>0</wsdd:MetadataVersion></wsdd:ProbeMatch></wsdd:ProbeMatches></SOAP-ENV:Body></SOAP-ENV:Envelope>

And after to_lowercase():

<?xml version="1.0" encoding="utf-8"?>
    <soap-env:envelope xmlns:soap-env="http://www.w3.org/2003/05/soap-envelope" xmlns:soap-enc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsdd="http://schemas.xmlsoap.org/ws/2005/04/discovery" xmlns:tdn="http://www.onvif.org/ver10/network/wsdl"><soap-env:header><wsa:messageid>urn:uuid:b7b46c8b-16e3-4b77-920e-edd1374a3fe6</wsa:messageid><wsa:relatesto>uuid:b800c7f9-24b5-4817-b87d-446e8fb76e49</wsa:relatesto><wsa:replyto soap-env:mustunderstand="true"><wsa:address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:address></wsa:replyto><wsa:to soap-env:mustunderstand="true">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:to><wsa:action soap-env:mustunderstand="true">http://schemas.xmlsoap.org/ws/2005/04/discovery/probematches</wsa:action><wsdd:appsequence instanceid="0" messagenumber="36"></wsdd:appsequence></soap-env:header><soap-env:body><wsdd:probematches><wsdd:probematch><wsa:endpointreference><wsa:address>urn:uuid:fb03dab7-1787-4e12-ab8b-4567327b23c6</wsa:address></wsa:endpointreference><wsdd:types>tdn:networkvideotransmitter</wsdd:types><wsdd:scopes>onvif://www.onvif.org/name/unknown onvif://www.onvif.org/profile/streaming</wsdd:scopes><wsdd:xaddrs>http://10.0.0.4:1000/onvif/device_service</wsdd:xaddrs><wsdd:metadataversion>0</wsdd:metadataversion></wsdd:probematch></wsdd:probematches></soap-env:body></soap-env:envelope>

If applicable:

  • this PR has an associated PR with documentation in akri-docs
  • this PR contains unit tests
  • added code adheres to standard Rust formatting (cargo fmt)
  • code builds properly (cargo build)
  • code is free of common mistakes (cargo clippy)
  • all Akri tests succeed (cargo test)
  • inline documentation builds (cargo doc)
  • version has been updated appropriately (./version.sh)

@kate-goldenring kate-goldenring added the bug Something isn't working label Sep 30, 2021
@bfjelds
Copy link
Collaborator

bfjelds commented Sep 30, 2021

My proposed fix: push this fix as version 0.6.19 and create new release and in the release CHANGELOG (see #394) put that ONVIF discovery does not work in versions 0.6.17 and 0.6.18 .

this seems fine ... i'm not super worried about versions 6.17 and 6.18 not working. bugs happen.

@@ -341,7 +345,7 @@ pub mod util {
"simple_onvif_discover - uris discovered by udp broadcast {:?}",
broadcast_responses
);
let mut filtered_uris = Vec::new();
let mut filtered_uris = std::collections::HashSet::new();
broadcast_responses.into_iter().for_each(|r| {
filtered_uris.extend(get_scope_filtered_uris_from_discovery_response(
Copy link
Contributor Author

@kate-goldenring kate-goldenring Sep 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filtered_uris are created by get_scope_filtered_uris_from_discovery_response which gets the uris from each discovery response. execute_filter is done when looking at the body of the discovery response. It is a text based (not api call) filter. It doesnt seem to make sense to get the uris and then do an api call to get scopes and filter

@romoh
Copy link
Contributor

romoh commented Sep 30, 2021

Is there a way to yank a release similar to what cargo supports ?
It is reasonable to create a new release with the fix and modify the bad release to add a warning (or label) mentioning the broken scenario.

@kate-goldenring
Copy link
Contributor Author

kate-goldenring commented Sep 30, 2021

Is there a way to yank a release similar to what cargo supports ? It is reasonable to create a new release with the fix and modify the bad release to add a warning (or label) mentioning the broken scenario.

I think that would definitely be the approach if other commits (changing versions) were added between the release and discovering the bug. Fortunately, since it was discovered quickly, we can effectively overwrite the release

Not to mention, i already deleted the release. Its that the containers and helm package still exist

@@ -310,7 +314,7 @@ pub mod util {
scopes_filters: Option<&FilterList>,
timeout: Duration,
) -> Result<Vec<String>, anyhow::Error> {
let mut broadcast_responses = std::collections::HashSet::new();
let mut broadcast_responses = Vec::new();
Copy link
Contributor

@romoh romoh Sep 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That can be a HashSet too, but I guess it doesn't provide much value at this scope.

@romoh
Copy link
Contributor

romoh commented Sep 30, 2021

Is there a way to yank a release similar to what cargo supports ? It is reasonable to create a new release with the fix and modify the bad release to add a warning (or label) mentioning the broken scenario.

I think that would definitely be the approach if other commits (changing versions) were added between the release and discovering the bug. Fortunately, since it was discovered quickly, we can effectively overwrite the release

Not to mention, i already deleted the release. Its that the containers and helm package still exist

Sounds good. yanked releases happen. Glad you found it early on.
On the other side, I'm wondering if we need to add more testing to catch similar issues in the future.

@kate-goldenring kate-goldenring merged commit d1494d6 into project-akri:main Sep 30, 2021
@kate-goldenring kate-goldenring deleted the onvif-bug branch September 30, 2021 18:21
@kate-goldenring
Copy link
Contributor Author

kate-goldenring commented Sep 30, 2021

Is there a way to yank a release similar to what cargo supports ? It is reasonable to create a new release with the fix and modify the bad release to add a warning (or label) mentioning the broken scenario.

I think that would definitely be the approach if other commits (changing versions) were added between the release and discovering the bug. Fortunately, since it was discovered quickly, we can effectively overwrite the release
Not to mention, i already deleted the release. Its that the containers and helm package still exist

Sounds good. yanked releases happen. Glad you found it early on. On the other side, I'm wondering if we need to add more testing to catch similar issues in the future.

Yeah i wonder if we want to try to set up e2e testing for onvif maybe that only runs on release or can be triggered by a test-onvif label. We could use this ONVIF mocking setup i created.

vincepnguyen pushed a commit that referenced this pull request Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants