-
Notifications
You must be signed in to change notification settings - Fork 111
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
Adding support for S3-compatible Storage for Repository part #332
Conversation
Codecov Report
@@ Coverage Diff @@
## master #332 +/- ##
============================================
- Coverage 99.53% 99.35% -0.18%
- Complexity 1822 1855 +33
============================================
Files 295 297 +2
Lines 5754 5858 +104
============================================
+ Hits 5727 5820 +93
- Misses 27 38 +11
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last few comments from my side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ffirst of all, many thanks for the effort 👏 🍻 .
We are happy to merge these changes.
But first, please make these minor corrections. Then we will test these changes on our side.
If everything works, we will merge next week 🎉
I must admit that you create very elegant commit descriptions. I appreciate 👏 |
After initial testing I found two small bugs, I push a fix. public function filename(Dist $dist): string
{
return sprintf(
'%s/%s/dist/%s/%s_%s.%s',
$this->distsDir,
$dist->repo(),
$dist->package(),
$dist->version(),
$dist->ref(),
$dist->format()
);
} As you can see, full relative path from content root is returned. |
Now we are passing the |
998a7cd
to
c551ee3
Compare
Regarding: #332 (comment) How did you manage to reproduce the bug? Can you help me by pointing a class or giving me the exception stack trace so I can try to write a test case? |
I have a package added earlier and I run security scanner for it. I think there will be the same problem for the newly added package. Security scanner probably wasn't tested externally, only as a separate service and that's why this problem. |
7532f0e
to
c551ee3
Compare
Hi @akondas sorry for the immense delay in my response. I tried to test locally and now I am getting one error while doing the security check, is this by any chance the same error as you are getting? If so, can you tell me why it does not get logged neither reported to sentry? And maybe how can I see trace and debug it? |
AH! I think I got it. I will fix it ASAP. 😃 I found one place where I didnt change how we are reading the Zip files. But still, I was hoping this exception was going to be reported to Sentry. |
Yes, in prod env it will be reported to sentry 😉 |
Okay, I managed to solve this SecurityScanner problem. I will use the application a bit more locally to be sure I dont find any other problems, but I guess it is fine. |
@akondas now I only have a problem with this conflict, if you could help me resolve it would be nice. I tried to resolve locally by doing a rebase, but had to run Detail: I am using composer v2, from what I see in your docker image you are using it as well, but I dunno if that should be a problem. |
Yes, I can help you with this. I will correct it immediately when testing this branch |
…ge interface Had to do many changes regarding file handling since, many places are dependent of a local file system for things to work, i.e. ReadmeExtractor.
tests/Doubles/FakeDownloader.php
Outdated
{ | ||
$basePath = $basePath ?? dirname(__DIR__, 1).DIRECTORY_SEPARATOR.'Resources'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the reason for level 1 in dirname and use of DIRECTORY_SEPARATOR
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was just to avoid the relative paths with ../
on it. I had problems when using those in conjunction with the composer repositories, specially the paths. Regarding the DIRECTORY_SEPARATOR
, I try to use it whenever I can for portability. If you guys prefer just /
I can replace it as well.
Now running the suite again with the old code I see that I don't get any errors 🤷♂️ . So I can easily revert it, just say the word. 😃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok, it's just that 1
is a default level for the dirname
function and we don't really support windows in other places 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OMG, I didn't even see that (default value). I will go back to the old code to avoid confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There you go! Thanks for catching such fine grained detail 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cheers, good job overall 🍻
We tested everything (for the local filesystem) and it looks like it works, we still have s3 configuration to check. Due to the fact that holidays are coming, we will probably merge this branch in the first week of January. Forgive me for taking so long, but I would like to supervise this myself. Thanks for the work and Merry Christmas. |
Wishing you a late Merry Christmas and all good for the new year!!! I
actually deployed this branch to production at my company to do a test run
before the holidays, if I face some problem I will also provide a patch
here. Until next year! 🖖
----
Pedro Tanaka
…On Wed, Dec 23, 2020 at 3:18 PM Arkadiusz Kondas ***@***.***> wrote:
We tested everything (for the local filesystem) and it looks like it
works, we still have s3 configuration to check. Due to the fact that
holidays are coming, we will probably merge this branch in the first week
of January. Forgive me for taking so long, but I would like to supervise
this myself. Thanks for the work and Merry Christmas.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#332 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAT5EQ2BAVFOKKQ6DPGZFDDSWH3Z5ANCNFSM4UNHXM3A>
.
|
Hello @pedro-stanaka, I hope all is well in the new year. Tests showed that managing the private packages works flawlessly, but we had a small problem with the proxy on s3. I am attaching an error dump: |
Okay, I will fix this ASAP. I already know the problem, the file is on remote location and fstat requires the file to be on local file system. @akondas would it be okay if we pass the file size inside the constructor for |
I guess that should be ok 👍. Too bad I thought fstat worked for stream data as well. |
We were using fstat, but sadly it does not work for remote streams I dropped the usage of the function in favor of Flysystem methods and a custom function using fstat + stream_get_meta_data
@akondas I think it should be fine now. I introduced a class for the Dist File for the proxy, because there we really only had the stream, so I added class to have information about the file size we are proxying. Hope solution is fine enough. |
src/Service/Proxy/DistFile.php
Outdated
@@ -2,7 +2,7 @@ | |||
/** | |||
* CRM PROJECT | |||
* THIS FILE IS A PART OF CRM PROJECT | |||
* CRM PROJECT IS PROPERTY OF Legal One GmbH | |||
* CRM PROJECT IS PROPERTY OF Legal One GmbH. | |||
* | |||
* @copyright Copyright (c) 2020 Legal One GmbH (http://www.legal.one) | |||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✂️ 😉
Everything seems to be working properly now. Thanks for a great job. Please delete this one comment and we are ready to merge it 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more thing to fix: repman:metadata:clear-cache
cli command. This is last place where local files are used 😉.
I will work on solution for the cli command. The symfony filesystem component is a really nice helper, but wont work with the new Flysystem adapter. I will have devise a "by-hand" solution, by iterating the contents of the distDir. Luckily this is cronjob, so no problem taking a bit more of time. |
…d using Flysystem classes
@akondas I managed to find a solution for the file finding. I took " inspiration" from symfony filesystem lib. Please take a look and see if this is adequate. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 👏
@pedro-stanaka Thank you for all your hard work on this functionality 🙏 👏 🎖️ |
This PR is related to issue #228. I tried to keep it simple and contained, but there were too many places where it the local filesystem was taken as a guarantee. So there was a lot of refactoring involved.
I tried to follow the conventions you used in the code, but if I failed to respect some convention please let me know and I will fix it.
Apart from the strong test suite of yours, I also tested the application inside a private hosted server with the ansible setup and it worked well for both the local and for the new S3 storage. The only problem that I could find is when migrating from local to S3, but I think in a later PR someone (or me) can provide a proper command to migrate files from local to S3 storage.
Once again, if you see any problems on the PR, let me know and I will fix in a manageable time, I spend almost a month working on this, so I would like to see it merged 😸 .
Thanks for the awesome tool you guys are providing for the community.