-
Notifications
You must be signed in to change notification settings - Fork 485
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
refactor(snap): Use snapctl and log packages #4187
refactor(snap): Use snapctl and log packages #4187
Conversation
Signed-off-by: Farshid Tavakolizadeh <farshid.tavakolizadeh@canonical.com>
c4e9203
to
57ab585
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@farshidtz Thank you for the lots of changes! It works as expected. I have some minor questions please see the inline comments. And here is what I tested:
snap install edgexfoundry_2.3.0-dev.83_amd64.snap --dangerous
sudo snap set edgexfoundry env.core-data.service.port=1111
snap set edgexfoundry.kuiper=on
snap set edgexfoundry app-options=true
snap set edgexfoundry apps.core-data.config.service-port=2222
snap restart edgexfoundry.core-data
# install hook logs
Okt 10 13:58:33 ubuntu systemd[1]: Started snap.edgexfoundry.hook.install.f2799bcf-e72b-43c9-a7f8-04d5c9b29125.scope.
Okt 10 13:58:39 ubuntu edgexfoundry.install[1209658]: Disabling all services: [edgexfoundry.consul edgexfoundry.core-command edgexfoundry.kuiper edgexfoundry.redis edgexfoundry.vault edgexfoundry.security-consul-bootstrapper edgexfoundry.security-secretstore-setup edgexfoundry.app-service-configurable edgexfoundry.postgres edgexfoundry.support-notifications edgexfoundry.support-scheduler edgexfoundry.sys-mgmt-agent edgexfoundry.core-data edgexfoundry.core-metadata edgexfoundry.kong-daemon edgexfoundry.security-bootstrapper-redis edgexfoundry.security-proxy-setup]
Okt 10 13:58:39 ubuntu systemd[1]: snap.edgexfoundry.hook.install.f2799bcf-e72b-43c9-a7f8-04d5c9b29125.scope: Succeeded.
Okt 10 13:58:39 ubuntu edgexfoundry.configure[1209935]: install-mode=defer-startup
Okt 10 13:58:39 ubuntu edgexfoundry.configure[1209935]: install-mode=defer-startup; starting disabled services
# configure hook logs
Okt 10 14:05:04 ubuntu systemd[1]: Started snap.edgexfoundry.hook.configure.51f81f20-e239-4438-9fe1-635f9ea4acac.scope.
Okt 10 14:05:04 ubuntu edgexfoundry.configure[1215288]: Processing config options
Okt 10 14:05:04 ubuntu edgexfoundry.configure[1215288]: Processing app options: false
Okt 10 14:05:04 ubuntu edgexfoundry.configure[1215288]: Started
Okt 10 14:05:04 ubuntu edgexfoundry.configure[1215288]: install-mode=defer-startup
Okt 10 14:05:04 ubuntu edgexfoundry.configure[1215288]: install-mode=defer-startup; starting disabled services
Okt 10 14:05:04 ubuntu systemd[1]: snap.edgexfoundry.hook.configure.51f81f20-e239-4438-9fe1-635f9ea4acac.scope: Succeeded.
Okt 10 14:05:30 ubuntu edgexfoundry.security-consul-bootstrapper[1216021]: level=INFO ts=2022-10-10T12:05:30.613824293Z app=security-bootstrapper source=command.go:699 msg="successfully configure Consul access for secretstore"
Okt 10 14:05:32 ubuntu systemd[1]: Started snap.edgexfoundry.hook.configure.32d12c39-5d90-48cd-81d5-95dd65fc4089.scope.
Okt 10 14:05:32 ubuntu edgexfoundry.configure[1216360]: Processing config options
Okt 10 14:05:32 ubuntu edgexfoundry.configure[1216360]: Processing app options: false
Okt 10 14:05:32 ubuntu edgexfoundry.configure[1216360]: Started
Okt 10 14:05:32 ubuntu edgexfoundry.configure[1216360]: install-mode=
Okt 10 14:05:32 ubuntu systemd[1]: snap.edgexfoundry.hook.configure.32d12c39-5d90-48cd-81d5-95dd65fc4089.scope: Succeeded.
Okt 10 14:05:32 ubuntu systemd[1]: Started snap.edgexfoundry.hook.configure.e61a057b-c5a9-4dda-8322-e93be18d2a3e.scope.
Okt 10 14:05:32 ubuntu edgexfoundry.configure[1216620]: Processing config options
Okt 10 14:05:32 ubuntu edgexfoundry.configure[1216620]: Processing app options: true
Okt 10 14:05:32 ubuntu edgexfoundry.configure[1216620]: Unset all 'env.' options.
Okt 10 14:05:32 ubuntu edgexfoundry.configure[1216620]: Mapping add-known-secrets to ADD_KNOWN_SECRETS
Okt 10 14:05:32 ubuntu edgexfoundry.configure[1216620]: Mapping add-secretstore-tokens to ADD_SECRETSTORE_TOKENS
Okt 10 14:05:32 ubuntu edgexfoundry.configure[1216620]: Mapping add-registry-acl-roles to ADD_REGISTRY_ACL_ROLES
Okt 10 14:05:32 ubuntu edgexfoundry.configure[1216620]: Writing to env file /var/snap/edgexfoundry/x1/config/security-secretstore-setup/res/security-secretstore-setup.env: ADD_KNOWN_SECRETS="redisdb[app-functional-tests],redisdb[app-rules-engine],redisdb[app-http-export],redisdb[app-mqtt-export],redisdb[app-external-mqtt-trigger],redisdb[app-push-to-core],redisdb[app-rfid-llrp-inventory],redisdb[application-service],redisdb[device-rest],redisdb[device-virtual],redisdb[device-camera],redisdb[device-mqtt],redisdb[device-modbus],redisdb[device-coap],redisdb[device-snmp],redisdb[device-gpio],redisdb[device-bacnet],redisdb[device-grove],redisdb[device-uart],redisdb[device-rfid-llrp],redisdb[device-usb-camera],redisdb[device-onvif-camera],redisdb[edgex-ekuiper]" ADD_SECRETSTORE_TOKENS="app-functional-tests,app-rules-engine,app-http-export,app-mqtt-export,app-external-mqtt-trigger,app-push-to-core,app-rfid-llrp-inventory,application-service,device-camera,device-mqtt,device-modbus,device-coap,device-snmp,device-gpio,device-bacnet,device-grove,device-uart,device-rfid-llrp,device-usb-camera,device-onvif-camera,edgex-ekuiper"
Okt 10 14:05:32 ubuntu edgexfoundry.configure[1216620]: Writing to env file /var/snap/edgexfoundry/x1/config/security-bootstrapper/res/security-bootstrapper.env: ADD_REGISTRY_ACL_ROLES="app-functional-tests,app-rules-engine,app-http-export,app-mqtt-export,app-external-mqtt-trigger,app-push-to-core,app-rfid-llrp-inventory,application-service,device-camera,device-mqtt,device-modbus,device-coap,device-snmp,device-gpio,device-bacnet,device-grove,device-uart,device-rfid-llrp,device-usb-camera,device-onvif-camera,edgex-ekuiper"
Okt 10 14:05:32 ubuntu edgexfoundry.configure[1216620]: Started
Okt 10 14:05:32 ubuntu edgexfoundry.configure[1216620]: install-mode=
Okt 10 14:05:32 ubuntu systemd[1]: snap.edgexfoundry.hook.configure.e61a057b-c5a9-4dda-8322-e93be18d2a3e.scope: Succeeded.
# options logs
Okt 10 14:05:32 ubuntu edgexfoundry.options[1216162]: Configuring options for security-proxy
Okt 10 14:05:32 ubuntu edgexfoundry.options[1216183]: Configuring options for secrets-config
os.Exit(1) | ||
} | ||
hooks.Info("edgexfoundry:configure: started") | ||
log.Info("Started") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about moving this info to line 520, so it will be ahead of processing app options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have addressed this and your next comment in my upcoming refactoring, which will be added once this PR is merged. See https://github.com/farshidtz/edgex-go/blob/cbd7714b276f42495f659f666f7270833e296979/snap/local/helper-go/configure.go#L544-L551
If you agree, I'd like to keep it that way to avoid merge conflicts.
|
||
deferStartup := (val == "defer-startup") | ||
hooks.Info(fmt.Sprintf("edgexfoundry:configure: deferStartup=%v", deferStartup)) | ||
log.Info("install-mode=%s", installMode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Info("install-mode=%s", installMode) | |
log.Infof(`install-mode="%s"`, installMode) |
It would be clear if install-mode
is unset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree and I will address it in my next PR. See my previous comment: #4187 (comment)
This refactoring is to make use of the new snapctl and log packages from the same module.
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:
BREAKING CHANGE:
describing the break)Testing Instructions
New Dependency Instructions (If applicable)