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(snap): Install Unit of Measure config file on upgrade #4125

Merged
merged 3 commits into from
Aug 22, 2022

Conversation

farshidtz
Copy link
Member

@farshidtz farshidtz commented Aug 15, 2022

PR #4119 added the following environment variable:

UOM_UOMFILE: $SNAP_DATA/config/core-metadata/res/uom.toml

This makes the edge releases of snap backward incompatible as of v2.3.0-dev.45 because this file doesn't exist when upgrading from an older version. The latest snap beta release which isn't broken is 2.3.0-dev.44 (snap rev 5898/5899). This fix works when upgrading from the latest beta or older.

This PR adds the logic to add the configuration file when upgrading (i.e. using snap refresh).

Signed-off-by: Farshid Tavakolizadeh farshid.tavakolizadeh@canonical.com

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

Reproduce the error:

$ snap install edgexfoundry --channel=latest/stable
edgexfoundry 2.2.0+2 from Canonical✓ installed

$ snap refresh edgexfoundry --channel=latest/edge
edgexfoundry (edge) 2.3.0-dev.46 from Canonical✓ refreshed

$ snap logs -n 100 edgexfoundry.core-metadata | grep -i ERROR
2022-08-15T16:16:26+02:00 edgexfoundry.core-metadata[386550]: level=ERROR ts=2022-08-15T14:16:26.714636738Z app=core-metadata source=httpserver.go:143 msg="Web server failed: http: Server closed"
2022-08-15T16:17:40+02:00 edgexfoundry.core-metadata[388065]: level=ERROR ts=2022-08-15T14:17:40.24683483Z app=core-metadata source=bootstrap.go:42 msg="could not load unit of measure configuration file (/var/snap/edgexfoundry/3904/config/core-metadata/res/uom.toml): open /var/snap/edgexfoundry/3904/config/core-metadata/res/uom.toml: no such file or directory"

Test the changes using the snap built from this branch:

$ snap install edgexfoundry --channel=latest/stable
edgexfoundry 2.2.0+2 from Canonical✓ installed

$ snap refresh edgexfoundry --channel=latest/edge/pr-4125
edgexfoundry (edge/pr-4125) 2.3.0-dev.46 from Canonical✓ refreshed

$ snap logs -n 2 edgexfoundry.core-metadata 
2022-08-15T16:25:57+02:00 edgexfoundry.core-metadata[395550]: level=INFO ts=2022-08-15T14:25:57.308622394Z app=core-metadata source=message.go:55 msg="This is the EdgeX Core Metadata Microservice"
2022-08-15T16:25:57+02:00 edgexfoundry.core-metadata[395550]: level=INFO ts=2022-08-15T14:25:57.308628766Z app=core-metadata source=message.go:58 msg="Service started in: 85.428935ms"

$ sudo journalctl -n 100 | grep post-refresh
systemd[1]: Started snap.edgexfoundry.hook.post-refresh.0409b2f7-0d0b-42dd-97e5-e865eaf1dece.scope.
edgexfoundry.post-refresh[394831]: Refreshing from  (3722) to 2.3.0-dev.46 (3912)
...
edgexfoundry.post-refresh[394843]: Installing /snap/edgexfoundry/3912/config/core-metadata/res/uom.toml
systemd[1]: snap.edgexfoundry.hook.post-refresh.0409b2f7-0d0b-42dd-97e5-e865eaf1dece.scope: Deactivated successfully.

New Dependency Instructions (If applicable)

Signed-off-by: Farshid Tavakolizadeh <farshid.tavakolizadeh@canonical.com>
@codecov-commenter
Copy link

Codecov Report

Merging #4125 (8b19799) into main (166620d) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #4125   +/-   ##
=======================================
  Coverage   43.61%   43.61%           
=======================================
  Files         120      120           
  Lines       10630    10630           
=======================================
  Hits         4636     4636           
  Misses       5607     5607           
  Partials      387      387           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

snap/hooks/pre-refresh Outdated Show resolved Hide resolved
Signed-off-by: Farshid Tavakolizadeh <farshid.tavakolizadeh@canonical.com>
Signed-off-by: Farshid Tavakolizadeh <farshid.tavakolizadeh@canonical.com>
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
5.1% 5.1% Duplication

Copy link
Contributor

@MonicaisHer MonicaisHer left a comment

Choose a reason for hiding this comment

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

@farshidtz Thank you, looks good!

@farshidtz
Copy link
Member Author

@cloudxxx8 could you please approve this? It's been reviewed.

@lenny-goodell lenny-goodell merged commit 0b67b21 into edgexfoundry:main Aug 22, 2022
@farshidtz farshidtz deleted the snap-upgrade-uom branch August 22, 2022 15:34
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.

4 participants