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

feat: add better error handlings when common config is missing #566

Merged

Conversation

jim-wang-intel
Copy link
Contributor

Gives a better error messages when the developer runs with hybrid mode but not including common config.

Closes: #564

If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/go-mod-bootstrap/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

  • git clone this PR
  • you can use device-simple from device-sdk repo to test this out when running in hybrid mode and don't provide common config (i.e. no -cc flag in place when running it)
  • in the device sdk, change the go-mod-bootstrap import to the local cloned go-mod-bootstrap in go.mod file
  • run make first from the base root of device-sdk repo to compile the device-sdk together with the local go-mod-bootstrap
  • change directory to device-simple under example/cmd: cd ./example/cmd/device-simple
  • run make again to compile the device simple app: make
  • run with ./device-simple without any flags like -cc or -d
  • you should expect to see some error message like
"Service.RequestTime found empty in bootstrap conifg, missing common config? Use -cp or -cc flags for common config"
  • you could now edit the configuration.yml in the res folder of device-simple to add the missing entries or items to fix this error message to go further until you see the app is starting or running without bootstrapping failed message in the log

New Dependency Instructions (If applicable)

Gives a better error messages when the developer runs with hybrid mode but not including common config.

  Closes: edgexfoundry#564

Signed-off-by: Jim Wang <[email protected]>
@@ -110,6 +110,11 @@ func (cb *ClientsBootstrap) BootstrapHandler(
return false
}

if len(config.GetBootstrap().Service.RequestTimeout) == 0 {
lc.Error("Service.RequestTimeout found empty in bootstrap config, missing common config? Use -cp or -cc flags for common config")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
lc.Error("Service.RequestTimeout found empty in bootstrap config, missing common config? Use -cp or -cc flags for common config")
lc.Error("Service.RequestTimeout found empty in service's configuration, missing common config? Use -cp or -cc flags for common config")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

all suggestions updated

bootstrap/handlers/httpserver.go Outdated Show resolved Hide resolved
bootstrap/handlers/httpserver.go Outdated Show resolved Hide resolved
bootstrap/registration/registry.go Outdated Show resolved Hide resolved
Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add better error handling in bootstrap handlers when Common Config is missing
2 participants