Closed sam0x17 closed 3 years ago
update: I think I have found the discrepancy:
When running du -sh /tmp/jets/[project]/stage/code/vendor/*
On my local system after running jets deploy
I get the following output:
8.0K /tmp/jets/arist/stage/code/vendor/gems
This makes sense because the only thing that should be in there should be the symlinked reference to the gem layer
In my Docker Action after running jets deploy
(after it fails due to size check as usual) I get the following output for the same command:
163M /tmp/jets/arist/stage/code/vendor/bundle
8.0K /tmp/jets/arist/stage/code/vendor/gems
This extra bundle
directory is causing all my problems and seems to only appear on specific systems. I am going to try to patch my fork of jets so this directory is deleted before this stage and see if that fixes things.
Update: yup, that fixes it! Successful deploy! I'll open a pull request shortly
Closed by #577
Checklist
jets upgrade
command that makes this a simple task. There's also an Upgrading Guide: http://rubyonjets.com/docs/upgrading/My Environment
Expected Behaviour
During
jets deploy
, thecompute_size
method inlib/jets/builders/code_size.rb
is used to calculate the total size of thecode
directory and the total size of theopt
directory in bytes. These two numbers are added together and checked against the maximum Lambda code size (currently 250 MB).The
compute_size
method currently shells out todu
to calculate size. Crucially, there is a symlinked directory containing all the compiled gems for the app located inopt
(gem layer) that is symlinked withincode/vendor/gems/ruby/[ruby-version-here]
(code layer). Because of the symlink, the size of the gems within thecode/vendor/gems/ruby/[ruby version here]
symlink should not count towards the total size of thecode
directory, since these files are already contained in theopt
directory (the gem layer).In most environments I've tried, this works fine and
compute_size
(really justdu -ks
) returns the size of thecode
directory minus the size of the symlinked files withincode/vendor/gems/[ruby-version-here]
.Current Behavior
In some environments, including MacOS (haven't directly confirmed if this is always the case, but is the case for some of my colleagues) and GitHub Actions using
ubuntu-latest
(this could apply more broadly to a variety of docker environments -- I don't know the scope of it),du -ks
and thuscompute_size
will include the symlinked gems when calculating the size of thecode
directory, and, ifcompute_size('code')
+compute_size('opt')
is greater than 250 MB, will causejets deploy
to abort complaining that the deployment exceeds the 250 MB limit (even though it does not).Step-by-step reproduction instructions
ubuntu-latest
that deploys the project (sample shown below)Code Sample
Solution Suggestion
This seems to be cross-platform inconsistency with
du
, which is super out of scope for this project. The best solution would be a more portable implementation forcompute_size
written in pure Ruby that is specially crafted to skip symlinked directories (but still count the size of the symlink towards total sie).