setting core.refresh.hold to "forever" in /var/lib/snapd/config.json leads to "cannot unmarshal snap "core" option "refresh.hold" into *time.Time: parsing time "\"forever\"" as "\"2006-01-02T15:04:05Z07:00\"": cannot parse "forever\"" as "2006", json: "forever""

Bug #2051917 reported by Thomas Bechtold
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
Fix Committed
Undecided
Maciej Borzecki

Bug Description

The public cloud team wants to disable all snap refreshs during image build.
What we do currently in a chroot is:

$ pushd "$scratch_d/var/lib/snapd"
$ jq -c '.data.config.core.refresh.hold |= "forever"' state.json >state.json.tmp
$ mv state.json.tmp state.json
$ popd

but when such a image boots, the snapd.service journal contains the following message(s):

Feb 01 08:22:28 ip-172-31-37-149 snapd[380]: stateengine.go:149: state ensure error: internal error: cannot unmarshal snap "core" option "refresh.hold" into *time.Time: parsing time "\"forever\"" as "\"2006-01-02T15:04:05Z07:00\"": cannot parse "forever\"" as "2006", json: "forever"
Feb 01 08:22:28 ip-172-31-37-149 snapd[380]: stateengine.go:149: state ensure error: internal error: cannot unmarshal snap "core" option "refresh.hold" into *time.Time: parsing time "\"forever\"" as "\"2006-01-02T15:04:05Z07:00\"": cannot parse "forever\"" as "2006", json: "forever"
Feb 01 08:22:28 ip-172-31-37-149 snapd[380]: stateengine.go:149: state ensure error: internal error: cannot unmarshal snap "core" option "refresh.hold" into *time.Time: parsing time "\"forever\"" as "\"2006-01-02T15:04:05Z07:00\"": cannot parse "forever\"" as "2006", json: "forever"
Feb 01 08:22:28 ip-172-31-37-149 snapd[380]: stateengine.go:149: state ensure error: internal error: cannot unmarshal snap "core" option "refresh.hold" into *time.Time: parsing time "\"forever\"" as "\"2006-01-02T15:04:05Z07:00\"": cannot parse "forever\"" as "2006", json: "forever"

Revision history for this message
Maciej Borzecki (maciek-borzecki) wrote :

Can you indicate what is the version if the snapd package and the snapd snap installed in the system?

Revision history for this message
Thomas Bechtold (toabctl) wrote :

This is on Jammy amd64 on AWS EC2 with:

# snap list|grep snapd
snapd 2.61.1 20671 latest/stable canonical** snapd

# dpkg -l|grep snapd
ii snapd 2.58+22.04.1 amd64 Daemon and tooling that enable snap packages

# uname -a
Linux ip-172-31-34-150 6.2.0-1018-aws #18~22.04.1-Ubuntu SMP Wed Jan 10 22:54:16 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

Revision history for this message
Thomas Bechtold (toabctl) wrote :

@Maciej , I'm happy to provide access to a EC2 node if you want for investgation.

Changed in snapd:
assignee: nobody → Maciej Borzecki (maciek-borzecki)
status: New → In Progress
Revision history for this message
Nicholas Neumann (aggienick02) wrote :

I am also hitting this. I'm trying to do the same thing, but with Ubuntu 23.10 instead. I don't need to go to the lengths of purging snap, but just want my image to not try to update snaps. But if there's not a nice way to do that, I guess purging snap may be the only real option.

Revision history for this message
Maciej Borzecki (maciek-borzecki) wrote :

There's a PR up https://github.com/snapcore/snapd/pull/13544 hopefully this will be sorted out soon.

Revision history for this message
Nicholas Neumann (aggienick02) wrote :

@Maciej, thanks for pointing me to this. Looking at it was helpful, and also made me realize that a workaround until "forever" works is pretty easy, e.g.,

jq -c '.data.config.core.refresh.hold |= "2300-01-01T00:00:00Z"' state.json > state.json.tmp

(This seems to work well. effectiveRefreshHold returns 290 years from the current time, so this is safely a bit less than forever, just 275+ years.)

Changed in snapd:
status: In Progress → Fix Committed
Revision history for this message
Nicholas Neumann (aggienick02) wrote :

I noticed that even with refresh hold set, snapd still makes multiple calls daily to api.snapcraft.io. Is that expected? Is there any way to stop them?

Revision history for this message
Ernest Lotter (ernestl) wrote :

Fix will be released with snapd 2.62

Changed in snapd:
milestone: none → 2.62
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.