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

[internal] Add a release artifact size verification step. #13234

Merged
merged 2 commits into from
Oct 15, 2021

Conversation

stuhood
Copy link
Sponsor Member

@stuhood stuhood commented Oct 13, 2021

Before beginning to automate deleting our "most stale" artifacts, add a manual verification step that encodes which artifacts we prefer to delete (dev releases before rcs before stable, then sorted by last upload date), and suggests deleting them before attempting to run a release.

This will likely be annoying, but verifying that the results look sane in the short term will be a blocker for automating deletion. The next step in release automation will probably be getting the pantsbuild bot's PyPI credentials into Github Actions secrets and starting to 1. run releases there, 2. delete stale releases there (if we think we can be comfortable with that).

[ci skip-rust]

[ci skip-rust]

[ci skip-build-wheels]
@stuhood
Copy link
Sponsor Member Author

stuhood commented Oct 13, 2021

Currently reports:

$ ./build-support/bin/release.sh validate-freshness
Stale:
  PackageVersion(name='pantsbuild.pants', version=<Version('2.3.0.dev0')>, size_mb=91, most_recent_upload_date=datetime.date(2021, 1, 11))
Stale:
  PackageVersion(name='pantsbuild.pants', version=<Version('2.3.0.dev1')>, size_mb=98, most_recent_upload_date=datetime.date(2021, 1, 22))
Stale:
  PackageVersion(name='pantsbuild.pants', version=<Version('2.3.0.dev2')>, size_mb=98, most_recent_upload_date=datetime.date(2021, 2, 1))
Stale:
  PackageVersion(name='pantsbuild.pants', version=<Version('2.3.0.dev3')>, size_mb=98, most_recent_upload_date=datetime.date(2021, 2, 3))
Stale:
  PackageVersion(name='pantsbuild.pants', version=<Version('2.4.0.dev0')>, size_mb=97, most_recent_upload_date=datetime.date(2021, 2, 28))
Stale:
  PackageVersion(name='pantsbuild.pants', version=<Version('2.4.0.dev1')>, size_mb=97, most_recent_upload_date=datetime.date(2021, 3, 9))
Stale:
  PackageVersion(name='pantsbuild.pants', version=<Version('2.4.0.dev2')>, size_mb=97, most_recent_upload_date=datetime.date(2021, 3, 13))
Stale:
  PackageVersion(name='pantsbuild.pants', version=<Version('2.4.0.dev3')>, size_mb=98, most_recent_upload_date=datetime.date(2021, 3, 20))
Stale:
  PackageVersion(name='pantsbuild.pants', version=<Version('2.5.0.dev0')>, size_mb=97, most_recent_upload_date=datetime.date(2021, 4, 2))
Stale:
  PackageVersion(name='pantsbuild.pants', version=<Version('2.5.0.dev1')>, size_mb=97, most_recent_upload_date=datetime.date(2021, 4, 11))
Stale:
  PackageVersion(name='pantsbuild.pants', version=<Version('2.0.0rc0')>, size_mb=168, most_recent_upload_date=datetime.date(2020, 10, 12))
Stale:
  PackageVersion(name='pantsbuild.pants', version=<Version('2.0.0rc1')>, size_mb=168, most_recent_upload_date=datetime.date(2020, 10, 16))
Stale:
  PackageVersion(name='pantsbuild.pants', version=<Version('2.0.0rc2')>, size_mb=168, most_recent_upload_date=datetime.date(2020, 10, 23))

To ensure that there is adequate storage for new artifacts, the stale release artifacts listed above should be deleted via [https://pypi.org/]'s UI.
If you have any concerns about the listed artifacts, or do not have access to delete them yourself, please raise an issue in #development Slack or on [https://github.com/pantsbuild/pants/issues/11614].
Press enter when you have deleted the listed artifacts: ^C

if versions_by_freshness_ascending[-1].size_mb > available_mb:
break
available_mb -= versions_by_freshness_ascending.pop().size_mb
return versions_by_freshness_ascending
Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

I'll probably add a safeguard here to confirm that it never suggests deleting more than N versions. But would be interested in any other safeguards folks can think of.

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

I don't see any safeguard against recommending deleting non-dev releases? I would imagine we want to think 1000 times before deleting recent dev releases, rcs or, of course, stable releases.

Copy link
Sponsor Member Author

@stuhood stuhood Oct 13, 2021

Choose a reason for hiding this comment

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

When we get into very recent dev releases (it's currently recommending deleting 5+ month old dev releases) things definitely get hairy, yea. Currently it prioritizes removing dev releases before rcs before stable releases.

But perhaps we need a recency safeguard, where we rule out deleting anything younger than X months old? The trouble with that right now is that we will quickly move on to deleting stable releases... admittedly, there are some very old stable releases (pre-1.0.0 basically), which we could manually delete to free up space in the more recent releases to give us more headroom.

Copy link
Member

@kaos kaos Oct 14, 2021

Choose a reason for hiding this comment

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

You could add constraints per release kind to that, so instead of time based, you could say
(blacklist vs whitelist simply reverse the constraint...)

stable: <1.30
rc: <2.0
dev: <2.2

As time is less important than release cadence, I think...

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

Agreed that doing something PackageVersionType-dependent would make more sense, but it would also be more complicated. I'm going to keep this simpler for now, and have added a minimum age to be eligible.

@benjyw
Copy link
Sponsor Contributor

benjyw commented Oct 13, 2021

Hopefully we can render this moot some day soon by deploying Pants as a binary, instead of as a dist. We'll still need to deploy the plugin API as a dist, but that could be a lot smaller since it wouldn't include the native engine.

Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Thanks, good idea.

build-support/bin/_release_helper.py Show resolved Hide resolved
stale_version for package in PACKAGES for stale_version in package.stale_versions()
]
if stale_versions:
print("\n".join(f"Stale:\n {sv}" for sv in stale_versions))
Copy link
Contributor

Choose a reason for hiding this comment

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

This would be more useful if you implemented __str__ for the type. The comment you posted was a bit chatty.

@stuhood
Copy link
Sponsor Member Author

stuhood commented Oct 13, 2021

Hopefully we can render this moot some day soon by deploying Pants as a binary, instead of as a dist. We'll still need to deploy the plugin API as a dist, but that could be a lot smaller since it wouldn't include the native engine.

After encountering another issue with the setup script today (not the script's fault per-se, but: setuptools + venv can float), I think I agree that it's possible that the best way to resolve both our size constraints and the complexity of the setup script is to switch to distributing a PEX by default.

#12397 covers this, but: switching to shipping a binary resolves it. If we ship a PEX (which we already deploy to Github as part of our release process), the PEX is stable with embedded setuptools/pip. Shipping a PEX would also be an incremental step toward shipping a Rust binary at some point.

In the past there were some objections to shipping a PEX due to performance, but with venv mode, that should no longer be a concern.

@Eric-Arellano
Copy link
Contributor

Great idea to exclusively ship a PEX.

How would we handle plugins - release a library-only dist without the native code? Also don't include the console script / entry point.

@jsirois
Copy link
Contributor

jsirois commented Oct 14, 2021

I'll step aside from this review. I'd still prefer deleting for past and moving forward as described in the OP in #11614. I think we're doing a bunch of dancing here for 0 users benefit in reality.

@stuhood
Copy link
Sponsor Member Author

stuhood commented Oct 14, 2021

I'll step aside from this review. I'd still prefer deleting for past and moving forward as described in the OP in #11614. I think we're doing a bunch of dancing here for 0 users benefit in reality.

At this point we have deleted all of the dev releases aside from the ones mentioned in #13234 (comment) (and newer): and that has not been sufficient. The thing that we realized the other day that means we have relatively little headroom is that the size limit is per package... i.e. we're hitting the cap for pantsbuild.pants, and none of the contrib modules matter at all.

@stuhood
Copy link
Sponsor Member Author

stuhood commented Oct 14, 2021

How would we handle plugins - release a library-only dist without the native code? Also don't include the console script / entry point.

Hm, very good question. Because testing a plugin does actually need the native code.

@jsirois
Copy link
Contributor

jsirois commented Oct 14, 2021

Ok. Option #37: Since no-one installs pantsbuild.pants via pip or otherwise except our own setup script / pants PEX creation process, there is 0 reason to use the PyPI index for publishing - we could use our own and foot the bill.

@stuhood
Copy link
Sponsor Member Author

stuhood commented Oct 14, 2021

Ok. Option #37: Since no-one installs pantsbuild.pants via pip or otherwise except our own setup script / pants PEX creation process, there is 0 reason to use the PyPI index for publishing - we could use our own and foot the bill.

Yea, that's true aside from the point @Eric-Arellano raised: 3rdparty plugin code does actually need to resolve Pants (using Pants) in order to develop against it.

But, the setup script already has a sort of solution to this when a PANTS_SHA is used: it adds the S3 repository containing the snapshot to [python-repos] repos:
https://github.com/pantsbuild/setup/blob/3ef18abce129b5c07556973b8e19aba4d13336c2/pants#L366-L368

So... perhaps the existing support for resolving from S3 in the setup script actually already gets us 80% of the way there. I expect that rather than actually fetching transitive wheels from S3 we'll want to fetch the PEX from Github, and then only add the S3 repository in case someone is developing a plugin (otherwise I think that we'd be taking on a significant bandwidth cost).

… can safely be deleted.

# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@stuhood
Copy link
Sponsor Member Author

stuhood commented Oct 14, 2021

Until we swap to distributing a PEX (which definitely seems like the way forward in the next few weeks), I think that we should land this. Have added a minimum age safeguard. And: this is still a manual step, so we'll lean on releasers to actually apply it and discuss things before deleting them if they have concerns.

@stuhood stuhood merged commit 04e3db4 into pantsbuild:main Oct 15, 2021
@stuhood stuhood deleted the stuhood/package-deletion-prompt branch October 15, 2021 04:50
@jsirois
Copy link
Contributor

jsirois commented Jan 6, 2022

What does "in case someone is developing a plugin" mean? If I'm developing a plugin and I use, say vscode, how am I expected to setup my project and get symbols, etc? Are you expecting us to publish instructions on how to build the venv pointing to our S3 find-links repo? If so that precludes Poetry users IIUC. They'll need to break their typical workflow and use Pip to build the vscode venv.

@stuhood
Copy link
Sponsor Member Author

stuhood commented Jan 6, 2022

Are you expecting us to publish instructions on how to build the venv pointing to our S3 find-links repo?

The pants_requirement target dynamically creates a requirement to match the current version, and the portion of the pants script that I linked to adds the S3 url to repositories. So it's already the case that when consuming from a PANTS_SHA, users are able to develop plugins.

As to creating a virtualenv for plugin development: that's effectively the same as any other IDE usage with Pants: to get a properly scoped venv in the context of multiple different resolves and requirements, you need to use something like the export goal from #13415 to export for the relevant set of targets.

@jsirois
Copy link
Contributor

jsirois commented Jan 7, 2022

Aha, so your implicit assumption is to develop a Pants plugin you must use Pants. I was not assuming that. Seems reasonable enough though.

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.

5 participants