balena-io-modules / balena-preload

Script for preloading containers onto balena device images
https://www.balena.io/
Apache License 2.0
35 stars 8 forks source link

"Release not found" error when the commit value is "latest" #204

Closed pdcastro closed 5 years ago

pdcastro commented 5 years ago

A customer reported that "balena preload" stopped working and I believe I have narrowed the issue down to the use of the alias "latest" instead of a commit hash value. I believe I have further identified the issue to have been introduced by the following PR:

https://github.com/balena-io/balena-preload/pull/201/files

Because when I pinned balena-preload to version 8.1.1 in the CLI's package.json, using the "-c latest" option seemed to work OK.

balena-ci commented 5 years ago

[pdcastro] This issue has attached support thread https://jel.ly.fish/#/support-thread~46eeb6c0-f831-44ed-bb04-befa8aeacf72

pdcastro commented 5 years ago

@Page-, @zvin, does it sound plausible that the PR I linked in this issue is the cause of the "Release not found" error? Is the fix obvious to you? Thanks!

zvin commented 5 years ago

I think the "latest" alias is only used in the cli https://github.com/balena-io/balena-cli/blob/master/lib/actions/preload.coffee#L288-L291

zvin commented 5 years ago

@pdcastro you're right, the preloader can be created with "latest" here https://github.com/balena-io/balena-cli/blob/master/lib/actions/preload.coffee#L237 , then _fetchApplication is called before this https://github.com/balena-io/balena-cli/blob/master/lib/actions/preload.coffee#L289 and the releaseFilter is incorrect.

pdcastro commented 5 years ago

A piece of data I forgot to add: when "--commit latest" was used, the CLI would print:

Release not found: 1e152b2abe0f7ba8891b32e6ba2fab2a

Meaning that somewhere somehow, "latest" was resolved to "1e152b2abe0f7ba8891b32e6ba2fab2a".

zvin commented 5 years ago

We could avoid filtering by commit here https://github.com/balena-io/balena-preload/blob/fbe363f3ffe8d6a43fe5834c25405bfafd21ceae/lib/preload.js#L501 if this.commit is "latest". Maybe there's a way to only get the latest release in that case? cc @Page-