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: Both path and paths need to be supported to address the breaking change until the next release #290

Merged
merged 8 commits into from
Sep 19, 2023

Conversation

presatish
Copy link
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)

@codecov-commenter
Copy link

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 <[email protected]>

type EdgeXErrorWrapper struct{}

func (e EdgeXErrorWrapper) CommandError(command string, err error) errors.EdgeX {
return errors.NewCommonEdgeX(errors.KindServerError, fmt.Sprintf("failed to execute %s command", command), err)
}

// 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
Contributor

Choose a reason for hiding this comment

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

Copy link
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 :-)

@@ -14,23 +14,17 @@ import (
"github.com/edgexfoundry/go-mod-core-contracts/v3/errors"
)

const (
redactedStr = "//<redacted>@"
Copy link
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
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
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.

// RefreshDevicePaths checks whether the existing device matches the connected device.
// 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
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
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
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
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
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
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 <[email protected]>
PixFmtDepthZ16: Depth,
}

const (
Copy link
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 <[email protected]>
Copy link
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
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