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

Feature/#7 implement launch #43

Merged
merged 15 commits into from
Mar 21, 2022
Merged

Feature/#7 implement launch #43

merged 15 commits into from
Mar 21, 2022

Conversation

higuruchi
Copy link
Owner

内容

launchコマンドを実装

デモ

$ sudo ./target/debug/injesh  launch <Contaioner ID>  --rootfs-image ubuntu/focal <DContainer_Name> /bin/bash
cmd"/bin/bash"
root@aef30e90a84b:/# ls
bin  boot  dev  etc  home  lib  lib32  lib64  libx32  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@aef30e90a84b:/# 

実装状況

  • --rootfs=/path/to/rootfs
  • --rootfs-image=
  • --rootfs-docker=
  • --rootfs-lxd=

不具合

  • container.rsのreloadメソッドが deleteコマンドの実装 #36 に実装されているため、これをmergeしてから修正する
  • user namespaceをsetnsすると失敗する
  • sudo ./target/debug/injesh launch ae --rootfs-image ubuntu/focal hoge lsをすると失敗する
  • sudo ./target/debug/injesh launch ae --rootfs-image ubuntu/focal hoge bashは成功する

@higuruchi higuruchi requested a review from yassi-github March 18, 2022 06:33
@yassi-github
Copy link
Collaborator

コードなんも読んでないが、不具合についてとりあえず:

  • user namespaceをsetnsすると失敗する
    • nsenterコマンドの--allオプションでは、user namespace のsetnsは行っていないのでする必要はないかと。
  • lsが失敗してbashが成功する
    • 謎……コード読んでみます

@higuruchi
Copy link
Owner Author

higuruchi commented Mar 18, 2022

container.rs周りのコンフリクトを修正

Copy link
Collaborator

@yassi-github yassi-github left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

レビュー前/後で実行してみたがENOENTになる

root@tashkent:/home/ys/injesh# ./target/debug/injesh launch b97c1a8271c9 --rootfs-image alpine/3.15 hoge bash
cmd: "bash"
execute launch command error: ENOENT
Child exited Exited(Pid(90065), 0)
root@tashkent:/home/ys/injesh# rm -rf ~/.injesh/containers/hoge/
root@tashkent:/home/ys/injesh# ./target/debug/injesh launch b97c1a8271c9 --rootfs-image alpine/3.15 hoge ls
cmd: "ls"
execute launch command error: ENOENT
Child exited Exited(Pid(90540), 0)

src/parser.rs Outdated Show resolved Hide resolved
src/parser.rs Outdated Show resolved Hide resolved
src/image_downloader_lxd.rs Show resolved Hide resolved
src/cmd/launch.rs Outdated Show resolved Hide resolved
src/cmd/launch.rs Outdated Show resolved Hide resolved
Comment on lines 148 to 150

// /var/lib/docker/overlay2/<CONTAINER_ID>/upperを~/.injesh/containers/<hoge>/upperに対してコピーする
for entry in fs::read_dir(launch.target_container().upperdir())? {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この実装では、1階層のみのファイルしかコピーできないので、再帰的にディレクトリを含めてコピーするようにしたい

src/cmd/launch.rs Outdated Show resolved Hide resolved
src/cmd/launch.rs Outdated Show resolved Hide resolved
src/cmd/launch.rs Outdated Show resolved Hide resolved
src/cmd/launch.rs Outdated Show resolved Hide resolved
@yassi-github
Copy link
Collaborator

yassi-github commented Mar 19, 2022

エラーになるのはforkしてる部分なので、
launchはマウントし直してrestartするまでにして、実行部分はexecコマンドにまかせてくれればよいかと。(内部でexecコマンド叩くか、実装内容をコピーするか、共通化するか。)

そしてexecを実行するためには、

を解決する必要がある。

@higuruchi
Copy link
Owner Author

僕の方ではforkは問題なく実行できる

レビュー前/後で実行してみたがENOENTになる

root@tashkent:/home/ys/injesh# ./target/debug/injesh launch b97c1a8271c9 --rootfs-image alpine/3.15 hoge bash
cmd: "bash"
execute launch command error: ENOENT
Child exited Exited(Pid(90065), 0)
root@tashkent:/home/ys/injesh# rm -rf ~/.injesh/containers/hoge/
root@tashkent:/home/ys/injesh# ./target/debug/injesh launch b97c1a8271c9 --rootfs-image alpine/3.15 hoge ls
cmd: "ls"
execute launch command error: ENOENT
Child exited Exited(Pid(90540), 0)

cmdの部分をbashでなく/bin/bashにするとできる

@higuruchi
Copy link
Owner Author

エラーになるのはforkしてる部分なので、 launchはマウントし直してrestartするまでにして、実行部分はexecコマンドにまかせてくれればよいかと。(内部でexecコマンド叩くか、実装内容をコピーするか、共通化するか。)

そしてexecを実行するためには、

を解決する必要がある。

execする部分はコード量があるわけではないので、execが完成してから考えればいいかな

@higuruchi higuruchi force-pushed the feature/#7_implement_launch branch from 83c8334 to cb455b5 Compare March 19, 2022 16:10
@higuruchi
Copy link
Owner Author

higuruchi commented Mar 19, 2022

execシステムコールを発行する際の引数が間違っていた

$ sudo ./target/debug/injesh  launch 35  --rootfs-image ubuntu/focal <DCONTAINER_NAME> /bin/echo hoge

hoge
Child exited Exited(Pid(3400999), 0)

複数引数にも対応

@higuruchi higuruchi requested a review from yassi-github March 19, 2022 16:11
src/parser.rs Show resolved Hide resolved
src/command.rs Outdated Show resolved Hide resolved
src/command.rs Outdated Show resolved Hide resolved
src/cmd/launch.rs Outdated Show resolved Hide resolved
src/parser.rs Outdated Show resolved Hide resolved
@higuruchi higuruchi force-pushed the feature/#7_implement_launch branch from 2d3d758 to 094a917 Compare March 20, 2022 13:13
@higuruchi higuruchi requested a review from yassi-github March 20, 2022 13:13
@higuruchi higuruchi force-pushed the feature/#7_implement_launch branch from a420c72 to 760b584 Compare March 20, 2022 13:17
src/command.rs Outdated Show resolved Hide resolved
src/command.rs Show resolved Hide resolved
src/cmd/launch.rs Outdated Show resolved Hide resolved
src/cmd/launch.rs Outdated Show resolved Hide resolved
src/cmd/launch.rs Outdated Show resolved Hide resolved
@higuruchi higuruchi requested a review from yassi-github March 21, 2022 05:43
@higuruchi higuruchi merged commit 4d609c3 into main Mar 21, 2022
@higuruchi higuruchi deleted the feature/#7_implement_launch branch March 21, 2022 07:35
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

Successfully merging this pull request may close these issues.

2 participants