-
Notifications
You must be signed in to change notification settings - Fork 34
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
[BUG] Zip file resolution error when deploying a single artifact #82
Comments
Hey i just saw this bug. Is it happening to everyone who is trying to use the beta version then? |
@tstackhouse would this help? --> https://github.com/flowaccount/nx-plugins/pull/84/files#diff-83dc8d582b8fb37ed63b28f9d66778aaf1b91d48495c4085387fda2eed4afdef also i merged the latest code into master although the test isn't working yet. Will try to find time to make them work. |
It's a step in the right direction, though I was doing some more testing and found another issue in the upload artifacts step when not packaging individually: https://github.com/serverless/serverless/blob/master/lib/plugins/aws/deploy/lib/uploadArtifacts.js#L104-L116 That usage of And because of that, it's not actually overridden by the time we do the override in deploy.impl.ts. Using |
so should we set the package.artifact? |
The opposite actually, at least in my experience. Packaging individually works because it goes inside both if statements in that code in uploadArtifacts.js. Not packaging individually only goes into the outer if, as the artifact is set in https://github.com/serverless/serverless/blob/master/lib/plugins/package/lib/packageService.js#L99-L113 during the packat step. Commenting the return on line 115 allows the if statement to be exited and the deploy works correctly. |
|
problem is i released 1.0.0-beta and the code has changed Alot....my bad for lack of communications. Want to make sure it works and we are talking about the same issue. I am testing out with packagingIndividually flags now |
ok i found out that if i set There was an error with the build. Error: ENOENT: no such file or directory, open trying to solve it |
Sorry, I was on my phone and getting out a detailed reply is tricky. like 115 in uploadArtifacts.js: https://github.com/serverless/serverless/blob/master/lib/plugins/aws/deploy/lib/uploadArtifacts.js#L115
No worries about the 1.0.0-beta, I need to see what if anything I would need to do to use serverless 2 in my project over 1.x.
That's exactly it. I did see that you fixed an issue in the beta that I was going to submit a fix for that I saw in 0.5.3: In the beta:
in 0.5.3: https://github.com/flowaccount/nx-plugins/blob/0.5.3/libs/nx-serverless/src/builders/deploy/deploy.impl.ts#L138-L141 There was no logging on deploy failure, so it would silently exit the |
yeh I had to refactor the whole thing to work with nx-12 .. Its another pattern that is used with nx/dev-kit and generators etc etc as well. So i am investigating why the path changed. I think it has something to do with the serverless lifeCycle hooks |
I'm investigating updating to 2.x and at least upon first impressions, the way this plugin handling initializing serverless, if we use an SSM reference in our
|
Replying from phone
Check the first line of import
Serverless 2 uses local serverless so when debugging have to use the path
to the debugging api i commented it out as example
Would be good to reuse the serverless resolveLocal function
…On Sat, Jun 5, 2021, 12:30 AM Tim Stackhouse, ***@***.***> wrote:
I'm investigating updating to 2.x and at least upon first impressions, the
way this plugin handling initializing serverless, if we use an SSM
reference in our serverless.yml, the framework attempts to parse the
config and fails because the aws plugin isn't loaded, I tried commenting
out all my SSM params from the config, but when it gets to the deploy step,
it seems to blow out:
npx nx deploy my-api --stage=my-stage
// Build output removed
dist/.serverlessPackages/apps/my-api
Copying build output files from dist/apps/my-api to dist/.serverlessPackages/apps/my-api to be packaged
Done copying build output files.
running serverless commands
There was an error with the build. ServerlessError: Serverless command "deploy" not found. Did you mean "undefined"? Run "serverless help" for a list of all available commands..
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#82 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALY2EXYFBDGXYA5UDROEHTTREET5ANCNFSM45SVIVWA>
.
|
in
this will make thigs work |
@tstackhouse the deploy per function is working now in |
I've been able to get back into this a bi, trying to update to 1.1.0 and serverless 2 in my project, and this bug is related to a slightly different issue, when using I'm kind of just putting words on paper at this point, so forgive me, I've been iterating on this and getting back into the headspace all day today. It seems to me that it should be possible through configuration or code changes to alleviate this, I keep coming back to the |
I've actually tracked down an easy potential fix for this, by changing the code here: https://github.com/flowaccount/nx-plugins/blob/master/libs/nx-serverless/src/utils/serverless.ts#L126-L132 from:
to
Omitting the extra conditionals and correcting the config option name a project with I can try to pull together a PR tomorrow |
Describe the bug
When overwriting
servicePath
with thepackagePath
in deploy.impl.ts:123 (and in earlier iterations) because of the relative pathing, inside serverless' packaging routines, the package path gets appended twice, resulting in a silent failure caused by an ENOENT when deploy attempts to read the generated zip artifacts:https://github.com/serverless/serverless/blob/master/lib/plugins/package/lib/zipService.js#L67
https://github.com/serverless/serverless/blob/master/lib/plugins/aws/deploy/lib/checkForChanges.js#L158-L162
package.artifact
is populated whenpackage.individually
is set tofalse
inserverless.yml
:https://github.com/serverless/serverless/blob/master/lib/plugins/package/lib/packageService.js#L99-L113
Inspecting the
filePath
that comes back inpackageAll
, we can see the following:That
filePath
then gets set toservice.package.artifact
which we can see incheckIfDeploymentIsNecessary
incheckForChanges.js
we can inspectzipFiles
andzipFilePaths
and see the incorrect path resolution forartifact
:We can see that the resolution on the prior step appends
servicePath
again which then on subsequent lines results in a silent ENOENT when serverless attempts to calculate the hash of the non-existant zip file. I already have tried to reproduce this through serverless directly, but as we are manipulating the runtime configuration in real time here, it is not easily reproducible through the command line forsls
.Suggested resolution
After a lot of trial and error if we modify the
servicePath
override on https://github.com/flowaccount/nx-plugins/blob/master/libs/nx-serverless/src/builders/deploy/deploy.impl.ts#L123 to be like so:This solves the path resolution issue by preventing
path.resolve
from incorrectly attempting to append the path:I want to submit a PR, but I've already spent days on this, and would need to upgrade my fork to match the master branch which includes the beta work for supporting serverless 2, which is a whole other can of worms for my project.
My repo with the change is here: https://github.com/tstackhouse/nx-plugins along with a solo build branch so I can pull it into my project: https://github.com/tstackhouse/nx-plugins/tree/nx-serverless-2
I have it on my radar to plan for upgrades in the near future (I hope) and am excited to see this flourish. I've seen some of the work to support Nx11, which would be awesome as well.
Check which provider is affected:
[x] AWS
[?] Azure
[?] Google Cloud Platform
Check which framework is affected:
[ ] Angular
[x] Nodejs
[x] Serverless
[ ] Lambda
[ ] Infrastructure as a code
Additional context
Currently using 0.5.3 of this plugin
Node 12.18.3
npm 6.14.6
serverless:
Framework Core: 1.79.0
Plugin: 3.7.1
SDK: 2.3.1
Components: 2.34.6
The text was updated successfully, but these errors were encountered: