Commit Graph

81 Commits

Author SHA1 Message Date
Yang Bo
c4f15f1280
Merge pull request #91 from ericho/master
agent: Add unit tests for sandbox.rs
2020-01-09 12:51:41 +08:00
Jose Carlos Venegas Munoz
3b6a837664
Merge pull request #115 from jcvenegas/fix-114
version: Add VERSION file
2020-01-07 14:42:55 -06:00
Jose Carlos Venegas Munoz
8d60612052 version: Add VERSION file
Needed by some CI scripts, like release or to verify stable
branches state.

Fixes: #114

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
2020-01-07 19:25:33 +00:00
James O. D. Hunt
e0df9739bf
Merge pull request #110 from GabyCT/topic/addmake
ci: Add minimal makefile to use central go test script
2020-01-06 09:19:59 +00:00
Hui Zhu
bf50d1811c
Merge pull request #112 from yyyeerbo/wip
netlink: pull out netlink as library crate.
2020-01-06 13:44:06 +08:00
Yang Bo
a5192a16e8 netlink: pull out netlink as library crate.
Fixes: #111

Signed-off-by: Yang Bo <yb203166@antfin.com>
2020-01-04 06:45:52 -08:00
Gabriela Cervantes
3881c06578 ci: Add minimal makefile to use central go test script
This adds a basic Makefile where we can use a central go test script
in order to run the tests for the CI.

Fixes #109

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
2020-01-03 10:04:09 -06:00
Jose Carlos Venegas Munoz
cfda17d529
Merge pull request #104 from egernst/fixup-workflow-103
Fixup workflow 103
2019-12-11 13:12:03 -06:00
Eric Ernst
1c576659de workflows: make sure we build the experimental kernel, CLH
gather job needs to take all build jobs into account, including
building of the experimental kernel and CLH. Added.

Fixes: #103

Signed-off-by: Eric Ernst <eric.ernst@intel.com>
2019-12-11 10:35:37 -08:00
Eric Ernst
cbd5fa008a workflows: fix step output usage
You cannot pass environment variables easily between steps/jobs.

Updated flow to define and set step outputs, and use the outputs of the
corresponding steps later in the flow, rather than env variables (which
never worked correctly - whoops).

Signed-off-by: Eric Ernst <eric.ernst@intel.com>
2019-12-11 08:02:36 -08:00
Erich Cordoba
92301a6382 agent: Add unit tests for sandbox.rs
These are the unit tests for the sandbox struct. This is the summary
of the most important changes:

  - To test containers it was needed to create a `LinuxContainer` type
    and this requires root privileges. So, some tests now requires root
    user to be run.
  - There was a bug in the `unset_sandbox_storage` method. The return
    type was wrapped in a `Result` to avoid this problem.

Fixes: #50

Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
2019-12-06 13:11:07 -06:00
Fupan Li
e025ba7d08
Merge pull request #99 from jiangliu/v2
Fix bug #98 and improve code readability
2019-12-05 10:01:29 +08:00
Jose Carlos Venegas Munoz
9b2fc09982
Merge pull request #58 from egernst/master-workflow
Master workflow
2019-12-02 11:01:25 -06:00
Liu Jiang
154c68eb93 agent: group Linux ABI constants into dedicated file
Group Linux ABI related constants into dedicated file for maintenance.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-12-02 22:19:33 +08:00
Liu Jiang
000bb8592d agent: refine device.rs for better maintenance
1) pass reference instead of value when possible.
2) simplify code.
3) rename get_device_pci_address() as get_pci_device_address() to keep
   consistency get_pci_device_name().
4) refine get_device_name() for maintenance.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-12-02 22:19:29 +08:00
Liu Jiang
94311e4997 agent: fix wrong return value of set_sandbox_storage()
Function set_sandbox_storage() is designed to return true when the
reference count drops from 1 to 0. But current implementation always
return true no matter the reference count is, which may cause removing
an in use mountpoint.

Fixes: #88

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-12-02 22:19:28 +08:00
Liu Jiang
b1748323f0 agent: refine namespace.rs/sandbox.rs for better maintenance
Refine namespace.rs for better maintenance:
1) avoid unnecessary clone
2) make NamespaceType::get() return &str instead of String
3) minor syntax changes
4) remove unused enable_grpc_trace

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-12-02 22:19:27 +08:00
Liu Jiang
a4adacaa10 agent: refine uevent.rs for better maintenance
Refine uevent.rs for better maintenance:
1) use dedicated function to handle uevents.
2) use dedicated function to handle blk add events.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-12-02 10:05:44 +08:00
Liu Jiang
8868eaeb4c agent: clean up clippy warnings about '`static'
warning: Constants have by default a `'static` lifetime
  --> src/grpc.rs:59:24
   |
59 | const CONTAINER_BASE: &'static str = "/run/kata-containers";
   |                       -^^^^^^^---- help: consider removing `'static`: `&str`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-11-30 18:54:23 +08:00
Liu Jiang
eb6258b751 agent: improve logger implemetation
Improve loger implementation by:
1) avoid unnecessary clone() operations.
2) change Arc<Mutex<slog::Level>> to Mutex<slog::Level>. We should use
atomic<usize> instead of Mutex<slog::Level> for better performance here.
But with slog_async::Async drainer in the pipeline, RuntimeLevelFilter
drainer will only get from a single-thread context, so keep it as is.
3) minor syntax cleanups.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-11-30 18:33:07 +08:00
James O. D. Hunt
b6c8b9d9f4
Merge pull request #97 from lifupan/fox_parse_cmdline
config: fix the issue of parse cmdline options
2019-11-29 08:16:47 +00:00
lifupan
4c051ed717 config: fix the issue of parse cmdline options
It's should use string.eq() to match option's
key words exactly instead of using string.starts_with()
for single key options and for "key=value" options it's
bettet to match "key=" instead of "key" with string.starts_with()
which would match wrongly such as passed options "agent.log_vsock"
which would match "agent.log" with string.starts_with()
and trigger parsing issues.

Fixes: #96

Signed-off-by: lifupan <lifupan@gmail.com>
2019-11-29 09:21:20 +08:00
Archana Shinde
c5a3fa76be actions: Add job for building nemu
Add job for nemu to support generating tarballs for 1.9 stable
branch.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2019-11-26 13:16:22 -08:00
Archana Shinde
e005c37274 actions: Add job for building cloud-hypervisor
This will build and store the tarball for cloud-hypervisor.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2019-11-26 13:16:22 -08:00
Archana Shinde
29c2ff8476 release: Move bash from the actions to separate bash file
Try to move all the common bash logic from the actions toml file
to separate scripts and call these scripts instead.
Note the repo itself is now checked out to get access to
these scripts.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
Signed-off-by: Eric Ernst <eric.ernst@intel.com>
2019-11-26 13:16:22 -08:00
Archana Shinde
383e70344f actions: Add job to upload tarball to release page
Once kata-deploy completes successfully, this job will upload
kata static tarball to the release page using GIT_UPLOAD_TOKEN
secret.

Signed-off-by: Jose Carlos Venegas Munoz<jose.carlos.venegas.munoz@intel.com>
Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2019-11-26 11:43:28 -08:00
Eric Ernst
fd5549aa5f workflows: add release workflow
Many changes introduced by Archana Shinde.

This workflow will:
 1. get a list of artifacts from the packaging repo
 2. In parallel, build each of the applicable artifacts
 3. Consolidate the build artifacts from <2>
 4. Test the artifacts in a docker image on AKS
 5. Push the verified docker image to dockerhub

Signed-off-by: Eric Ernst <eric.ernst@intel.com>
Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
2019-11-25 14:00:15 -08:00
Yang Bo
b9158efe3a
Merge pull request #93 from lifupan/fix_copy_file
Fix copy file
2019-11-25 11:40:32 +08:00
lifupan
aeeb6fce73 grpc: fix the issue of wrong containers base dir
The base dir should be "/run/kata-containers" instead
of "/run/agent".

Fixes: #92

Signed-off-by: lifupan <lifupan@gmail.com>
2019-11-25 10:35:17 +08:00
lifupan
5f29f3e293 grpc: fix the issue of return ENOENT for chmod on a file/dir
When call "C" func directly, it's needed to change the string to
CString. To avoid using the unsafe calling, replace it with the
rust safe function to set mode for a file/dir.

Signed-off-by: lifupan <lifupan@gmail.com>
2019-11-25 10:21:07 +08:00
Fupan Li
f2e22eec4f
Merge pull request #89 from jiangliu/oci_v1
Minor improvement to agent/oci crate
2019-11-23 13:04:08 +08:00
Liu Jiang
a47a94218f agent: rename SerializeError as Error
Rename SerializeError as Error and export it as the Error codes for
the OCI crate.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-11-22 18:08:56 +08:00
Liu Jiang
c34bdd06db agent: simplify implementation of oci/serialize
Simplify implementation of oci/serialize:
1) explicitly export pub members.
2) avoid unnecessary & and mut operators.
3) define Result to avoid duplicated code.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-11-22 18:08:56 +08:00
Liu Jiang
b0edfc75ff agent: clean up clippy warnings about '`static'
warning: Constants have by default a `'static` lifetime
   --> src/lib.rs:254:26
    |
254 | pub const PIDNAMESPACE: &'static str = "pid";
    |                         -^^^^^^^---- help: consider removing `'static`: `&str`
    |
    = note: #[warn(clippy::const_static_lifetime)] on by default
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#const_static_lifetime

Fixes: #90

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2019-11-22 16:48:47 +08:00
Yang Bo
459e732ead
Merge pull request #88 from lifupan/fix_deadlock
agent: fix the issue dead lock on AGENT_CONFIG
2019-11-19 18:58:03 +08:00
lifupan
6b611030db agent: fix the issue dead lock on AGENT_CONFIG
Once parsed cmdline and set the config on AGENT_CONFIG,
release the write lock as soon as possible. In case other
thread would get read lock on it.

Fixes:#87

Signed-off-by: lifupan <lifupan@gmail.com>
2019-11-19 18:32:11 +08:00
Yang Bo
60d713e84d
Merge pull request #82 from ericho/namespace-uts
agent: Add unit tests for `namespace.rs`
2019-11-14 07:39:56 +08:00
Eric Ernst
7be308befe
Merge pull request #81 from jodh-intel/add-version-option
Add version option
2019-11-13 08:13:03 -08:00
Erich Cordoba
8aa2c78dd2 agent: Add unit tests for namespace.rs
This patch adds a unit test for `namespace.rs`. The baseline for this
test comes from the Go agent tests in which the namespace is mounted in
a temporary folder.

In order to enable testing in the temporary folder the code was refactored
allow configuration for the specified namespace, thus the changes done
are described below:

- The `setup_persistent_ns` method was moved inside the `Namespace` type.
- A builder pattern was implemented for the `Namespace` type. This allows
  the caller to set the type of the desired namespace as well as the root
  folder which will help the testing.
- A new `NamespaceType` enum was introduced to represent the namespace type.
- The user of the `Namespace` type (sandbox.rs) was updated accordingly.

Fixes: #50

Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
2019-11-13 10:04:41 -06:00
Xu Wang
9112257c23
Merge pull request #86 from lifupan/fix_initrd_panic
agent: init agent as init before parsing cmd line
2019-11-13 01:03:48 +08:00
lifupan
d011b39e96 agent: init agent as init before parsing cmd line
When kata-agent run as init process in initrd, do the
init in which will do some base mount such as mount
/proc; thus the following config.parse_cmdline can access
/proc/cmdline to parse the parameters such as agent.log etc.

Fixes: #85

Signed-off-by: lifupan <lifupan@gmail.com>
2019-11-13 01:01:29 +08:00
James O. D. Hunt
3fe04a2ddc main: Add --version CLI option
Support `--version` which dumps the announce message and exits.

Fixes: #80.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
2019-11-11 13:50:45 +00:00
Fupan Li
cb1849cd2c
Merge pull request #84 from ericho/ci-and-rustfmt
agent: Fix CI and rustfmt issues
2019-11-11 11:01:51 +08:00
Fupan Li
60609cacd0
Merge pull request #74 from yyyeerbo/wip
netlink: Fix invalid route crashes agent
2019-11-11 10:59:59 +08:00
Erich Cordoba
8834e3a759 agent: Fix CI and rustfmt issues
The CI was failing due to two problems.

1. The `ci/static-checks.sh` was run from an incorrect place.
2. `rustfmt` was failing as some code wasn't correctly formatted.

This patch address all the changed requested by rustfmt and the
`static-checks.sh` script was updated

Fixes: #83

Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
2019-11-08 15:58:59 -06:00
Yang Bo
9dce527793
Merge pull request #77 from awprice/issue-62
config: add hotplug timeout option
2019-11-08 15:05:55 +08:00
Yang Bo
089f3b4651
Merge pull request #72 from ericho/master
agent: Move test macros to a separate module to be commonly used.
2019-11-08 15:02:56 +08:00
Alex Price
e06a230c30 config: add hotplug timeout option
This adds an option to the agent to control the hotplug timeout of block devices.
Retains the previous behaviour of defaulting to 3 seconds if not specified.
Can be increased when block device hot plugging is taking longer than expected.

fixes #62

Signed-off-by: Alex Price <aprice@atlassian.com>
2019-11-06 21:12:27 +11:00
Yang Bo
777cee5436
Merge pull request #71 from jodh-intel/allow-gnu-target-build
build: Allow building with gnu target
2019-11-06 10:27:25 +08:00
Erich Cordoba
b14f5a1f89 agent: Move test macros to a separate module to be commonly used.
The `skip_*` macros will be useful across the different tests so having
them in a separate module can help with code duplication. This change
creates a new module and exports the macros at crate level.

Signed-off-by: Erich Cordoba <erich.cordoba.malibran@intel.com>
2019-11-05 10:01:43 -06:00