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

checkInContaner REGEX need to be adjusted #5371

Closed
nemoneph opened this issue Apr 9, 2020 · 4 comments
Closed

checkInContaner REGEX need to be adjusted #5371

nemoneph opened this issue Apr 9, 2020 · 4 comments

Comments

@nemoneph
Copy link

nemoneph commented Apr 9, 2020

Version

4.3.1

Environment info

  System:
    OS: Linux 4.19 Alpine Linux
    CPU: (4) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
  Binaries:
    Node: 12.16.1 - /usr/local/bin/node
    Yarn: 1.22.0 - /usr/local/bin/yarn
    npm: 6.13.4 - /usr/local/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0 
    @vue/babel-plugin-transform-vue-jsx:  1.1.2 
    @vue/babel-preset-app:  4.3.1 
    @vue/babel-preset-jsx:  1.1.2 
    @vue/babel-sugar-functional-vue:  1.1.2 
    @vue/babel-sugar-inject-h:  1.1.2 
    @vue/babel-sugar-v-model:  1.1.2 
    @vue/babel-sugar-v-on:  1.1.2 
    @vue/cli-overlay:  4.3.1 
    @vue/cli-plugin-babel: ~4.3.0 => 4.3.1 
    @vue/cli-plugin-eslint: ~4.3.0 => 4.3.1 
    @vue/cli-plugin-router:  4.3.1 
    @vue/cli-plugin-vuex:  4.3.1 
    @vue/cli-service: ~4.3.0 => 4.3.1 
    @vue/cli-shared-utils:  4.3.1 
    @vue/component-compiler-utils:  3.1.2 
    @vue/preload-webpack-plugin:  1.1.1 
    @vue/web-component-wrapper:  1.2.0 
    eslint-plugin-vue: ^6.1.2 => 6.2.2 
    vue: ^2.6.11 => 2.6.11 
    vue-eslint-parser:  7.0.0 
    vue-hot-reload-api:  2.3.4 
    vue-loader:  15.9.1 
    vue-style-loader:  4.1.2 
    vue-template-compiler: ^2.6.11 => 2.6.11 
    vue-template-es2015-compiler:  1.9.1 
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

Hello,
I'm using Minikube (Kubernetes dev environment).
So my vue application run in a container (pod).
My Minikube version is v1.9.2

What is expected?

After an upgrade to minikube v1.9.2
I noticed that the checkInContainer return false instead of true !

https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/commands/serve.js#L344

Indeed with my old version of Minikube (v1.4.0) the output of /proc/1/cgroup was:

bash-5.0# cat /proc/1/cgroup
11:hugetlb:/kubepods/besteffort/pode62a77e6-9d4b-4974-8376-8bb98df015bb/2e26a995b0f0108a688b6b30b24bc424cc95efc20c1a59827ef0bad5e66f9c67
10:perf_event:/kubepods/besteffort/pode62a77e6-9d4b-4974-8376-8bb98df015bb/2e26a995b0f0108a688b6b30b24bc424cc95efc20c1a59827ef0bad5e66f9c67

So it's was good, and checkInContainer return true.

But now with minikube v1.9.2:

bash-5.0# cat /proc/1/cgroup

11:perf_event:/kubepods.slice/kubepods-besteffort.slice/kubepods-besteffort-pod4877e3c2_9915_4991_aa79_cd978f8b89e9.slice/docker-605ec9359d21c5b9fe4e5d511b1edb496e9f53f631a6a48a4798c08021e8b4d9.scope
10:freezer:/kubepods.slice/kubepods-besteffort.slice/kubepods-besteffort-pod4877e3c2_9915_4991_aa79_cd978f8b89e9.slice/docker-605ec9359d21c5b9fe4e5d511b1edb496e9f53f631a6a48a4798c08021e8b4d9.scope

What is actually happening?

It's return false instead of true, the regex need to be upgraded to support the new output of the /proc/1/cgroup
and need to grep "kubepods.slice" ?

@sraillard
Copy link

The current regex used in the function checkInContainer is searching for patterns like /docker/, /kubepods/ and /lxc/. The cgroup names are changing a lot with the different Kuebernetes or Docker versions used. Maybe a less restrictive regex can be used, only searching for the keywords without the /?

@sraillard
Copy link

sraillard commented May 28, 2020

A quick contribution: replacing return /:\/(lxc|docker|kubepods)\//.test(content) by return /(lxc|docker|kubepods)/.test(content) in serve.js is fixing the issue (tested with Kubernetes version 1.18.2).

@0xSimeon
Copy link

0xSimeon commented Jul 6, 2020

Anyone can contribute? This would be my first contribution to OSS

@sodatea
Copy link
Member

sodatea commented Aug 26, 2020

Fixed by #5681

@sodatea sodatea closed this as completed Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants