8000 rkt: calculate real dataDir path by sgotti · Pull Request #2399 · rkt/rkt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 24, 2020. It is now read-only.

rkt: calculate real dataDir path #2399

Merged
merged 1 commit into from
Apr 14, 2016

Conversation

sgotti
Copy link
Contributor
@sgotti sgotti commented Apr 8, 2016

If dataDir or some of its parents are symlinks all seems to work correctly
except the gc.

That's because stage0.MountGC determines which mountpoints should be
unmounted filtering the mountpoints returned from /proc/self/mountinfo
with the dataDir value. These mountpoints are the real path so, if the
dataDir or its parents are symlinks, no mountpoint will match.

This patch evaluates the dataDir real path.

If some functional tests are needed I'm not sure under what file under ./tests/ I should put them.

If dataDir or some of its parents are symlinks all seems to work correctly
except the gc.

That's because stage0.MountGC determines which mountpoints should be
unmounted filtering the mountpoints returned from /proc/self/mountinfo
with the dataDir value. These mountpoints are the real path so, if the
dataDir or its parents are symlinks, no mountpoint will match.

This patch evaluates the dataDir real path.
@sgotti sgotti force-pushed the rkt_datadir_or_parents_symlink branch from eade3a2 to b02fd2f Compare April 8, 2016 14:57
@jonboulle jonboulle added this to the v1.4.0 milestone Apr 11, 2016
} else {
if config.Paths.DataDir != "" {
dataDir = config.Paths.DataDir
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can simplify this if-else cascade a bit:

if dataDir == "" {
  config, err := getConfig()

  if err != nil {
    stderr.PrintE("cannot get configuration", err)
    os.Exit(1)
  }

  dataDir = config.Paths.DataDir
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@s-urbaniak Agree. I just kept the previous logic to bring less pollution to the patch. But I'll change it if you're ok.

Copy link
Member

Choose a reason for hiding this comment

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

Let's address this on a follow-up: #2421

@s-urbaniak
Copy link
Contributor

stylistic nit, else LGTM; I'd also suggest to introduce a functional test for symlink resolving, but unsure where to put this either ;-)

@alban thoughts re: test?

@alban
Copy link
Member
alban commented Apr 14, 2016

I am not sure that tests are needed for that...

If you want to add tests, you can look at ctx.go:

func (d *dirDesc) reset() {
    d.cleanup()
    dir, err := ioutil.TempDir("", d.prefix)

This function decides which temporary directory to use for the tests. It could create new symlinks, and all tests would run in a directory with symlink components in its path.

@iaguis
Copy link
Member
iaguis commented Apr 14, 2016

LGTM

Issue for tests: #2422

@iaguis iaguis merged commit afbbd84 into rkt:master Apr 14, 2016
@alban alban mentioned this pull request Apr 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0