Skip to content

Commit 39bdc12

Browse files
authored
[CRE-739] clnode volume relative paths store (#2076)
* use volumes for CL node * Store cached config on absolute path if the relative doesn't work
1 parent 17e45c2 commit 39bdc12

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

framework/.changeset/v0.10.16.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Use volumes for user's home directory and `config` folder for the CL node
2+
- Store cached config on absolute path if the relative doesn't work

framework/components/clnode/clnode.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ const (
2929
TmpImageName = "chainlink-tmp:latest"
3030
CustomPortSeparator = ":"
3131
DefaultCapabilitiesDir = "/usr/local/bin"
32+
ConfigVolumeName = "clnode-config"
33+
HomeVolumeName = "clnode-home"
3234
)
3335

3436
var (
@@ -253,6 +255,23 @@ func newNode(in *Input, pgOut *postgres.Output) (*NodeOut, error) {
253255
WithPort(DefaultHTTPPort).
254256
WithStartupTimeout(3 * time.Minute).
255257
WithPollInterval(200 * time.Millisecond),
258+
Mounts: tc.ContainerMounts{
259+
{
260+
// various configuration files
261+
Source: tc.GenericVolumeMountSource{
262+
Name: ConfigVolumeName + "-" + in.Node.Name,
263+
},
264+
Target: "/config",
265+
},
266+
{
267+
// kv store of the OCR jobs and other state files are stored
268+
// in the user's home instead of the DB
269+
Source: tc.GenericVolumeMountSource{
270+
Name: HomeVolumeName + "-" + in.Node.Name,
271+
},
272+
Target: "/home/chainlink",
273+
},
274+
},
256275
}
257276
if in.Node.HTTPPort != 0 && in.Node.P2PPort != 0 {
258277
req.HostConfigModifier = func(h *container.HostConfig) {

framework/config.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,17 @@ func Store[T any](cfg *T) error {
293293
if err != nil {
294294
return err
295295
}
296-
return os.WriteFile(filepath.Join(DefaultConfigDir, cachedOutName), d, 0600)
296+
297+
writePath := filepath.Join(DefaultConfigDir, cachedOutName)
298+
if _, err := os.Stat(writePath); err != nil {
299+
var absErr error
300+
writePath, absErr = filepath.Abs(cachedOutName)
301+
if absErr != nil {
302+
return fmt.Errorf("error getting absolute path for config file %s: %w", cachedOutName, absErr)
303+
}
304+
}
305+
306+
return os.WriteFile(writePath, d, 0600)
297307
}
298308

299309
// JSONStrDuration is JSON friendly duration that can be parsed from "1h2m0s" Go format

0 commit comments

Comments
 (0)