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 Kubernetes container detection #5681

Merged
merged 1 commit into from Jul 19, 2020

Conversation

lbogdan
Copy link
Contributor

@lbogdan lbogdan commented Jul 14, 2020

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Underlying tools
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Other information:

While configuring a new Kubernetes cluster for CodeSandbox Containers, I've noticed that HMR was not working (again, see #2795). The reason seems to be that cgroup naming has changed in recent Kubernetes versions, and the regex at

return /:\/(lxc|docker|kubepods)\//.test(content)
doesn't match anymore. This PR fixes the regex to match the new cgroup name, adding an optional .slice after kubepods.

I also went ahead and added a special detection for CodeSandbox Containers, by checking if the CODESANDBOX_SSE environment variable is set, so that we can control detection regardless of future cgroup naming changes (or even containerization technology). We would appreciate getting this additional check in, however we can understand if you're hesitant to add 3rd party logic, so just let me know and I'll remove it.

Although it's hard to test the checkInContainer() function, you can see this PR working in our new cluster at https://4iycu.sse.codesandbox.stream/ (with serve.js manually patched inside node_modules).

@sodatea
Copy link
Member

sodatea commented Jul 16, 2020

Codesandbox is a common execution environment for Vue CLI so I'm fine with the environment variable.

But it would be nice if you can document that variable somewhere in the codesandbox documentation so that future contributors can better understand the logic here.

@lbogdan
Copy link
Contributor Author

lbogdan commented Jul 16, 2020

Thanks, we'll update the documentation today!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants