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

fails to run in docker because user is nil #84

Closed
3 tasks done
dzmitry-lahoda opened this issue Aug 4, 2023 · 14 comments
Closed
3 tasks done

fails to run in docker because user is nil #84

dzmitry-lahoda opened this issue Aug 4, 2023 · 14 comments
Labels
bug Something isn't working

Comments

@dzmitry-lahoda
Copy link

dzmitry-lahoda commented Aug 4, 2023

Defect

Make sure that these boxes are checked before submitting your issue -- thank you!

  • Included the relevant configuration snippet
  • Included the relevant process-compose log (log location: process-compose info)
  • Included a [Minimal, Complete, and Verifiable example] (https://stackoverflow.com/help/mcve)

Version of process-compose:

 docker run -it --entrypoint bash composablefi/devnet-xc:f110a75b84068c72c0d6589d964649547c0f9c74 
bash-5.2# cat devnet-xc-background
#!/nix/store/a7f7xfp9wyghf44yv6l6fv9dfw492hd3-bash-5.2-p15/bin/bash
set -o errexit
set -o nounset
set -o pipefail

export PATH="/nix/store/k01vbwj28s01da6f95r7qkiw2c56p52f-process-compose-0.51.4/bin:$PATH"

cat /nix/store/f50cr9qh6lc7cawbz8dbmf6nj9pl7k5k-devnet-xc-background.yaml
export PC_CONFIG_FILES=/nix/store/f50cr9qh6lc7cawbz8dbmf6nj9pl7k5k-devnet-xc-background.yaml
export PC_DISABLE_TUI=true
exec process-compose -p 8080 "$@"

bash-5.2# PATH="/nix/store/k01vbwj28s01da6f95r7qkiw2c56p52f-process-compose-0.51.4/bin:$PATH"
bash-5.2# 
bash-5.2# process-compose    
{"level":"fatal","error":"user: lookup userid 0: no such file or directory","time":"2023-08-04T00:27:45Z","message":"Failed to retrieve user info"}
bash-5.2# process-comepose --version
bash: process-comepose: command not found
bash-5.2# ^[[A^C
bash-5.2# process-compose --version
{"level":"fatal","error":"user: lookup userid 0: no such file or directory","time":"2023-08-04T00:28:00Z","message":"Failed to retrieve user info"}
bash-5.2# process-compose version      
{"level":"fatal","error":"user: lookup userid 0: no such file or directory","time":"2023-08-04T00:28:09Z","message":"Failed to retrieve user info"}
bash-5.2# process-compose -v       
{"level":"fatal","error":"user: lookup userid 0: no such file or directory","time":"2023-08-04T00:28:18Z","message":"Failed to retrieve user info"}
bash-5.2# process-compose -version 
{"level":"fatal","error":"user: lookup userid 0: no such file or directory","time":"2023-08-04T00:28:22Z","message":"Failed to retrieve user info"}
bash-5.2# process-compose --help   
{"level":"fatal","error":"user: lookup userid 0: no such file or directory","time":"2023-08-04T00:28:28Z","message":"Failed to retrieve user info"}
bash-5.2# 

OS environment:

Docker.

Steps or code to reproduce the issue:

 docker run -it  composablefi/devnet-xc:main 

Expected result:

Runs or other error.

Actual result:

actions-runner@Ubuntu-2204-jammy-amd64-base:~$ docker run -it  composablefi/devnet-xc:f110a75b84068c72c0d6589d964649547c0f9c74 
processes:
  centauri:
    availability:
      restart: on_failure
    command: /nix/store/4l88isl2fhib4zsdq94xx3sspjs70jsg-centaurid-gen/bin/centaurid-gen
    log_location: /tmp/composable-devnet/centauri.log
    readiness_probe:
      failure_threshold: 3
      http_get:
        host: 127.0.0.1
        path: /
        port: 26657
        scheme: http
      initial_delay_seconds: 0
      period_seconds: 10
      success_threshold: 1
      timeout_seconds: 3
  centauri-init:
    availability:
      restart: on_failure
    command: /nix/store/65jjn2ckp8qa32k935ill8liqifx4l4x-centaurid-init/bin/centaurid-init
    depends_on:
      centauri:
        condition: process_healthy
    log_location: /tmp/composable-devnet/centauri-init.log
  composable:
    availability:
      restart: on_failure
    command: /nix/store/07q9wz30dchv8s64zxqfdzhb4nbbvcvw-zombienet-composable-centauri-b/bin/zombienet-composable-centauri-b
    log_location: /tmp/composable-devnet/composable.log
    readiness_probe:
      exec:
        command: |
          curl --header "Content-Type: application/json" --data '{"id":1, "jsonrpc":"2.0", "method" : "assets_listAssets"}' http://127.0.0.1:32201
      failure_threshold: 8
      initial_delay_seconds: 32
      period_seconds: 8
      success_threshold: 1
      timeout_seconds: 2
  composable-picasso-ibc-channels-init:
    availability:
      restart: on_failure
    command: "HOME=\"/tmp/composable-devnet/composable-picasso-ibc\"\nexport HOME       \nRUST_LOG=\"hyperspace=info,hyperspace_parachain=debug,hyperspace_cosmos=debug\"\nexport RUST_LOG\n/nix/store/f6anaxjgf6i33380mz03njaks17hcvb3-hyperspace-composable-rococo-picasso-rococo/bin/hyperspace create-channel --config-a /tmp/composable-devnet/composable-picasso-ibc/config-chain-a.toml --config-b /tmp/composable-devnet/composable-picasso-ibc/config-chain-b.toml --config-core /tmp/composable-devnet/composable-picasso-ibc/config-core.toml --delay-period 10 --port-id transfer --version ics20-1 --order unordered\n"
    depends_on:
      composable-picasso-ibc-connection-init:
        condition: process_completed_successfully
    log_location: /tmp/composable-devnet/composable-picasso-ibc-channels-init.log
  composable-picasso-ibc-connection-init:
    availability:
      restart: on_failure
    command: "HOME=\"/tmp/composable-devnet/composable-picasso-ibc\"\nexport HOME                \nRUST_LOG=\"hyperspace=info,hyperspace_parachain=debug,hyperspace_cosmos=debug\"\nexport RUST_LOG      \n/nix/store/f6anaxjgf6i33380mz03njaks17hcvb3-hyperspace-composable-rococo-picasso-rococo/bin/hyperspace create-connection --config-a /tmp/composable-devnet/composable-picasso-ibc/config-chain-a.toml --config-b /tmp/composable-devnet/composable-picasso-ibc/config-chain-b.toml --config-core /tmp/composable-devnet/composable-picasso-ibc/config-core.toml --delay-period 10\n"
    depends_on:
      composable-picasso-ibc-init:
        condition: process_completed_successfully
    log_location: /tmp/composable-devnet/composable-picasso-ibc-connection-init.log
  composable-picasso-ibc-init:
    availability:
      restart: on_failure
    command: /nix/store/ag4h4pzbsfsybxfkq9vwxnhrvpy44lbc-composable-picasso-ibc-init/bin/composable-picasso-ibc-init
    depends_on:
      composable:
        condition: process_healthy
      picasso:
        condition: process_healthy
      picasso-centauri-ibc-channels-init:
        condition: process_completed_successfully
    log_location: /tmp/composable-devnet/composable-picasso-ibc-init.log
  composable-picasso-ibc-relay:
    availability:
      restart: on_failure
    command: /nix/store/rps5vp8r12ppn268hq7zldk4hx42jb5c-composable-picasso-ibc-relay/bin/composable-picasso-ibc-relay
    depends_on:
      composable-picasso-ibc-channels-init:
        condition: process_completed_successfully
    log_location: /tmp/composable-devnet/composable-picasso-ibc-relay.log
  osmosis:
    command: /nix/store/vpg6764j5wagzmlqml3vmsh3288yh8ig-osmosisd-gen/bin/osmosisd-gen
    log_location: /tmp/composable-devnet/osmosis.log
    readiness_probe:
      failure_threshold: 3
      http_get:
        host: 127.0.0.1
        path: /
        port: 36657
        scheme: http
      initial_delay_seconds: 0
      period_seconds: 10
      success_threshold: 1
      timeout_seconds: 3
  osmosis-centauri-hermes-init:
    availability:
      restart: on_failure
    command: /nix/store/pbglg0a7f9a52b0f7af15g3r8cc8698m-osmosis-centauri-hermes-init/bin/osmosis-centauri-hermes-init
    depends_on:
      centauri-init:
        condition: process_completed_successfully
      osmosis:
        condition: process_healthy
      picasso-centauri-ibc-channels-init:
        condition: process_completed_successfully
    log_location: /tmp/composable-devnet/osmosis-centauri-hermes-init.log
  osmosis-centauri-hermes-relay:
    availability:
      restart: on_failure
    command: /nix/store/dal3sw1j21vvrv1ib6l8hxcsirc1na6r-osmosis-centauri-hermes-relay/bin/osmosis-centauri-hermes-relay
    depends_on:
      osmosis-centauri-hermes-init:
        condition: process_completed_successfully
    log_location: /tmp/composable-devnet/osmosis-centauri-hermes-relay.log
  osmosis-init:
    availability:
      restart: on_failure
    command: /nix/store/ggrnlgq6rfwhp5r9h067l8kwi358qf8s-osmosisd-init/bin/osmosisd-init
    depends_on:
      osmosis:
        condition: process_healthy
    log_location: /tmp/composable-devnet/osmosis-init.log
  picasso:
    availability:
      restart: on_failure
    command: /nix/store/3khkmb88vyw376agfczi0k0j2hfqr62h-zombienet-rococo-local-picasso-dev/bin/zombienet-rococo-local-picasso-dev
    log_location: /tmp/composable-devnet/picasso.log
    readiness_probe:
      exec:
        command: |
          curl --header "Content-Type: application/json" --data '{"id":1, "jsonrpc":"2.0", "method" : "assets_listAssets"}' http://127.0.0.1:32200
      failure_threshold: 8
      initial_delay_seconds: 32
      period_seconds: 8
      success_threshold: 1
      timeout_seconds: 2
  picasso-centauri-ibc-channels-init:
    availability:
      restart: on_failure
    command: /nix/store/w9c4fcnzkkwjvqzlxms63fzlp4warksd-picasso-centauri-ibc-channels-init/bin/picasso-centauri-ibc-channels-init
    depends_on:
      picasso-centauri-ibc-connection-init:
        condition: process_completed_successfully
    log_location: /tmp/composable-devnet/picasso-centauri-ibc-channels-init.log
  picasso-centauri-ibc-connection-init:
    availability:
      restart: on_failure
    command: /nix/store/g0kknc92nbn99h5wgk7sxf8zlw4v9rb2-picasso-centauri-ibc-connection-init/bin/picasso-centauri-ibc-connection-init
    depends_on:
      picasso-centauri-ibc-init:
        condition: process_completed_successfully
    log_location: /tmp/composable-devnet/picasso-centauri-ibc-connection-init.log
  picasso-centauri-ibc-init:
    availability:
      restart: on_failure
    command: /nix/store/parh7f1mvlkjyfs1kz0xxmp64lqmv96n-picasso-centauri-ibc-init/bin/picasso-centauri-ibc-init
    depends_on:
      centauri:
        condition: process_healthy
      centauri-init:
        condition: process_completed_successfully
      picasso:
        condition: process_healthy
    log_location: /tmp/composable-devnet/picasso-centauri-ibc-init.log
  picasso-centauri-ibc-relay:
    availability:
      restart: on_failure
    command: /nix/store/9nwl712053i5zgb8qdxfammx288091gi-picasso-centauri-ibc-relay/bin/picasso-centauri-ibc-relay
    depends_on:
      picasso-centauri-ibc-channels-init:
        condition: process_completed_successfully
    log_location: /tmp/composable-devnet/picasso-centauri-ibc-relay.log
shell:
  shell_argument: -c
  shell_command: /nix/store/a7f7xfp9wyghf44yv6l6fv9dfw492hd3-bash-5.2-p15/bin/bash
{"level":"fatal","error":"user: lookup userid 0: no such file or directory","time":"2023-08-04T00:26:18Z","message":"Failed to retrieve user info"}
@dzmitry-lahoda
Copy link
Author

func mustUser() string {
	usr, err := user.Current()
	if err != nil {
		log.Fatal().Err(err).Msg("Failed to retrieve user info")
	}
	return usr.Username
}

when in docker use other thing

@dzmitry-lahoda
Copy link
Author

bash-5.2# whoami
whoami: cannot find name for user ID 0: No such file or directory

@adrian-gierakowski
Copy link
Contributor

I guess you built you images with nix? You should use fakeNss or shadowSetup. There are many programs out there which will fail without it.

github-merge-queue bot pushed a commit to ComposableFi/composable that referenced this issue Aug 4, 2023
![image](https://github.com/ComposableFi/composable/assets/757125/1f288499-3285-438b-9499-68847851b52e)


Required for merge:
- [ ] `pr-workflow-check / draft-release-check` is ✅ success
- Other rules GitHub shows you, or can be read in
[configuration](../terraform/github.com/branches.tf)

Makes review faster:
- [x] PR title is my best effort to provide summary of changes and has
clear text to be part of release notes
- [ ] I marked PR by `misc` label if it should not be in release notes
- [x] Linked Zenhub/Github/Slack/etc reference if one exists
F1bonacc1/process-compose#84
- [ ] I was clear on what type of deployment required to release my
changes (node, runtime, contract, indexer, on chain operation, frontend,
infrastructure) if any in PR title or description
- [ ] Added reviewer into `Reviewers`
- [x] I tagged(`@`) or used other form of notification of one person who
I think can handle best review of this PR
- [ ] I have proved that PR has no general regressions of relevant
features and processes required to release into production
- [ ] Any dependency updates made, was done according guides from
relevant dependency
- Clicking all checkboxes 
- Adding detailed description of changes when it feels appropriate (for
example when PR is big)
@dzmitry-lahoda
Copy link
Author

yeah, fixed liked that.

but process compose is ideal with nix as nix already decent isolation, just need some decent process manager working slick out of box.

@thenonameguy
Copy link
Sponsor Contributor

Great response @adrian-gierakowski.

This is not a bug in process-compose, it's fair to assume for the common usecases that nss will be set up.

IMO this should be closed.

@dzmitry-lahoda
Copy link
Author

dzmitry-lahoda commented Aug 4, 2023

@thenonameguy for this exact case, user name is used only to setup logging file name.

func GetLogFilePath() string {
	val, found := os.LookupEnv(LogPathEnvVarName)
	if found {
		return val
	}
	return filepath.Join(os.TempDir(), fmt.Sprintf("process-compose-%s%s.log", mustUser(), mode()))
}

not sure if this is really blocker to not use user and make nix use cases simpler.

if there was more complicated use, like some security setting or like, sure, but in this case it is not needed to be like that.

fix also could be set LogPathEnvVarName as I see.

but seems fix is just if no user than %s for user would be empty string because no user

@thenonameguy
Copy link
Sponsor Contributor

I see, fair point.

I guess a fallback to the stringified PID of the process-compose process itself would be preferable.

Since that would not be a breakage and still keep some form of isolation between concurrently running process-compose instances, it would be a fine relaxation of the runtime environment dependencies.

github-merge-queue bot pushed a commit to ComposableFi/composable that referenced this issue Aug 4, 2023
…espace (#4016)

![image](https://github.com/ComposableFi/composable/assets/757125/1f288499-3285-438b-9499-68847851b52e)


Required for merge:
- [x] `pr-workflow-check / draft-release-check` is ✅ success
- Other rules GitHub shows you, or can be read in
[configuration](../terraform/github.com/branches.tf)

Makes review faster:
- [x] PR title is my best effort to provide summary of changes and has
clear text to be part of release notes
- [x] I marked PR by `misc` label if it should not be in release notes
- [x] Linked Zenhub/Github/Slack/etc reference if one exists
F1bonacc1/process-compose#84
- [x] I was clear on what type of deployment required to release my
changes (node, runtime, contract, indexer, on chain operation, frontend,
infrastructure) if any in PR title or description
- [x] Added reviewer into `Reviewers`
- [x] I tagged(`@`) or used other form of notification of one person who
I think can handle best review of this PR
- [x] I have proved that PR has no general regressions of relevant
features and processes required to release into production
- [x] Any dependency updates made, was done according guides from
relevant dependency
- Clicking all checkboxes 
- Adding detailed description of changes when it feels appropriate (for
example when PR is big)
@dzmitry-lahoda
Copy link
Author

fix is simple, so it would take me hours to catch up with the thing because i am not go dev. will donate 50 usd in crypto to project for fix. btw another nice use case why nix/guix/(partially will work on win/mac sandboxes so) may be target nieche for product #87

@F1bonacc1
Copy link
Owner

Hi,

Sorry for the late response. I was away for some time.
What would be the expected fallback in this case?

  1. Not to fail the PC (exit=1).
  2. Return an empty string.
  3. Return a predefined ENV variable and fail if nothing is defined.
  4. Return some arbitrary value UNKNOW or NOBODY.
  5. Something else?

@dzmitry-lahoda
Copy link
Author

most complex fix to use specific mod to detect user on non posix compliant systems. i guess go has one. so it will detect root in this case.

in docker afaik there is USER env set usually, try it may be too. it seems set without shadow. https://unix.stackexchange.com/questions/76354/who-sets-user-and-username-environment-variables/76356

empty string will work great too.

i guess most automated way will work.

@dzmitry-lahoda
Copy link
Author

what would happen in case of conflict using same file? new PC will fail to start? can add root process id as suffix for any files created as part of run?

@F1bonacc1
Copy link
Owner

Will be fixed in the next release.
There will be a warning message, that can be avoided if USER env variable is defined.

@F1bonacc1 F1bonacc1 added the bug Something isn't working label Sep 9, 2023
@F1bonacc1
Copy link
Owner

what would happen in case of conflict using same file? new PC will fail to start? can add root process id as suffix for any files created as part of run?

Since Process Compose opens a port, without changing the default one, 2 instances of PC won't run. In other cases where you need to run 2 instances in the same environment, I suggest using the PC_LOG_FILE environment variable.

@F1bonacc1
Copy link
Owner

Fixed in v0.65.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants