edgexfoundry / app-rfid-llrp-inventory

Apache License 2.0
9 stars 20 forks source link

[LLRP] CustomConfig setup bug #86

Closed ajcasagrande closed 2 years ago

ajcasagrande commented 2 years ago

I was looking at this code as an example for how to load the custom config, and noticed that this just doesn't seem right. It needs to be checked further.

Mostly around why it is loading the aliasesConfigKey

https://github.com/edgexfoundry/app-rfid-llrp-inventory/blob/993cf3e57aaceca8bb36ff677d4f27516283947c/internal/inventory/app/app.go#L81-L91

lenny-goodell commented 2 years ago

Agreed this incorrect. But it is still working for most part because the passed in key is only used to checking for existence in Consul. It uses the passed in struct to un-marshal the TOML. What we'll see is it always pushes config to Consul, which I just confirmed.

level=INFO ts=2022-06-21T19:26:02.7648941Z app=app-rfid-llrp-inventory source=config.go:229 msg="Checking if custom configuration ('Aliases') exists in Configuration Provider"
level=INFO ts=2022-06-21T19:26:02.7708223Z app=app-rfid-llrp-inventory source=config.go:391 msg="Loaded custom configuration from ./res/configuration.toml"
level=INFO ts=2022-06-21T19:26:02.8095057Z app=app-rfid-llrp-inventory source=config.go:270 msg="Custom Config loaded from file and pushed to Configuration Provider "

The result of this is any changes made to existing custom setting in Consul will be overwritten when the service restarts, :-( But since Aliases is empty in the TOML file, they don't get overridden. Just the values in [AppCustom.AppSettings]

lenny-goodell commented 2 years ago

@ajcasagrande , the better example of using Custom Configuration is here: https://github.com/edgexfoundry/app-functions-sdk-go/blob/main/app-service-template/main.go#L74-L98

lenny-goodell commented 2 years ago

The workaround for this bug is to set this values via Env Overrides such as APPCUSTOM_APPSETTINGS_AGEOUTHOURS=5