Skip to content

fix: Both path and paths need to be supported to address the breaking change until the next release#290

Merged
presatish merged 8 commits intoedgexfoundry:mainfrom
EdgeX-Camera-Management:support-path
Sep 19, 2023
Merged

fix: Both path and paths need to be supported to address the breaking change until the next release#290
presatish merged 8 commits intoedgexfoundry:mainfrom
EdgeX-Camera-Management:support-path

Conversation

@presatish
Copy link
Copy Markdown
Contributor

If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/edgex-go/blob/main/.github/Contributing.md

PR Checklist

Please check if your PR fulfills the following requirements:

  • I am not introducing a breaking change (if you are, flag in conventional commit message with BREAKING CHANGE: describing the break)
  • I am not introducing a new dependency (add notes below if you are)
  • I have added unit tests for the new feature or bug fix (if not, why?)
  • I have fully tested (add details below) this the new feature or bug fix (if not, why?)
  • I have opened a PR for the related docs change (if not, why?)

Testing Instructions

  • make test
  • make build
  • make docker
  • Get the edgex core and device usb service running in 3.0 version (Minnesota)
  • The usb devices get registered in edgex with Path as one of the protocol properties which is a string.
  • Stop the containers without deleting the volume (make down)
  • Checkout the main version of edgex compose and get the core services running.
  • Get this version of device service running natively or even in docker
  • The same devices get discovered again and Path changes to Paths which is an array of string.

New Dependency Instructions (If applicable)

Signed-off-by: preethi-satishcandra <preethi.satishchandra@intel.com>
Signed-off-by: preethi-satishcandra <preethi.satishchandra@intel.com>
Signed-off-by: preethi-satishcandra <preethi.satishchandra@intel.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 15, 2023

Codecov Report

Merging #290 (18a7ff3) into main (608e40c) will decrease coverage by 0.05%.
The diff coverage is 0.00%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@           Coverage Diff            @@
##            main    #290      +/-   ##
========================================
- Coverage   4.79%   4.74%   -0.05%     
========================================
  Files          8       8              
  Lines       1293    1306      +13     
========================================
  Hits          62      62              
- Misses      1231    1244      +13     
Files Changed Coverage Δ
internal/driver/device.go 2.83% <ø> (ø)
internal/driver/driver.go 3.21% <0.00%> (-0.06%) ⬇️
internal/driver/helper.go 80.95% <0.00%> (ø)

Signed-off-by: preethi-satishcandra <preethi.satishchandra@intel.com>
}

// redact removes all instances of basic auth (ie. rtsp://username:password@server) from a url
// redact removes all instances of basic auth (i.e. rtsp://username:password@server) from an url
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Even the silly IDE suggested to me that it should be an :-)

)

const (
redactedStr = "//<redacted>@"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I feel this makes more sense being defined here, closer to its usage

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, I thought it would be better to keep all constants in one place.

Comment on lines -13 to -17
const (
RTSPServerModeInternal RTSPServerMode = "internal"
RTSPServerModeExternal RTSPServerMode = "external"
RTSPServerModeNone RTSPServerMode = "none"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

these belong to the type RTSPServerMode string above, and implement an enum.

// If there is a mismatch between them, scan all paths to find the matching device
// and update the existing device with the correct path.
func (d *Driver) RefreshDevicePaths(cd models.Device) {
d.updatePathToPaths(cd)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this the only place that needs to call this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes this function is called when the service starts up and also when the discovery is called.

if value, ok := cd.Protocols[UsbProtocol][Path]; ok {
if value != nil {
cd.Protocols[UsbProtocol][Paths] = []string{value.(string)}
delete(cd.Protocols[UsbProtocol], "Path")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought we had discussed keeping both fields in the metadata because otherwise, when you get a device it will be missing the Path field that used to be there. @lenny-intel thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't remember discussing about this, you mean creating Metadata section within protocols like how we have in onvif service? Existing Path field will be changed to Paths with this code which is easier to maintain. We have added in the docs too that Path field is deprecated and users should be using Paths. I think @lenny-intel was fine with this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I mean keeping bath Path and Paths in the Onvif protocol properties, and using code to sync them. As long as @lenny-intel is OK with this approach I am fine as well, since this will be cleaner.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, we have to keep both. My thought is if a device is loaded that has Path set, then set Paths to the single Path. That way the driver code always deals with Paths.

Signed-off-by: preethi-satishcandra <preethi.satishchandra@intel.com>
PixFmtDepthZ16: Depth,
}

const (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would put these back where they were, or move the type definition down here. I like them being together.

Signed-off-by: preethi-satishcandra <preethi.satishchandra@intel.com>
Copy link
Copy Markdown
Contributor

@ajcasagrande ajcasagrande left a comment

Choose a reason for hiding this comment

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

LGTM

@presatish presatish merged commit 884b56a into edgexfoundry:main Sep 19, 2023
@presatish presatish deleted the support-path branch September 19, 2023 17:12
@vyshali-chitikeshi
Copy link
Copy Markdown
Contributor

Though its already merged into main, I did validaiton to ensure end-to-end testing (discovering usb cameras, adding them egex metadata and rest-api's) works correctly both with 'path' and 'paths' fields and it looks good.
Validated with below combinations of code:

  1. Latest (main branch) egex and Latest (main branch) USB code - works with 'paths'
  2. Latest (main branch) egex and 3.0 USB code - works with 'path'
  3. 3.0 egex and Latest (main branch) USB code - works with 'paths'
  4. 3.0 egex and 3.0 USB code - works with 'path

attaced scrresnhots for refecne.
latest_edgex_and_3.0_usb_device_usb.txt
3.0_edgex_and_latest_usb_device_path.txt
3.0_edgex_and_3.0_usb_device_path.txt
latest_edgex_and_latest_usb_device_path.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config variable Path changed to Paths to support real sense cameras

5 participants