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

Fix nodejs-simple cannot find agones-sdk module and update server_tag to 0.8 #2633

Merged
merged 2 commits into from
Jun 27, 2022
Merged

Fix nodejs-simple cannot find agones-sdk module and update server_tag to 0.8 #2633

merged 2 commits into from
Jun 27, 2022

Conversation

govargo
Copy link
Contributor

@govargo govargo commented Jun 17, 2022

What type of PR is this?

/kind bug

What this PR does / Why we need it:

Current nodejs-simple example cannot run due to the module not found.
The agones-sdk module is targeted in the file path but it doesn't exist in the target directory.

$  ls -la node_modules/@google-cloud/agones-sdk
lrwxrwxrwx 1 server root 23 Jun 16 15:43 node_modules/@google-cloud/agones-sdk -> ../../../../sdks/nodejs
$
$ ls -la ../../../../sdks/nodejs
ls: cannot access '../../../../sdks/nodejs': No such file or directory

I found gcr.io/agones-images/nodejs-simple-server:0.6 and gcr.io/agones-images/nodejs-simple-server:0.7 doesn't work.
This PR fix nodejs-simple example bug.

Which issue(s) this PR fixes:

Closes #2625

Special notes for your reviewer:

Q1. I think we have to push docker image gcr.io/agones-images/nodejs-simple-server:0.8.
Can I or you push this image automatically or manually?

Q2. Should I test the e2e test for nodejs-simple?

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: a9ca267c-87bc-4ab7-9f25-ed666c5bb6bb

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@govargo
Copy link
Contributor Author

govargo commented Jun 17, 2022

Network error? I'd like to retest when the rebase

Step 6/8 : RUN apt-get update     && apt-get install -y dotnet-sdk-3.1
 ---> Running in 8322ed04280a
Hit:1 http://deb.debian.org/debian buster InRelease
Hit:2 http://deb.debian.org/debian buster-updates InRelease
Hit:3 http://security.debian.org/debian-security buster/updates InRelease
Get:4 https://packages.microsoft.com/ubuntu/18.04/prod bionic InRelease [4003 B]
Get:5 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 Packages [265 kB]
Fetched 269 kB in 1s (295 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
  aspnetcore-runtime-3.1 aspnetcore-targeting-pack-3.1 dotnet-apphost-pack-3.1
  dotnet-host dotnet-hostfxr-3.1 dotnet-runtime-3.1 dotnet-runtime-deps-3.1
  dotnet-targeting-pack-3.1 netstandard-targeting-pack-2.1
The following NEW packages will be installed:
  aspnetcore-runtime-3.1 aspnetcore-targeting-pack-3.1 dotnet-apphost-pack-3.1
  dotnet-host dotnet-hostfxr-3.1 dotnet-runtime-3.1 dotnet-runtime-deps-3.1
  dotnet-sdk-3.1 dotnet-targeting-pack-3.1 netstandard-targeting-pack-2.1
0 upgraded, 10 newly installed, 0 to remove and 26 not upgraded.
Need to get 82.0 MB of archives.
After this operation, 346 MB of additional disk space will be used.
Err:1 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 dotnet-host amd64 6.0.6-1
  Could not connect to packages.microsoft.com:443 (40.117.131.251), connection timed out
Err:2 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 dotnet-hostfxr-3.1 amd64 3.1.26-1
  Unable to connect to packages.microsoft.com:https:
Err:3 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 dotnet-runtime-deps-3.1 amd64 3.1.26-1
  Unable to connect to packages.microsoft.com:https:
Err:4 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 dotnet-runtime-3.1 amd64 3.1.26-1
  Unable to connect to packages.microsoft.com:https:
Err:5 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 aspnetcore-runtime-3.1 amd64 3.1.26-1
  Unable to connect to packages.microsoft.com:https:
Err:6 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 dotnet-targeting-pack-3.1 amd64 3.1.0-1
  Unable to connect to packages.microsoft.com:https:
Err:7 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 aspnetcore-targeting-pack-3.1 amd64 3.1.10-1
  Unable to connect to packages.microsoft.com:https:
Err:8 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 dotnet-apphost-pack-3.1 amd64 3.1.26-1
  Unable to connect to packages.microsoft.com:https:
Err:9 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 netstandard-targeting-pack-2.1 amd64 2.1.0-1
  Unable to connect to packages.microsoft.com:https:
Err:10 https://packages.microsoft.com/ubuntu/18.04/prod bionic/main amd64 dotnet-sdk-3.1 amd64 3.1.420-1
  Unable to connect to packages.microsoft.com:https:
E: Failed to fetch https://packages.microsoft.com/ubuntu/18.04/prod/pool/main/d/dotnet-host/dotnet-host-6.0.6-x64.deb  Could not connect to packages.microsoft.com:443 (40.117.131.251), connection timed out
E: Failed to fetch https://packages.microsoft.com/ubuntu/18.04/prod/pool/main/d/dotnet-hostfxr-3.1/dotnet-hostfxr-3.1.26-x64.deb  Unable to connect to packages.microsoft.com:https:
E: Failed to fetch https://packages.microsoft.com/ubuntu/18.04/prod/pool/main/d/dotnet-runtime-deps-3.1/dotnet-runtime-deps-3.1.26-x64.deb  Unable to connect to packages.microsoft.com:https:
E: Failed to fetch https://packages.microsoft.com/ubuntu/18.04/prod/pool/main/d/dotnet-runtime-3.1/dotnet-runtime-3.1.26-x64.deb  Unable to connect to packages.microsoft.com:https:
E: Failed to fetch https://packages.microsoft.com/ubuntu/18.04/prod/pool/main/a/aspnetcore-runtime-3.1/aspnetcore-runtime-3.1.26-x64.deb  Unable to connect to packages.microsoft.com:https:
E: Failed to fetch https://packages.microsoft.com/ubuntu/18.04/prod/pool/main/d/dotnet-targeting-pack-3.1/dotnet-targeting-pack-3.1.0-x64.deb  Unable to connect to packages.microsoft.com:https:
E: Failed to fetch https://packages.microsoft.com/ubuntu/18.04/prod/pool/main/a/aspnetcore-targeting-pack-3.1/aspnetcore-targeting-pack-3.1.10.deb  Unable to connect to packages.microsoft.com:https:
E: Failed to fetch https://packages.microsoft.com/ubuntu/18.04/prod/pool/main/d/dotnet-apphost-pack-3.1/dotnet-apphost-pack-3.1.26-x64.deb  Unable to connect to packages.microsoft.com:https:
E: Failed to fetch https://packages.microsoft.com/ubuntu/18.04/prod/pool/main/n/netstandard-targeting-pack-2.1/netstandard-targeting-pack-2.1_2.1.0-1_amd64.deb  Unable to connect to packages.microsoft.com:https:
E: Failed to fetch https://packages.microsoft.com/ubuntu/18.04/prod/pool/main/d/dotnet-sdk-3.1/dotnet-sdk-3.1.420-x64.deb  Unable to connect to packages.microsoft.com:https:
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
make[4]: Leaving directory '/workspace/build'
make[3]: *** [includes/build-image.mk:60: ensure-image] Error 2
make[2]: *** [includes/sdk.mk:123: ensure-build-sdk-image] Error 2

@@ -35,6 +35,7 @@ RUN apt-get update && apt-get install -y nodejs

WORKDIR /home/server

COPY ../../sdks/nodejs sdks/nodejs
Copy link
Collaborator

Choose a reason for hiding this comment

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

The source path may not be correct here, e.g. see https://github.com/googleforgames/agones/blob/main/examples/cpp-simple/Dockerfile#L25 and also the line below which I think means the root project path is being used, which would mean changing to

COPY ./sdks/nodejs sdks/nodejs

Copy link
Contributor Author

@govargo govargo Jun 18, 2022

Choose a reason for hiding this comment

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

Thank you for your review!
As you said, I missed the root path and docker build context.
I fixed the COPY path.

@steven-supersolid
Copy link
Collaborator

What are the problems with gcr.io/agones-images/nodejs-simple-server:0.6 and gcr.io/agones-images/nodejs-simple-server:0.7, as may be best to investigate before publishing a new version?

@govargo
Copy link
Contributor Author

govargo commented Jun 18, 2022

What are the problems with gcr.io/agones-images/nodejs-simple-server:0.6 and gcr.io/agones-images/nodejs-simple-server:0.7, as may be best to investigate before publishing a new version?

Phenomenon

When try running the example container 0.6 or 0.7, the container failed to run with the following error.

% docker run --network=host gcr.io/agones-images/nodejs-simple-server:0.6

> @ start /home/server/examples/nodejs-simple
> node src/index.js

internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module '@google-cloud/agones-sdk'
Require stack:
- /home/server/examples/nodejs-simple/src/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/server/examples/nodejs-simple/src/index.js:15:19)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/home/server/examples/nodejs-simple/src/index.js' ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start: `node src/index.js`
npm ERR! Exit status 1

Direct cause

package.json specifies the agones-sdk with file path, however, the sdk files are not included inside of the container.

# package.json
"dependencies": {
    "@google-cloud/agones-sdk": "file:../../sdks/nodejs"
  },
# inside of the container
$  ls -la node_modules/@google-cloud/agones-sdk
lrwxrwxrwx 1 server root 23 Jun 16 15:43 node_modules/@google-cloud/agones-sdk -> ../../../../sdks/nodejs
$
$ ls -la ../../../../sdks/nodejs
ls: cannot access '../../../../sdks/nodejs': No such file or directory

Root cause

Currently there is no test(E2E) which the gcr.io/agones-images/nodejs-simple-server works fine.
When the update happens to this image, the only the contributor checks if this image works fine.

Originally I sent this PR just to fix this bug, but if E2E test for node-simple is desirable, I would like to add E2E test case.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 0b2dd21b-a551-4fc0-a452-639314fdd890

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@govargo
Copy link
Contributor Author

govargo commented Jun 18, 2022

same error. I would test build-sdk localy and investigate later...
→ I misunderstood. This is another errror. run-sdk-conformance-test-rust failed. Same as #2634 (comment) .

make[3]: *** [includes/sdk.mk:88: run-sdk-command] Error 1
 Downloading crates ...
  Downloaded hermit-abi v0.1.19
  ...
error: failed to parse manifest at `/go/src/agones.dev/agones/test/sdk/rust/.cargo/registry/src/github.51.al-1ecc6299db9ec823/hashbrown-0.12.1/Cargo.toml`

Caused by:
  feature `edition2021` is required

  The package requires the Cargo feature called `edition2021`, but that feature is not stabilized in this version of Cargo (1.55.0 (32da73ab1 2021-08-23)).
  Consider trying a newer version of Cargo (this may require the nightly release).
  See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#edition-2021 for more information about the status of this feature.
make[2]: *** [includes/sdk.mk:88: run-sdk-command] Error 101
make[1]: *** [includes/sdk.mk:152: run-sdk-conformance-test] Error 2
make: *** [includes/sdk.mk:169: run-sdk-conformance-test-rust] Error 2
make: *** Waiting for unfinished jobs....

@markmandel
Copy link
Member

That Rust error was fixed in: #2635 - if you rebase against main, you should be good to go.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 9e53cbda-4c78-41e3-817d-47a7cb01b81d

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2633/head:pr_2633 && git checkout pr_2633
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.tag=1.24.0-765e972-amd64

@govargo
Copy link
Contributor Author

govargo commented Jun 22, 2022

That Rust error was fixed in: #2635 - if you rebase against main, you should be good to go.

Thanks! CI is green.

@steven-supersolid
Copy link
Collaborator

@markmandel - LGTM but there is still the question of whether the docker image push is manual or automatic?

@markmandel
Copy link
Member

@markmandel - LGTM but there is still the question of whether the docker image push is manual or automatic?

Ah! Sorry - yep, example image push is a manual process. We have a check in the release process that makes sure that each example image exists before a release occurs - but we don't build images automatically.

Those of us who have access to the project can push up the images though.

@markmandel
Copy link
Member

We should merge this once the #2637 is merged and the release is complete though.

@markmandel
Copy link
Member

So I just did a local build of the image and tested out running it, and got the following error:

  nodejs-simple git:(pr/fix-nodejs-simple) make run
docker run --network=host gcr.io/agones-images/nodejs-simple-server:0.8

> start
> node src/index.js

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module '@grpc/grpc-js'
Require stack:
- /home/server/sdks/nodejs/src/agonesSDK.js
- /home/server/sdks/nodejs/src/index.js
- /home/server/examples/nodejs-simple/src/index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/server/sdks/nodejs/src/agonesSDK.js:15:14)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/server/sdks/nodejs/src/agonesSDK.js',
    '/home/server/sdks/nodejs/src/index.js',
    '/home/server/examples/nodejs-simple/src/index.js'
  ]
}
make: *** [Makefile:46: run] Error 1

@govargo
Copy link
Contributor Author

govargo commented Jun 23, 2022

So I just did a local build of the image and tested out running it, and got the following error:

Thanks. I confirmed this same error now in my local. This didn't happen before. I'll look to investigate this.

@google-oss-prow google-oss-prow bot removed the lgtm label Jun 23, 2022
@govargo
Copy link
Contributor Author

govargo commented Jun 23, 2022

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 79c07427-33cb-40e9-8681-ab93655075f9

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 0a1094bf-fb17-4deb-8b00-1763f8075783

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2633/head:pr_2633 && git checkout pr_2633
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.tag=1.25.0-5b55483-amd64

@@ -35,6 +35,9 @@ RUN apt-get update && apt-get install -y nodejs

WORKDIR /home/server

COPY ./sdks/nodejs sdks/nodejs
RUN cd sdks/nodejs && \
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure why we have npm rebuild below so this may be a good time to remove it and on this line too, but it won't do anything bad.

npm rebuild calls npm build which is an internal command to npm. The same command is called from npm install already as far as I could gather, so is redundant. Information is a bit scarce on this.

Another potential error in this file is that we are using npm install instead of npm ci. The former can override package-lock.json and also takes slightly longer to run. Generally npm install should only be run by users and npm ci by automation. In this case I don't think we are running tests as part of the Docker build so do not need the dev dependencies and so can use npm ci --production

So these changes are fine but we are duplicating lines that could be better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your great review!!

I updated and tested locally. This works fine.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 08b9fd5d-eb4e-45ad-bbb7-8dba956087f3

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2633/head:pr_2633 && git checkout pr_2633
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.tag=1.25.0-9401cc7-amd64

Copy link
Member

@markmandel markmandel left a comment

Choose a reason for hiding this comment

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

Took this for a run, and it all worked perfectly! Thanks!

@google-oss-prow google-oss-prow bot removed the lgtm label Jun 27, 2022
@google-oss-prow
Copy link

New changes are detected. LGTM label has been removed.

@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: govargo, markmandel, steven-supersolid

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

1 similar comment
@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: govargo, markmandel, steven-supersolid

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 0e6a8df7-0b77-4552-bd82-07b13cb271f8

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/googleforgames/agones.git pull/2633/head:pr_2633 && git checkout pr_2633
  • helm install agones ./install/helm/agones --namespace agones-system --set agones.image.tag=1.25.0-e918121-amd64

@markmandel markmandel merged commit 6e57d34 into googleforgames:main Jun 27, 2022
@govargo govargo deleted the fix-nodejs-simple branch June 30, 2022 13:11
@SaitejaTamma SaitejaTamma added the kind/bug These are bugs. label Jul 26, 2022
@SaitejaTamma SaitejaTamma added this to the 1.25.0 milestone Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nodejs sdk example container fails to run
5 participants