Skip to content

[remove-nixpkgs] Disable remove-nixpkgs to fix non-search fallback #1463

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

Merged
merged 1 commit into from
Sep 8, 2023

Conversation

mikeland73
Copy link
Contributor

Summary

Restores functionality implemented by #1264 and refactored in #1279

which was accidentally broken by #1437

tldr: the FillNarInfoCache function breaks if packages are not in search, but we support non-search packages via fallback (.e.g. stdenv.cc.cc.lib)

I'm keeping surface area as small as possible, but as a follow up I think we can remove the devpkg.FillNarInfoCache calls from impl.Add if we simply ignore theIsInBinaryCache errors in ValidateExists or remove IsInBinaryCache from that function completely (I'm not convinced it is needed, @savil @ipince correct me if I'm wrong)

How was it tested?

devbox add stdenv.cc.cc.lib

@mikeland73 mikeland73 merged commit 8b1e2e3 into main Sep 8, 2023
@mikeland73 mikeland73 deleted the landau/fix-non-search-fallback branch September 8, 2023 15:48
savil added a commit that referenced this pull request Sep 12, 2023
…1468)

## Summary

In this PR, we loosen the conditions under which
`devpkg.Package.IsInBinaryCache` can be called. Internally, it checks an
in-memory map for the status of the package in the binary cache.
Previously, it was _required_ that callers pre-compute this status by
invoking `FillNarInfoInCache`. The motivation then was to ensure that we
avoid a synchronous http request if `IsInBinaryCache` is called within a
loop.

However, this condition and the fact that golang lacks async-await
support resulted in a loosely coupled load-and-check-later design
whereby calls to `FillNarInfoInCache` would be sprinkled in various
parts of the codebase and then `IsInBinaryCache` checked in other parts.
This loose-coupling made it hard to reason about _why_ any particular
FillNarInfoInCache was present.

The straw that broke the proverbial camel's back was the issue that
#1463 was seeking to fix.

In this PR, we add a fallback http request inside `IsInBinaryCache` and
remove all but one of the `FillNarInfoInCache` calls. Reason:
1. The remaining callsite is in the hot codepath of calculating
`shellenv`.
2. The other callsites were in the codepaths of adding or installing
packages. This is necessarily a slow operation, and so a small bit of
synchrony is acceptable.

NOTE: this PR also re-enables Remove Nixpkgs feature flag.


## How was it tested?

- did some adhoc testing of opening a shell in an example project
- added testscript unit-test for adding packages that are not in the
Devbox Search Index. re: #1463's scenario
- prior testscript unit-tests and project-tests should pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants