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

Cleanup files.PublishedStorage after dropping a publish #1381

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aol-nnov
Copy link
Contributor

@aol-nnov aol-nnov commented Oct 22, 2024

Fixes: #198

After dropping files.PublishedStorage there were some leftovers - empty directory tree. If that directory tree is empty, it is now removed.

Checklist

  • functional test added/updated (if change is functional)

@aol-nnov
Copy link
Contributor Author

@neolynx here is another annoying thing I'd like to fix in aptly. My publish prefix is bloated with empty directories as I have to create and remove publishes intensively.

@neolynx
Copy link
Member

neolynx commented Oct 22, 2024

oh, yes please ! I found this quite annoying as well...

@aol-nnov
Copy link
Contributor Author

yay, there is an issue for it! #198

files/public.go Outdated Show resolved Hide resolved
deb/publish.go Outdated Show resolved Hide resolved
@aol-nnov aol-nnov requested a review from neolynx October 22, 2024 14:44
@neolynx neolynx self-assigned this Oct 22, 2024
@neolynx neolynx added the fix tests Tests are failing label Oct 22, 2024
@aol-nnov aol-nnov force-pushed the cleanup-local-tree branch 2 times, most recently from d5f937b to 6809929 Compare October 23, 2024 06:32
@aol-nnov
Copy link
Contributor Author

aol-nnov commented Oct 23, 2024

@neolynx original tests that were failing are now fixed, but my newly added PublishDrop21Test is failing, not sure why...

May be it's time for me to learn something new, too? 😁 This alienish test suite is driving me nuts, frankly...

system/t06_publish/drop.py Outdated Show resolved Hide resolved
files/public.go Outdated Show resolved Hide resolved
@aol-nnov aol-nnov force-pushed the cleanup-local-tree branch 3 times, most recently from 05f0908 to 3b33303 Compare October 23, 2024 07:22
@aol-nnov
Copy link
Contributor Author

All tests are passing now

@neolynx
Copy link
Member

neolynx commented Oct 23, 2024

@neolynx original tests that were failing are now fixed

great ! could you explain why they failed ?

but my newly added PublishDrop21Test is failing, not sure why...

May be it's time for me to learn something new, too? 😁 This alienish test suite is driving me nuts, frankly...

please do not judge :) the history of all of this is in git, many people worked on that. I think the thing to learn here is how to deal with legacy code and how to slowly improve it and revive the project. so please be respectful and constructive, we are all aware of the state of things, and it took months to get it to a working and halfway reliable state.

@aol-nnov
Copy link
Contributor Author

aol-nnov commented Oct 23, 2024

could you explain why they failed ?

-gold file was missing for my PublishDrop21Test - copied it from PublishDrop2Test. Not completely sure what it is.

Whole experience of adding tests is cumbersome and non-obvious due to lack of developers documentation. Even some doc links to the testing frameworks would make the whole process more friendly and smooth...

Oh, and original tests were failing because checks relied on empty directories now removed (as you said, the history of all of this is in git :-) )

@neolynx
Copy link
Member

neolynx commented Oct 23, 2024

could you explain why they failed ?

-gold file was missing for my PublishDrop21Test - copied it from PublishDrop2Test. Not completely sure what it is.

ok great. in the Makefile there is the CAPTURE flag, you can uncomment, then the tests will create the gold files.

Whole experience of adding tests is cumbersome and non-obvious due to lack of developers documentation. Even some doc links to the testing frameworks would make the whole process more friendly and smooth...

as said before, we are well aware of that. feel free to contribute. until then let's keep the discussions here technical.

Oh, and original tests were failing because checks relied on empty directories now removed (as you said, the history of all of this is in git :-) )

thanks, that is excellent :-)

@aol-nnov aol-nnov force-pushed the cleanup-local-tree branch 3 times, most recently from ab0c5e5 to 81d0034 Compare October 23, 2024 08:50
@neolynx
Copy link
Member

neolynx commented Oct 23, 2024

tests look good !

I started a coverage build: codecov/patch — 84.61% of diff hit (target 74.84%)

@aol-nnov aol-nnov force-pushed the cleanup-local-tree branch 2 times, most recently from 5750df4 to ddc84c5 Compare October 23, 2024 09:01
@aol-nnov
Copy link
Contributor Author

Seems, ci is stuck again...

@neolynx
Copy link
Member

neolynx commented Oct 23, 2024

Seems, ci is stuck again...

seems we have a segfault:
https://github.com/aptly-dev/aptly/actions/runs/11476603052/job/31936962068?pr=1381#step:8:487

deb/publish.go Outdated Show resolved Hide resolved
@aol-nnov
Copy link
Contributor Author

aol-nnov commented Oct 23, 2024

seems we have a segfault

Heh, that's because nil is passed instead of aptly.Progress in tests. Very handy 😒

P.S.: handled that on my side

@aol-nnov
Copy link
Contributor Author

Now, seems -gold-en outputs do not match new reality 😂

@neolynx
Copy link
Member

neolynx commented Oct 23, 2024

Now, seems -gold-en outputs do not match new reality 😂

it needs that non empty check before remove... ;-)

@aol-nnov
Copy link
Contributor Author

Also, something wrong with docker tests:

$ make docker-image
[+] Building 310.3s (21/21) FINISHED
$ make docker-system-test
usermod: UID '0' already exists
make: *** [docker-system-test] Error 4
$ _

So, for me there is no simple way to update test now, unfortunately.

@aol-nnov
Copy link
Contributor Author

it needs that non empty check before remove... ;-)

You know what, my experience contributing in this particular PR is drastically falling down. Second day in a row we're chewing through tons of comments in a changeset that barely changes nothing, docs on testsuite are missing, tooling does not work and you're making jokes on me...

That all really makes me sad.

@neolynx
Copy link
Member

neolynx commented Oct 23, 2024

Also, something wrong with docker tests:

the docker-wrapper sets the user to the one of the git repo directory, to not write files as root. it seems your git dir is owned by root. changing to user owner would solve this in that case.

@aol-nnov
Copy link
Contributor Author

aol-nnov commented Oct 23, 2024

it seems your git dir is owned by root

not true

$ ls -lad ../aptly/
drwxr-xr-x@ 46 aol  staff  1472 Oct 22 17:22 ../aptly/

Thanks for the docker-wrapper idea, though. Slashed it a bit.

@aol-nnov
Copy link
Contributor Author

Re: better tooling #1384

It might be worth merging it first.

@aol-nnov aol-nnov requested a review from neolynx October 24, 2024 07:27
@aol-nnov
Copy link
Contributor Author

aol-nnov commented Oct 28, 2024

A friendly ping for @neolynx

Tests are fixed now.

Let's finish those two PRs, we're on the homestretch ;)

@aol-nnov

This comment was marked as resolved.

After dropping files.PublishedStorage there were some leftovers -
empty directory tree. If that directory tree is empty, it is now removed.

Fixes: aptly-dev#198
@aol-nnov
Copy link
Contributor Author

aol-nnov commented Nov 2, 2024

Rebased to the tip of master, conflicts resolved.

P.S.: Failing tests are not mine.

@@ -0,0 +1,5 @@
Removing ${HOME}/.aptly/public/ppa/smira/dists...
Removing ${HOME}/.aptly/public/ppa/smira/pool...
{"level":"debug","time":"now","message":"CleanupPublishTree: remove ${HOME}/.aptly/public/ppa: directory not empty. '${HOME}/.aptly/public/ppa' not removed\n"}
Copy link
Member

Choose a reason for hiding this comment

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

we need to use normal logging here, no json to console...

@neolynx
Copy link
Member

neolynx commented Nov 2, 2024

P.S.: Failing tests are not mine.

resources from the internet are not always available, I restarted the tests.

@neolynx
Copy link
Member

neolynx commented Nov 2, 2024

Dear @aol-nnov,

I was by no means making jokes on you, i was merely a wink to point out what is expected here. Your skills and contributions are very welcome, also for documentation and all the other stuff which is lagging behind !

I talked to some of the other maintainers, here are our thougths:

  • Aptly does not have the authority over the prefix path, as it is most likely used in a webserver directory structure, which might be managed by other tools
  • Changing the default behavior to remove the tree could result in 404 instead of a empty directory index on the webserver
  • Proper logging of unexpected error is required, as aptly logs are crucial for reproducing issues, also expected errors are prevented / not logged
  • there is also deb/publish.go:func (p *PublishedRepo) RemoveFiles(publishedStorageProvider aptly.PublishedStorageProvider, removePrefix bool, - the removePrefix might be doing something similar, maybe this can be combined?
  • Issue comments are marked as resolved by the maintainers. Even if the concern might feel unreasonable or not to your liking.

To move forward here, we suggest the following changes:

  • make a cleanupTree argument to the drop calls (api, cmd), cleanup up the tree only if set to true and skipCleanup is false
  • in CleanupPublishTree, check if the directory is empty and return if true, otherwise remove directory. return the error and log in the caller
  • original test should prove that prefix is not removed, new tests prove that empty dirs are removed, non-empty ones not (without a error log)
  • if we wanna be fancy, a test with a parent directory without write permissions would prove that the error is logged

Please understand that aptly is a legacy project with many maintainers and contributors over the years. It took considerable effort to revive it and bring it to the state it is now. As maintainers, our main concern is to not break any of potentially thousands of installations, and if something happens, we have proper logs. And this has some implications on how we can implement things.

@cfiehe, @szakalboss, @dario-gallucci please add if I forgot something

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix tests Tests are failing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Aptly leave empty directory structure when droping published repo with prefix
2 participants