Use JSON serialization for balena build secrets#79
Conversation
|
No issues from my side |
See balena-io-modules/balena-compose#79 Change-type: patch Signed-off-by: Ken Bannister <kb2ma@runbox.com>
|
@pipex I think that we need to also update the package.json to use |
|
hmm, I'm not sure @thgreasi, because docker-modem will only stringify Object or Array fields, if you give it a string it won't touch it right? |
See balena-io-modules/balena-compose#79 Change-type: patch Signed-off-by: Ken Bannister <kb2ma@runbox.com>
|
@pipex I am able to recreate the error locally when building on a local mode device. I set up build secrets as described in the docs. The commit here fixes the original issue, but I am able to demonstrate another instance of the problem. Using the same command, I now see the error in the transcript below. It looks like it is originating in A couple of other notes: I also can recreate the SecretRemovalError with a Also I wonder about SecretRemovalError: |
ea4d031 to
96f6c3b
Compare
|
Updated the code @kb2ma, let me know if that works |
|
Hmm, I had not seen the reference to |
Pull request was converted to draft
96f6c3b to
b0d173b
Compare
|
@kb2ma nice catch with |
See balena-io-modules/balena-compose#79 Change-type: patch Signed-off-by: Ken Bannister <kb2ma@runbox.com>
|
My tests above in balenaCLI pass now. The CLI build was using docker-modem v5.0.6. @pipex , @thgreasi -- Regarding the need to use docker-modem ^5.0.6: With this PR we modify balena-compose to pre-stringify some arrays that no longer are being stringified in docker-modem v5.0.6. So, if these modifications run on docker-modem <v5.0.6, docker-modem will just stringify something that already is a string, which should be a no-op. Having said that, I agree we should force docker-modem ^5.0.6 just so we don't have to think about use of older versions. Any new builds with docker-modem as a dependency probably will bring in v5.0.6 anyway, right? Once we have consensus on this question, I think the PR is ready to go. |
The latest code addresses my concern. Not ready to approve PR yet though.
As I understand it, pre 5.0.6, docker-modem would only JSON stringify arrays (or objects). If given a string, it would pass it through so there should not be any problems with this code. That being said, I agree that it probably better to require docker-modem 5.0.6 (as peer dependency maybe?) @kb2ma @thgreasi |
|
Added a new commit requiring docker-modem as peer dependency |
| "versionist": { | ||
| "publishedAt": "2025-04-11T13:21:54.965Z" | ||
| } | ||
| "name": "@balena/compose", |
There was a problem hiding this comment.
This looks like a whitespace issue throughout the file.
c8af505 to
ebfc9b6
Compare
See balena-io-modules/balena-compose#79 Change-type: patch Signed-off-by: Ken Bannister <kb2ma@runbox.com>
|
@thgreasi I just tested balena-io/balena-cli#2935 based on the latest commit here, ebfc9b6. It works fine. The use of peerDependencies for docker-modem seems OK, but I'm not familiar with it. If it looks fine to you, I support approving this PR. |
|
@pipex I have not used a peer dependency in the past. Research shows the common use is for a plugin to specify a peer dependency on the framework it is built on. The idea is to say that a package depends on general version of the framework, like v3.x, to avoid installation with other plugins that require for example v4.x of the framework. I'm also confused about also specifying a separate devDependency in addition to the peerDependency. So, let's compare: If we use a regular dependency like ^5.0.6, we are saying that v5.0.6 to <v5.1.0 are OK. Can you describe how peerDependency ^5.0.6 plus devDependency 5.0.6 works better? What case does it cover that the regular dependency does not? Also, how does this relate to an app like balena-cli that specifies balena-compose, docker-modem, and dockerode versions? https://docs.npmjs.com/cli/v11/configuring-npm/package-json#peerdependencies |
|
@kb2ma AFAIU Dev dependencies are for developing the project itself, e.g. compiling and running tests. Peer dependencies tell users of the library what version of the dependency they need to use to work with the library. I'm not entirely sure the dev dependency is needed in this specific case but it doesn't hurt. The exact 5.0.6 version required for the devDependency was an oversight |
ebfc9b6 to
7e152d6
Compare
|
The build is now failing because of the automated docker-progress bump and a bug that was introduced in the latest minor version. This fixes that problem balena-io-modules/docker-progress#76 |
| "docker-modem": "^5.0.3", | ||
| "docker-progress": "^5.1.0", | ||
| "dockerfile-ast": "^0.7.0", | ||
| "dockerode": "^4.0.2", |
There was a problem hiding this comment.
Should we bump dockerode to ^4.0.4, which is the version that bumped docker-modem to ^5.0.6 ?
PS: fwiw the cli atm is on 4.0.5
| "typed-error": "^3.2.1" | ||
| }, | ||
| "peerDependencies": { | ||
| "docker-modem": "^5.0.6", |
There was a problem hiding this comment.
I guess that docker-modem became a devDependency now b/c we only use it in a type import.
I don't think we need it as a peerDepenency though 🤔
Wouldn't bumping dockerrode be enough?
If you just want to precautions and make 100% sure that docker-modem is present, then I'm fine w/ keeping it as a peerDependency.
Build secrets make use of a `volumes` option passed to the build image docker API. This option is only available in balenaEngine. With the changes on apocas/docker-modem#181, this array will be serialized using URL serialization by dockerode, which is not accepted by balenaEngine. Change-type: patch
7e152d6 to
668df1d
Compare
Change-type: patch
668df1d to
d3937a4
Compare
See balena-io-modules/balena-compose#79 Change-type: patch Signed-off-by: Ken Bannister <kb2ma@runbox.com>
Build secrets make use of a
volumesoption passed to the build image docker API. This option is only available in balenaEngine. With the changes on apocas/docker-modem#181, this array will be serialized using URL serialization by dockerode, which is not accepted by balenaEngine.Change-type: patch
See: https://balena.zendesk.com/agent/tickets/4782