Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

rootless: implement rootless fs and support --rootless option #2429

Merged

Conversation

devimc
Copy link

@devimc devimc commented Jan 31, 2020

No description provided.

@devimc
Copy link
Author

devimc commented Jan 31, 2020

/test

@devimc devimc force-pushed the topic/virtcontainers/rootlessStore branch from 17ac5ce to 7a1b00f Compare January 31, 2020 21:41
@devimc
Copy link
Author

devimc commented Jan 31, 2020

/test

@codecov
Copy link

codecov bot commented Jan 31, 2020

Codecov Report

Merging #2429 into master will increase coverage by 0.02%.
The diff coverage is 48.81%.

@@            Coverage Diff             @@
##           master    #2429      +/-   ##
==========================================
+ Coverage   50.62%   50.65%   +0.02%     
==========================================
  Files         112      114       +2     
  Lines       16274    16315      +41     
==========================================
+ Hits         8239     8264      +25     
- Misses       7020     7029       +9     
- Partials     1015     1022       +7

@devimc devimc force-pushed the topic/virtcontainers/rootlessStore branch from 7a1b00f to 4151daf Compare February 4, 2020 16:42
@devimc
Copy link
Author

devimc commented Feb 4, 2020

/test

@devimc devimc force-pushed the topic/virtcontainers/rootlessStore branch from 4151daf to 1a3c39d Compare February 4, 2020 17:14
@devimc
Copy link
Author

devimc commented Feb 4, 2020

/test

@devimc devimc force-pushed the topic/virtcontainers/rootlessStore branch from 1a3c39d to 8324fb2 Compare February 5, 2020 22:06
@devimc
Copy link
Author

devimc commented Feb 5, 2020

/test

@devimc
Copy link
Author

devimc commented Feb 6, 2020

review please

Copy link
Contributor

@jodh-intel jodh-intel left a comment

Choose a reason for hiding this comment

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

Thanks @devimc - that's a pretty big PR but thanks for doing this and updating the tests too!

lgtm

clh := &cloudHypervisor{}
store, err := persist.GetDriver()
if err != nil {
t.Errorf("persist.GetDriver() unexpected error != %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: The assert syntax save you two lines of code 😄

assert.NoError(err)

Copy link
Author

Choose a reason for hiding this comment

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

Fixed, thanks

@devimc devimc force-pushed the topic/virtcontainers/rootlessStore branch from 8324fb2 to e95bfec Compare February 6, 2020 16:08
@amshinde amshinde requested review from amshinde and bergwolf February 6, 2020 18:59
Copy link
Member

@amshinde amshinde left a comment

Choose a reason for hiding this comment

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

@devimc minor nits/questions from my end. Otherwise lgtm overall.

@@ -208,7 +213,12 @@ func TestAcrnGetSandboxConsole(t *testing.T) {
func TestAcrnCreateSandbox(t *testing.T) {
assert := assert.New(t)
acrnConfig := newAcrnConfig()
a := &Acrn{}
store, err := persist.GetDriver()
Copy link
Member

Choose a reason for hiding this comment

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

Shoudlnt these tests be run with a mockdriver? I dont see if the the variable mockTesting has been set to true anywhere?

Copy link
Author

Choose a reason for hiding this comment

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

cli/main.go Outdated
if err != nil {
return err
}
// If nil, not set a value, let vc auto-detect rootless
Copy link
Member

Choose a reason for hiding this comment

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

This comment is slightly confusing, as we are checking non-nil value below. Perhaps, this could be worded as
If flag is true/false, assign the rootless flag. vc will not perform any auto-detection in that case. In case flag is nil or auto, vc detects if the runtime is running as rootless.


// from runC
// parseBoolOrAuto returns (nil, nil) if s is empty or "auto"
func parseBoolOrAuto(s string) (*bool, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I know this is a small function, but I think its better to include the runc license in the file if not included since we have taken this code varbatim. cc @grahamwhaley wdyt?

Copy link
Author

Choose a reason for hiding this comment

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

fixed, thanks

@devimc devimc force-pushed the topic/virtcontainers/rootlessStore branch 2 times, most recently from 5b3ebd7 to 1e0042f Compare February 10, 2020 21:12
@devimc
Copy link
Author

devimc commented Feb 10, 2020

@amshinde changes applied, thanks

@devimc devimc force-pushed the topic/virtcontainers/rootlessStore branch from 1e0042f to 569bbbb Compare February 11, 2020 17:01
Julio Montes added 9 commits February 12, 2020 19:09
rootless is used in katautils, cli and virtcontainers. It makes more sense
if it's part of virtcontainer, this way virtcontainers won't depend on other
runtime subpackages

Signed-off-by: Julio Montes <[email protected]>
`agent.getVMPath()` is an almost useless method that can be easily replaced
with `filepath.Join()`

Signed-off-by: Julio Montes <[email protected]>
Update persist FS API and interface to support rootless and mock filesystem
implementations. `RunStoragePath` and `RunVMStoragePath` are part of FS
object and may change their path depending on the driver (rootless/mock/fs)

Signed-off-by: Julio Montes <[email protected]>
Rootless fs driver inherits from FS and may overwrite its methods. All files
and directories created by this driver are under a path accessible for the
current user, typically this path is defined by the environment variable
`XDG_RUNTIME_DIR`, if this variable is not defined, the default path
`/run/user/$UID` is used instead, where $UID is the current user ID.

fixes kata-containers#2416

Signed-off-by: Julio Montes <[email protected]>
Mock FS driver can be used in unit testing to allow

Mock fs driver inherits from FS and may overwrite its methods. All files
and directories created by this driver are under a path accessible for all
users, this path is created under the system temporal directory.

Signed-off-by: Julio Montes <[email protected]>
GetDriver returns new PersistDriver according to current needs, a mock fs
driver is returned when mockTesting is enabled, a rootless fs is returned when
rootless is detected, otherwise a fs driver is used.

Signed-off-by: Julio Montes <[email protected]>
Fix factory implementation and unit tests to support the new persist API

Signed-off-by: Julio Montes <[email protected]>
Fix sandbox implementation and unit tests to support the new persist API

Signed-off-by: Julio Montes <[email protected]>
Fix hypervisor implementations and unit tests to support the new persist API

Signed-off-by: Julio Montes <[email protected]>
Julio Montes added 3 commits February 12, 2020 19:09
Fix API, container and kata implementations and unit tests to support
the new persist API

Signed-off-by: Julio Montes <[email protected]>
By default virtcontainer auto-detects if the current process is running
rootless or not, but this behavior can change from commandline with the
--rootless option

fixes kata-containers#2417

Signed-off-by: Julio Montes <[email protected]>
Fix comment on exported var `IsRootless` should be of the form
`IsRootless ...` (golint)

Signed-off-by: Julio Montes <[email protected]>
@devimc devimc force-pushed the topic/virtcontainers/rootlessStore branch from 569bbbb to a45cf62 Compare February 12, 2020 19:09
@devimc
Copy link
Author

devimc commented Feb 12, 2020

/test

@devimc devimc merged commit f8e5254 into kata-containers:master Feb 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants