Fix Kubernetes container detection #5681
Merged
+4
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
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
vue-cli/packages/@vue/cli-service/lib/commands/serve.js
Line 300 in 11d60d5
.slice
afterkubepods
.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/ (withserve.js
manually patched insidenode_modules
).