Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Return Err in PackageInstall::load when pkg path not present. #741

Merged
merged 1 commit into from
Jun 11, 2016

Conversation

fnichol
Copy link
Collaborator

@fnichol fnichol commented Jun 11, 2016

Checking for the /hab/pkgs directory hasn't been a concern until we
started producing a portable hab CLI binary which doesn't necessarily
run inside a Habitat package itself. The package install detection logic
was initially running under the assumption that it was a Supervisor and
hence properly installed as a Habitat package. Then our glibc/dynamic
version of hab had the same set of assumptions (i.e. that it was
running in a Habitat package, hence the parent directories would exist).

This fix performs an early return if the package root path does not
exist which is accurate: no Habitat packages will exist so there's no
more detection work to do!

Closes #736

Checking for the `/hab/pkgs` directory hasn't been a concern until we
started producing a portable `hab` CLI binary which doesn't necessarily
run inside a Habitat package itself. The package install detection logic
was initially running under the assumption that it was a Supervisor and
hence properly installed as a Habitat package. Then our glibc/dynamic
version of `hab` had the same set of assumptions (i.e. that it was
running in a Habitat package, hence the parent directories would exist).

This fix performs an early return if the package root path does not
exist which is accurate: no Habitat packages will exist so there's no
more detection work to do!

Closes #736

Signed-off-by: Fletcher Nichol <[email protected]>
@thesentinels
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @reset to be a potential reviewer

@fnichol
Copy link
Collaborator Author

fnichol commented Jun 11, 2016

A repro is possible in the devshell, but you must delete the package root directory to trigger the failure:

root@254c52851fe3:/src/components/hab# cargo build
root@254c52851fe3:/src/components/hab# rm -rf /hab/pkgs
root@254c52851fe3:/src/components/hab# ls -l /hab/
total 4
drwxr-xr-x 4 root root 4096 Jun 11 15:42 cache
root@254c52851fe3:/src/components/hab# ./target/debug/hab studio -V
✗✗✗
✗✗✗ No such file or directory (os error 2)
✗✗✗

And after:

root@254c52851fe3:/src/components/hab# cargo build
root@254c52851fe3:/src/components/hab# rm -rf /hab/pkgs
root@254c52851fe3:/src/components/hab# ls -l /hab/
total 4
drwxr-xr-x 4 root root 4096 Jun 11 15:42 cache
root@254c52851fe3:/src/components/hab# ./target/debug/hab studio -V
∵ Package for core/hab-studio not found, installing
» Installing core/hab-studio
↓ Downloading core/hab-studio/0.6.0/20160604180820
    2.66 MB / 2.66 MB \ [=========] 100.00 % 2.98 MB/s
✓ Installed core/hab-studio/0.6.0/20160604180820
★ Install of core/hab-studio complete with 1 packages installed.
hab-studio 0.6.0/20160604180820

@fnichol
Copy link
Collaborator Author

fnichol commented Jun 11, 2016

Confirmed with a release-style build:

> docker run --rm -ti -v `pwd`:/src alpine sh
/ # tail -n +6 /src/results/core-hab-0.6.0-20160611160242-x86_64-linux.hart | xzcat | tar x -C /tmp
/ # ls /hab
ls: /hab: No such file or directory
/ # /tmp/hab/pkgs/core/hab/0.6.0/20160611160242/bin/hab studio -V
∵ Package for core/hab-studio not found, installing
» Installing core/hab-studio
↓ Downloading core/hab-studio/0.6.0/20160604180820
    2.66 MB / 2.66 MB - [=======] 100.00 % 3.08 MB/s
↓ Downloading core-20160423193745 public origin key
    75 B / 75 B | [=====] 100.00 % 2.61 MB/s
☑ Cached core-20160423193745 public origin key
✓ Installed core/hab-studio/0.6.0/20160604180820
★ Install of core/hab-studio complete with 1 packages installed.
hab-studio 0.6.0/20160604180820

@fnichol
Copy link
Collaborator Author

fnichol commented Jun 11, 2016

@thesentinels r+

@thesentinels
Copy link
Contributor

📌 Commit 8e09428 has been approved by fnichol

@thesentinels
Copy link
Contributor

⌛ Testing commit 8e09428 with merge c58688d...

thesentinels pushed a commit that referenced this pull request Jun 11, 2016
Checking for the `/hab/pkgs` directory hasn't been a concern until we
started producing a portable `hab` CLI binary which doesn't necessarily
run inside a Habitat package itself. The package install detection logic
was initially running under the assumption that it was a Supervisor and
hence properly installed as a Habitat package. Then our glibc/dynamic
version of `hab` had the same set of assumptions (i.e. that it was
running in a Habitat package, hence the parent directories would exist).

This fix performs an early return if the package root path does not
exist which is accurate: no Habitat packages will exist so there's no
more detection work to do!

Closes #736

Signed-off-by: Fletcher Nichol <[email protected]>

Pull request: #741
Approved by: fnichol
@thesentinels
Copy link
Contributor

☀️ Test successful - travis

@thesentinels thesentinels merged commit 8e09428 into master Jun 11, 2016
@fnichol fnichol deleted the fnichol/install-parent-dirs-fix branch June 11, 2016 17:30
jtimberman pushed a commit that referenced this pull request Jun 12, 2016
Checking for the `/hab/pkgs` directory hasn't been a concern until we
started producing a portable `hab` CLI binary which doesn't necessarily
run inside a Habitat package itself. The package install detection logic
was initially running under the assumption that it was a Supervisor and
hence properly installed as a Habitat package. Then our glibc/dynamic
version of `hab` had the same set of assumptions (i.e. that it was
running in a Habitat package, hence the parent directories would exist).

This fix performs an early return if the package root path does not
exist which is accurate: no Habitat packages will exist so there's no
more detection work to do!

Closes #736

Signed-off-by: Fletcher Nichol <[email protected]>

Pull request: #741
Approved by: fnichol
raskchanky pushed a commit that referenced this pull request Apr 16, 2019
Checking for the `/hab/pkgs` directory hasn't been a concern until we
started producing a portable `hab` CLI binary which doesn't necessarily
run inside a Habitat package itself. The package install detection logic
was initially running under the assumption that it was a Supervisor and
hence properly installed as a Habitat package. Then our glibc/dynamic
version of `hab` had the same set of assumptions (i.e. that it was
running in a Habitat package, hence the parent directories would exist).

This fix performs an early return if the package root path does not
exist which is accurate: no Habitat packages will exist so there's no
more detection work to do!

Closes #736

Signed-off-by: Fletcher Nichol <[email protected]>

Pull request: #741
Approved by: fnichol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"No such file or directory" trying to enter the studio
2 participants