Skip to content
This repository was archived by the owner on May 6, 2024. It is now read-only.

OPS-1850: use nodeenv for edxapp - #3444

Merged
maxrothman merged 1 commit into
masterfrom
max/edxapp-nodeenv
Nov 17, 2016
Merged

OPS-1850: use nodeenv for edxapp#3444
maxrothman merged 1 commit into
masterfrom
max/edxapp-nodeenv

Conversation

@maxrothman

Copy link
Copy Markdown
Contributor

@edx/devops @bjacobel

@bjacobel

bjacobel commented Nov 2, 2016

Copy link
Copy Markdown
Contributor

@maxrothman How should I go about testing this?

@maxrothman

Copy link
Copy Markdown
Contributor Author

I think building a sandbox off of this branch would work.

@bjacobel

bjacobel commented Nov 2, 2016

Copy link
Copy Markdown
Contributor

ok, nodeenv.sandbox.edx.org is launching

@maxrothman

maxrothman commented Nov 2, 2016

Copy link
Copy Markdown
Contributor Author

@bjacobel it's probably going to fail because I don't think nodeenv is in edxapp's requirements

EDIT: verified. Apps that use nodeenv have it in their requirements.txt, edx-platform does not. I'll make a quick PR.

@maxrothman

Copy link
Copy Markdown
Contributor Author

@bjacobel have you had a chance to test yet?

@bjacobel

bjacobel commented Nov 3, 2016

Copy link
Copy Markdown
Contributor

@maxrothman I haven't, I didn't check the first sandbox I built after you said it would probably fail. Now that edx/edx-platform#13890 is merged I will build a box with configuration_version as origin/max/edxapp-nodeenv and see how it goes.

@bjacobel

bjacobel commented Nov 3, 2016

Copy link
Copy Markdown
Contributor

@maxrothman Got an error building the sandbox: http://jenkins.edx.org:8080/view/Ansible/job/ansible-provision/9885/

Could be I just configured something wrong, I've never launched one with a non-master configuration version before. You probably know much more about this than me, you want to just ping me when there's a box I can SSH into and poke around?

@maxrothman

maxrothman commented Nov 3, 2016

Copy link
Copy Markdown
Contributor Author

It's an issue with my code. Hang on, I'll fix it.

EDIT: @bjacobel fixed

@maxrothman

Copy link
Copy Markdown
Contributor Author

@bjacobel I built this sandbox from scratch. Though the build failed, it got past the edxapp section so you should be able to use it for testing.

@bjacobel

bjacobel commented Nov 4, 2016

Copy link
Copy Markdown
Contributor

I SSHed in and did some poking around, everything seemed ok up until the point I started trying to run things with node modules that (I think?) should be installed on sandboxes.

 wheatley > ~ > code > edx-pattern-library > master > $ > ssh nodeenv.sandbox.edx.org
Welcome to Ubuntu 12.04.5 LTS (GNU/Linux 3.2.0-101-virtual x86_64)


*******************************************************************
*     ___                         _ __  __                        *
*    / _ \ _ __ ___ _ _    ___ __| |\ \/ / (R)                    *
*   | |_| | '_ \ -_) ' \  / -_) _` | >  <                         *
*    \___/| .__/___|_|_|  \___\__,_|/_/\_\                        *
*         |_|                                                     *
*                                                                 *
* This system is for the use of authorized users only.  Usage of  *
* this system may be monitored and recorded by system personnel.  *
*                                                                 *
* Anyone using this system expressly consents to such monitoring  *
* and is advised that if such monitoring reveals possible         *
* evidence of criminal activity, system personnel may provide the *
* evidence from such monitoring to law enforcement officials.     *
*                                                                 *
* Need help? https://open.edx.org/getting-help                    *
*                                                                 *
*******************************************************************
This system will be terminated on Nov 10, 2016
Last login: Fri Nov  4 14:15:39 2016 from dhcp-18-189-127-242.dyn.mit.edu
[nodeenv] bjacobel@nodeenv i-12022c8b:~$ which node
/usr/bin/node
[nodeenv] bjacobel@nodeenv i-12022c8b:~$ node --version
v0.10.37
[nodeenv] bjacobel@nodeenv i-12022c8b:~$ which npm
/usr/bin/npm
[nodeenv] bjacobel@nodeenv i-12022c8b:~$ npm version
{ http_parser: '1.0',
  node: '0.10.37',
  v8: '3.14.5.9',
  ares: '1.9.0-DEV',
  uv: '0.10.36',
  zlib: '1.2.8',
  modules: '11',
  openssl: '1.0.1l',
  npm: '1.4.28' }
[nodeenv] bjacobel@nodeenv i-12022c8b:~$ npm bin
/home/bjacobel/node_modules/.bin
[nodeenv] bjacobel@nodeenv i-12022c8b:~$ sudo su edxapp -s /bin/bash
edxapp@nodeenv:/home/bjacobel$ source ~/edxapp_env
edxapp@nodeenv:/home/bjacobel$ cd /edx/app/edxapp/edx-platform
edxapp@nodeenv:~/edx-platform$ which node
/edx/app/edxapp/nodeenvs/edxapp/bin/node
edxapp@nodeenv:~/edx-platform$ node --version
v0.10.37
edxapp@nodeenv:~/edx-platform$ which npm
/edx/app/edxapp/nodeenvs/edxapp/bin/npm
edxapp@nodeenv:~/edx-platform$ npm --version
1.4.28

(everything looked ok up to this point)

edxapp@nodeenv:~/edx-platform$ npm bin
/edx/app/edxapp/edx-platform/node_modules/.bin
edxapp@nodeenv:~/edx-platform$ ls -al $(npm bin)
ls: cannot access /edx/app/edxapp/edx-platform/node_modules/.bin: No such file or directory
edxapp@nodeenv:~/edx-platform$ $(npm bin)/eslint
bash: /edx/app/edxapp/edx-platform/node_modules/.bin/eslint: No such file or directory
edxapp@nodeenv:~/edx-platform$ ls -al /edx/app/edxapp/edx-platform/node_modules
ls: cannot access /edx/app/edxapp/edx-platform/node_modules: No such file or directory
edxapp@nodeenv:~/edx-platform$

Can't find any node modules in this nodeenv. Or maybe I'm not actually in the nodeenv? It's confusing because I named the sandbox nodeenv. But none of the node modules I would expect to be installed are in /edx/app/edxapp/nodeenvs/edxapp/lib either.

@maxrothman

Copy link
Copy Markdown
Contributor Author

@bjacobel let's connect later this morning and figure it out.

@bjacobel

bjacobel commented Nov 4, 2016

Copy link
Copy Markdown
Contributor

👍 maxrothman.sandbox.edx.org is looking good with these changes

@maxrothman

Copy link
Copy Markdown
Contributor Author

Tests are running in https://github.com/edx/configuration/pull/3449 because this requires a change on master in edx-platform but the tests run on release.

@maxrothman

Copy link
Copy Markdown
Contributor Author

Tests have passed in #3449

@e0d

e0d commented Nov 7, 2016

Copy link
Copy Markdown
Contributor

I'm 👍 for this change.

@benpatterson is there anything you'd like to see before merging this?

@benpatterson

Copy link
Copy Markdown
Contributor

I'd look for some solution in the jenkins_worker role; that's currently using the chrislea PPA and that's how we'll be executing tests....

Where did you see that in the overall plan? Do we move one without the other?

@e0d

e0d commented Nov 7, 2016

Copy link
Copy Markdown
Contributor

@benpatterson Hmm, I'm a little surprised the worker is using different code -- I hadn't realized that when we discussed last week. I think they should be the same, but that the key thing is that we are using the same node and npm versions. The chrislea PPA is not available for xenial, so I think moving the nodeenv is the right thing to do. Who can we talk to about your usecases for node/npm?

@benpatterson

Copy link
Copy Markdown
Contributor

@e0d Oh, I am totally on board with moving to nodeenv. I was moreso pointing out this. I think the reason that's there today might be legacy...when it was originally added, we did not have the edxapp_common role. So arguably it's a matter of cleaning up that side of things.

What I was also inferring was that using nodeenv has not been built into edxapp CI yet. Currently it's using the node/npm versions it finds on the machine it's running on (supplied by the jenkins_worker role). The questions at this juncture would revolve around how we'd want to roll out changes here. If you merge this and deploy using this, then there is the risk of different node environments. If, OTOH, we build this onto edx-platform first, then there is the risk of waiting for that to land (might be a couple of weeks? if we wait for the Tools team).

Happy to take this offline...it's a somewhat strategic/logistical set of questions. But I think we want the same thing here ultimately: both the test and prod infrastructures to be as similar as possible.

@e0d

e0d commented Nov 7, 2016

Copy link
Copy Markdown
Contributor

I'd really like to take the steps to ensure that we're testing the same we we deploy. Doesn't feel like this would be a huge effort, but I'd like to talk through the repercussions.

@nedbat FYI


- name: create nodeenv
shell: >
{{ edxapp_venv_dir }}/bin/nodeenv {{ edxapp_nodeenv_dir }} --node={{ edxapp_node_version }} --prebuilt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you use --force then this can be idempotent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The creates arg below means that it won't attempt to create it when the directory is present. However, this won't replace a nodeenv with the wrong node version. Are you saying we should ditch creates and only use --force? That's not how we're doing it elsewhere.

I think the right approach might be to make that change in all the places that create nodeenvs in a separate PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah I missed the creates arg. No, you are right...that's how idempotency is achieved. I was more concerned with running the same script twice than I was changing the node version. Perhaps you need to register the node version and ensure that's what was created?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The more I think about it, the more I think creates actually does the wrong thing. I think --force is safer, but we should do it in a separate PR in all the places that make nodeenvs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed ^

benpatterson referenced this pull request in openedx/openedx-platform Nov 9, 2016
This change:
* gives us the flexibility of managing node from pull-request to pull-request. It'll be a huge lift to folks that want to test out node upgrades like @bjacobel or @andy-armstrong
* Sets us up for a port to Xenial, which will be accomplished in part by using nodeenv for managing the node environment. See a companion PR on the configuration repo for edxapp: edx/configuration#3444

This pull request does not:
* Attempt to solve any stability issues in builds related to node.
* Make node installs any faster
* Create any caching infrastructure to speed up node installs. They will be approximately as fast as they were before. Downloading the node bits build-to-build adds about 3 seconds, which is worth it for the added flexibility.
benpatterson referenced this pull request in openedx/openedx-platform Nov 10, 2016
This change:
* gives us the flexibility of managing node from pull-request to pull-request. It'll be a huge lift to folks that want to test out node upgrades like @bjacobel or @andy-armstrong
* Sets us up for a port to Xenial, which will be accomplished in part by using nodeenv for managing the node environment. See a companion PR on the configuration repo for edxapp: edx/configuration#3444

This pull request does not:
* Attempt to solve any stability issues in builds related to node.
* Make node installs any faster
* Create any caching infrastructure to speed up node installs. They will be approximately as fast as they were before. Downloading the node bits build-to-build adds about 3 seconds, which is worth it for the added flexibility.
@feanil feanil mentioned this pull request Nov 10, 2016
1 task
@benpatterson

Copy link
Copy Markdown
Contributor

Closing the loop on this, I am 👍

@maxrothman
maxrothman merged commit 1a75f79 into master Nov 17, 2016
@maxrothman
maxrothman deleted the max/edxapp-nodeenv branch November 17, 2016 15:02
@benpatterson

Copy link
Copy Markdown
Contributor

🎉

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants