-
Notifications
You must be signed in to change notification settings - Fork 618
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
ecs_client/model, functional_tests: updated model, functional tests for devices and init fields #1004
Conversation
This PR depends on the merge of #996 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still WIP
? Also, can you link the following issues in the commit message?
Lastly, please rephrase the commit message as per this comment.
d90e97e
to
a9c107d
Compare
Referenced the issues in the commit message. |
} | ||
] | ||
}, | ||
"command": ["sh", "-c", "if ls /dev/sda && ! fdisk /dev/sda; then exit 42; else exit 1; fi"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not do fdisk
here? Especially because you are mounting /dev/xvda
into the container? Or at least fdisk
with no flags? fdisk -l
seems reasonable. Or any of lsblk
or blockdev
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the fdisk
call is supposed to fail here, since only read
permission is added to the device in container. -l
flag can also be used here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but it'll also fail if the device wasn't mounted. You need a check to ensure that it's mounted as well. Can't you check the permission with something like stat --format=%a /dev/sda
?
Alternatively, you can do both. Make sure that disk exists fdisk -l
and that you can't write to it. fdisk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think commands like stat
and lsblk
take information from sysfs
, hence do not show the right permissions for the mounted devices.
I tried the following:
$ ls -l /dev/xvda brw-rw---- 1 root disk 202, 0 Jul 5 23:37 /dev/xvda
docker run -it --device /dev/xvda:/dev/dummy ubuntu # ls -l /dev/dummy brw-rw---- 1 root disk 202, 0 Oct 6 18:54 /dev/dummy # stat --format=%a /dev/dummy 660 # fdisk /dev/dummy Welcome to fdisk (util-linux 2.27.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): q
and
docker run -it --device /dev/xvda:/dev/dummy:r ubuntu # ls -l /dev/dummy brw-rw---- 1 root disk 202, 0 Oct 6 18:58 /dev/dummy # stat --format=%a /dev/dummy 660 # fdisk /dev/dummy Welcome to fdisk (util-linux 2.27.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. fdisk: cannot open /dev/dummy: Operation not permitted
As you mentioned, we can do ls
to check if the device is mounted and fdisk
for permissions.
"linuxParameters": { | ||
"initProcessEnabled":true | ||
}, | ||
"command": ["sh", "-c", "ps -x | grep \"/dev/init\" && exit 42 || exit 1"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will return false positives I think. Can we do pidof "/dev/init" == 1
check instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pidof "/dev/init" == 1
is a better check. will change this.
a9c107d
to
8cd474c
Compare
Can you add entries to the |
These changes cannot go in until support for device and init is there in the backend services. Will add changelog and reference #996. |
8cd474c
to
d38238e
Compare
@sharanyad this is tagged for milestone 1.15.2. Can you please address the comments if this needs to go in the next release? Or, please change the milestone if it doesn't need to go in the next release. Thanks! |
@aaithal The comments have been addressed. The functional tests pass now too. |
d38238e
to
c268ea0
Compare
Summary
Model changes to Container Definition for enabling devices and init for Linux containers.
Functional tests
Implementation details
Functional tests that verify:
Testing
make release
)go build -out amazon-ecs-agent.exe ./agent
)make test
) passgo test -timeout=25s ./agent/...
) passmake run-integ-tests
) pass.\scripts\run-integ-tests.ps1
) passmake run-functional-tests
) pass.\scripts\run-functional-tests.ps1
) passNew tests cover the changes: yes
Description for the changelog
Licensing
This contribution is under the terms of the Apache 2.0 License: yes