Closed farshidtz closed 1 year ago
For the services listed, environment variable overrides will not be applied:
Here is an example:
snap install edgexfoundry --edge
sudo snap set edgexfoundry apps.support-scheduler.config.service-startupmsg='manul-snap-testing-A'
sleep 10
sudo snap restart edgexfoundry.support-scheduler
app=support-scheduler source=config.go:143 msg="Common configuration loaded from the Configuration Provider. No overrides applied"
In order to run the services without the config provider, the services should have the full set of configurations (local and common) available to them. The default service configuration files only include the local config. We should either inject the common config parts into the same file, or point to the common config file via the respective common config environment variable override. The latter is currently being implemented; see https://github.com/edgexfoundry/go-mod-bootstrap/pull/487.
The common config file is available at https://github.com/edgexfoundry/edgex-go/blob/main/cmd/core-common-config-bootstrapper/res/configuration.yaml. It can be sourced from the edgexfoundry snap or for quick/manual testing directly from github.
An example of making service run without config provider:
# Use no configuration provider
sudo snap set edgexfoundry apps.core-data.config.edgex-config-provider='none'
# Pull common configuration
sudo snap set edgexfoundry apps.core-data.config.edgex-common-config=./config/core-common-config-bootstrapper/res/configuration.yaml
# Set environment variables
sudo snap set edgexfoundry apps.core-data.config.service-startupmsg='manual-snap-testing'
snap restart edgexfoundry.core-data
The behavior of core-data has changed compared to its previous version:
$ snap install edgexfoundry --edge
edgexfoundry (edge) 3.0.0-dev.114 from Canonical✓ installed
$ sudo snap set edgexfoundry apps.core-data.config.edgex-config-provider='none'
$ sudo snap set edgexfoundry apps.core-data.config.edgex-common-config=./config/core-common-config-bootstrapper/res/configuration.yaml
$ sudo snap set edgexfoundry apps.core-data.config.service-startupmsg='manual-snap-testing'
$ snap restart edgexfoundry.core-data
Mär 27 14:51:55 ubuntu systemd[1]: Started Service for snap application edgexfoundry.core-data.
Mär 27 14:51:55 ubuntu edgex-core-data.service-config-overrides.sh[34122]: sourcing /var/snap/edgexfoundry/4359/config/core-data/res/core-data.env
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.473473087Z app=core-data source=secret.go:65 msg="Creating SecretClient"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.473585204Z app=core-data source=variables.go:457 msg="Variables override of 'SecretStore/TokenFile' by environment variable: SECRETSTORE_TOKENFILE=/var/snap/edgexfoundry/4359/secrets/core-data/secrets-token.json"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.473645868Z app=core-data source=secret.go:159 msg="SecretStore information created with 1 overrides applied"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.473653455Z app=core-data source=secret.go:75 msg="Reading secret store configuration and authentication token"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.473660562Z app=core-data source=secret.go:200 msg="load token from file"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.473732885Z app=core-data source=secret.go:93 msg="Attempting to create secret client"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.474765087Z app=core-data source=secret.go:104 msg="Created SecretClient"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.474775605Z app=core-data source=secret.go:109 msg="SecretsFile not set, skipping seeding of service secrets."
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.474787185Z app=core-data source=variables.go:457 msg="Variables override of 'Configuration Provider Information' by environment variable: EDGEX_CONFIG_PROVIDER=none"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.474795573Z app=core-data source=variables.go:457 msg="Variables override of '-cc/--commonConfig' by environment variable: EDGEX_COMMON_CONFIG=./config/core-common-config-bootstrapper/res/configuration.yaml"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.474801088Z app=core-data source=config.go:565 msg="Loading configuration file from ./config/core-common-config-bootstrapper/res/configuration.yaml"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: level=INFO ts=2023-03-27T12:51:55.475239929Z app=core-data source=secrets.go:277 msg="kick off token renewal with interval: 30m0s"
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: panic: runtime error: invalid memory address or nil pointer dereference
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x98 pc=0x7553df]
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: goroutine 1 [running]:
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/environment.(*Variables).buildPaths(0xc0004b0f38?, 0x5?)
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3@v3.0.0-dev.56/bootstrap/environment/variables.go:236 +0x11f
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/environment.(*Variables).buildPaths(0xc0004b10a8?, 0x5?)
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3@v3.0.0-dev.56/bootstrap/environment/variables.go:243 +0x1d4
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/environment.(*Variables).buildPaths(0x852dc0?, 0xc0004423e0?)
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3@v3.0.0-dev.56/bootstrap/environment/variables.go:243 +0x1d4
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/environment.(*Variables).OverrideConfigMapValues(0xc000012378, 0x61c?)
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3@v3.0.0-dev.56/bootstrap/environment/variables.go:149 +0x3e
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/environment.(*Variables).OverrideConfiguration(0xc0000b69a0?, {0x8ccd00, 0xc0003c5e00})
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3@v3.0.0-dev.56/bootstrap/environment/variables.go:130 +0x14f
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap/config.(*Processor).Process(0xc0000b69a0, {0x9132b7, 0x9}, {0x90f6dc, 0x5}, {0x912c27, 0x8}, {0x9ce3b8, 0xc0003c5e00}, {0x9ceea0, ...})
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3@v3.0.0-dev.56/bootstrap/config/config.go:188 +0x765
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap.RunAndReturnWaitGroup({0x9cb2d0, 0xc0003eeaa0}, 0xc0003fb7b0, {0x9ce418?, 0xc00042a770}, {0x9132b7, 0x9}, {0x912c27, 0x8}, {0x9ce3b8, ...}, ...)
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3@v3.0.0-dev.56/bootstrap/bootstrap.go:126 +0x4ac
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3/bootstrap.Run({0x9cb2d0?, 0xc0003eeaa0?}, 0xc0003fb7b0, {0x9ce418?, 0xc00042a770?}, {0x9132b7?, 0x0?}, {0x912c27?, 0x0?}, {0x9ce3b8, ...}, ...)
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/go-mod-bootstrap/v3@v3.0.0-dev.56/bootstrap/bootstrap.go:215 +0x11d
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/edgex-go/internal/core/data.Main({0x9cb2d0, 0xc0003eeaa0}, 0x405391?, 0xc000001d40)
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/edgex-go/internal/core/data/main.go:62 +0x705
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: main.main()
Mär 27 14:51:55 ubuntu edgexfoundry.core-data[34092]: github.com/edgexfoundry/edgex-go/cmd/core-data/main.go:27 +0x89
Mär 27 14:51:55 ubuntu systemd[1]: snap.edgexfoundry.core-data.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Mär 27 14:51:55 ubuntu systemd[1]: snap.edgexfoundry.core-data.service: Failed with result 'exit-code'.
@MonicaisHer please report the bug at https://github.com/edgexfoundry/go-mod-bootstrap
@farshidtz sure, reported: https://github.com/edgexfoundry/go-mod-bootstrap/issues/494
As expected by #4448, the snap tests have started failing since this change because the overrides no longer apply on top of configurations coming from config provider:
Common configuration loaded from the Configuration Provider. No overrides applied
Need to change the snap tests to no longer test that, or make the services run without config provider.
Failing test result: