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

flox upgrade reports no packages upgraded with catalog even though they are #1485

Closed
zmitchell opened this issue May 23, 2024 · 5 comments
Closed
Labels
bug Something isn't working team-cli Tickets relevant to the flox CLI team
Milestone

Comments

@zmitchell
Copy link
Contributor

zmitchell commented May 23, 2024

Steps to reproduce:

  • Using the catalog server install hello and dump the response
  • Modify the version number and rev_count from the response to make the package look "old"
    • Even if this isn't the correct way to make the package look old, you'll see that it still updates the lockfile later
  • Uninstall the package, then install it again using this dumped and modified response
  • Now you have an "old" installed package
  • FLOX_FEATURES_USE_CATALOG=true flox upgrade
  • See a message saying that no packages needed upgrading
  • Check the lockfile and see that the package was actually upgraded

From discussion:
There's two issues

  1. For our tests, we need to change the derivation rather than just the version, and then we can unskip things
  2. We need to polish if we report upgrades when the page changes but not the derivation
@zmitchell zmitchell added the bug Something isn't working label May 23, 2024
@mkenigs mkenigs added the team-cli Tickets relevant to the flox CLI team label May 23, 2024
@mkenigs mkenigs added this to the Catalog 3 milestone May 23, 2024
github-merge-queue bot pushed a commit that referenced this issue May 25, 2024
## Proposed Changes

<!-- Describe the changes proposed in this pull request. -->
<!-- Please provide links to any issue(s) which are expected to be
resolved. -->
Makes copies of `flox upgrade` tests for use with catalog service. All
tests are skipped for now due to
#1485.

Anything not in `upgrade.bats` was added for debugging or to fix a bug
in dumping catalog responses.

## Release Notes

<!-- Describe any user facing changes. Use "N/A" if not applicable. -->
N/A

<!-- Many thanks! -->
@mkenigs
Copy link
Contributor

mkenigs commented May 27, 2024

As part of this ticket, we should unskip the tests added in #1488

@dcarley
Copy link
Contributor

dcarley commented Jun 4, 2024

I'm not able to reproduce this using the original instructions:

% _FLOX_CATALOG_DUMP_RESPONSE_FILE=catalog.json flox install hello
✅ 'hello' installed to environment 'tmp'

% flox list        
hello: hello (2.12.1)

% flox remove hello
🗑️  'hello' uninstalled from environment 'tmp'

% _FLOX_USE_CATALOG_MOCK=<(jq '.[0][0].pages[0].packages[0] |= ( .version |= "1.2.3" | .rev_count |= 123)' catalog.json) flox install hello
✅ 'hello' installed to environment 'tmp'

% flox list
hello: hello (1.2.3)

% flox upgrade 
⬆️  Upgraded 'hello' in environment 'tmp'.

% flox list   
hello: hello (2.12.1)

Removing the version constraint on an existing package also works:

% flox install hello@2.12
✅ 'hello' installed to environment 'tmp'

% flox list              
hello: hello (2.12)

% sed -iE '/hello.version/d' .flox/env/manifest.toml

% flox upgrade
⬆️  Upgraded 'hello' in environment 'tmp'.

% flox list
hello: hello (2.12.1)

Although it says that it's upgraded every time, even when there are no changes to the lock:

% flox list
hello: hello (2.12.1)

% flox upgrade
⬆️  Upgraded 'hello' in environment 'tmp'.

% flox list
hello: hello (2.12.1)

@dcarley
Copy link
Contributor

dcarley commented Jun 5, 2024

Ahh, I see a difference between what's happening above and the commented tests. The "old_hello" fixture also modifies the name. If name is left unmodified or the derivation is modified to match then the tests pass:

It will still require some work to:

  1. Massage the responses for "catalog: upgrade errors on iid in group with other packages" to work.
  2. Add other systems to the mock response files so that the bats matrix tests pass on other platforms.

@ysndr
Copy link
Contributor

ysndr commented Jun 10, 2024

when using the catalog the diff is calculated after locking the manifest here:

// find all packages that after upgrading have a different derivation
let package_diff = upgraded
.packages
.iter()
.filter_map(move |pkg| {
previous_packages
.iter()
.find(|prev| {
prev.install_id == pkg.install_id && prev.derivation != pkg.derivation
})
.map(|prev| (prev.clone(), pkg.clone()))
})
.collect();

in particular the current predicate for a package to count as "upgraded" is a change of its derivation attribute.
I.e. a package is not upgraded when the derivation remains the same even though the revision of nixpkgs it got pulled form changes, as both revisions produce the exact same package.

Also it's hard to call the lockfile "upgraded" when wrt a single package both revisions are indeed equivalent.

IMO the missing message is "New lockfile written, no package upgraded" if we do write a lockfile.
OR, we wholly ignore a lockfile or, more granular, package upgrade if its derivations are equivalent.

Saying "hello was upgraded from version A to version A" seems like "the worst" of both options.

@mkenigs
Copy link
Contributor

mkenigs commented Jun 11, 2024

Split into #1568 and #1570

@mkenigs mkenigs closed this as not planned Won't fix, can't repro, duplicate, stale Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working team-cli Tickets relevant to the flox CLI team
Projects
None yet
Development

No branches or pull requests

4 participants