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

A bug with flag --custom-labels when use golang exec.Command() Func #5187

Open
sumengzs opened this issue Sep 24, 2024 · 4 comments
Open

A bug with flag --custom-labels when use golang exec.Command() Func #5187

sumengzs opened this issue Sep 24, 2024 · 4 comments
Assignees

Comments

@sumengzs
Copy link

What happened:

When you exec juicefs mount command with golang and the command include --custom-labels flag, the proccess will exit after panic.

Example:

func main() {
    cmd := exec.Command("juicefs", "mount", "metaurl", "mp", "--custom-labels", "\"key1:value1;key2:value2\"", "-d")
    fmt.Println(cmd.String()) // juicefs mount metaurl mp --custom-labels \"key1:value1;key2:value2\" -d
    if err := cmd.Run(); err != nil {
        log.Fatalf("命令执行失败: %v", err)
    }
}

Err

panic: descriptor Desc{fqName: "juicefs_process_cpu_seconds_total", help: "Total user and system CPU time spent in seconds.", constLabels: {}, variableLabels: []} is invalid: "\"key1" is not a valid label name for metric "juicefs_process_cpu_seconds_total"

What you expected to happen:

How to reproduce it (as minimally and precisely as possible):
like the example

key and value not less than 2

Anything else we need to know?

Environment:

  • JuiceFS version (use juicefs --version) or Hadoop Java SDK version: 1.2.0+2024-06-18.873c47b
  • Cloud provider or hardware configuration running JuiceFS:
  • OS (e.g cat /etc/os-release):
    NAME="Ubuntu"
    VERSION="20.04.6 LTS (Focal Fossa)"
    ID=ubuntu
    ID_LIKE=debian
    PRETTY_NAME="Ubuntu 20.04.6 LTS"
    VERSION_ID="20.04"
    HOME_URL="https://www.ubuntu.com/"
    SUPPORT_URL="https://help.ubuntu.com/"
    BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
    PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
    VERSION_CODENAME=focal
    UBUNTU_CODENAME=focal
  • Kernel (e.g. uname -a):
    Linux 6.1.83-1.2.3 compact slices into bigger one #2 SMP PREEMPT_DYNAMIC Wed May 22 20:08:49 CST 2024 x86_64 x86_64 x86_64 GNU/Linux
  • Object storage (cloud provider and region, or self maintained):self maintained
  • Metadata engine info (version, cloud provider managed or self maintained): redis 7.0
  • Network connectivity (JuiceFS to metadata engine, JuiceFS to object storage):
  • Others:
@sumengzs sumengzs added the kind/bug Something isn't working label Sep 24, 2024
@zhijian-pro
Copy link
Contributor

Your code has a bug, and this is a correct example.

cmd := exec.Command("juicefs", "mount", "redis://127.0.0.1/2", "/tmp/test4", "--custom-labels", "key1:value1;key2:value2")

@zhijian-pro zhijian-pro removed the kind/bug Something isn't working label Sep 24, 2024
@sumengzs
Copy link
Author

sumengzs commented Sep 24, 2024

Your code has a bug, and this is a correct example.

cmd := exec.Command("juicefs", "mount", "redis://127.0.0.1/2", "/tmp/test4", "--custom-labels", "key1:value1;key2:value2")

this is a error command, because key1:value1;key2:value2 have symbol ;, when you exec this command ,it will happen error, you can try it. so we need "" .

if exec the follow command:
it will return ok

juicefs mount meta url mp --custom-labels "key1:value1;key2:value2"

however; if exec this command:
it will return error

juicefs mount meta url mp --custom-labels key1:value1;key2:value2

so we need use "" or '' include multiple keys and values, but, when I use golang exec.Command do that.
it was explained as:

juicefs mount metaurl mp --custom-labels \"key1:value1;key2:value2\"

in this case, juicefs will happen panic.

@zhijian-pro
Copy link
Contributor

cmd := exec.Command("juicefs", "mount", "redis://127.0.0.1/2", "/tmp/test4", "--custom-labels", "key1:value1;key2:value2")
I can run this code normally, and the ; is not a special character, there is no need to use extra ""

@zhijian-pro
Copy link
Contributor

@sumengzs Any updates?

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

No branches or pull requests

2 participants