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

Extra whitespaces in debug opts in alluxio-env.sh causes processes to fail to start #18249

Closed
dbw9580 opened this issue Oct 8, 2023 · 2 comments
Assignees
Labels
type-bug This issue is about a bug

Comments

@dbw9580
Copy link
Contributor

dbw9580 commented Oct 8, 2023

Alluxio Version:
Current main

Describe the bug

Alluxio processes fail to start if ALLUXIO_*_ATTACH_OPTS is set and contains a leading or trailing whitespace.

logs/worker.out says Error: Could not find or load main class. No class name is included in this error message.

To Reproduce

  1. Enable the Java debugger to attach to Alluxio processes e.g. the worker, by setting ALLUXIO_WORKER_ATTACH_OPTS to -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=60003, with a leading whitespace, in conf/alluxio-env.sh.
  2. Start the worker process by running bin/alluxio process start worker
  3. Wait for the worker to start.

Expected behavior

The worker process should start normally, with the debugging port open.

Urgency
Normal

Are you planning to fix it
No

Additional context

func (p *WorkerProcess) Start(cmd *env.StartProcessCommand) error {
cmdArgs := []string{env.Env.EnvVar.GetString(env.ConfJava.EnvVar)}
if attachOpts := env.Env.EnvVar.GetString(confAlluxioWorkerAttachOpts.EnvVar); attachOpts != "" {
cmdArgs = append(cmdArgs, strings.Split(attachOpts, " ")...)
}

The launcher prepends the attach opts to the command, by first splitting the opts with a whitespace as the delimiter. In the case where the opts string contains a leading whitespace, there is a empty string after the split. This empty string is then passed to the java command as a positional argument, which interprets it as the name of a main class.

Since alluxio-env.sh is a shell script, a user can reasonably expect to set the options with a leading whitespace as they are usually concatenated to form a longer command line. Not respecting this convention may be surprising.

@dbw9580 dbw9580 added the type-bug This issue is about a bug label Oct 8, 2023
@dbw9580
Copy link
Contributor Author

dbw9580 commented Oct 8, 2023

@Xenorith FYI.

@Xenorith Xenorith self-assigned this Oct 8, 2023
alluxio-bot pushed a commit that referenced this issue Oct 11, 2023
address #18249

refactor how java opt env vars are handled. previously they were treating as strings and then using a split operation to separate the single string into cmd line arguments. now they are handled as `[]string` immediately after parsing from env to properly handle any leading or trailing whitespaces.
			pr-link: #18252
			change-id: cid-44c4e14465432b0a5d9d8e84b488e9cd13c1e11b
@Xenorith
Copy link
Contributor

fixed by #18252

ssz1997 pushed a commit to ssz1997/alluxio that referenced this issue Dec 15, 2023
address Alluxio#18249

refactor how java opt env vars are handled. previously they were treating as strings and then using a split operation to separate the single string into cmd line arguments. now they are handled as `[]string` immediately after parsing from env to properly handle any leading or trailing whitespaces.
			pr-link: Alluxio#18252
			change-id: cid-44c4e14465432b0a5d9d8e84b488e9cd13c1e11b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug This issue is about a bug
Projects
None yet
Development

No branches or pull requests

2 participants