This repository has been archived by the owner on May 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 374
virtcontainers: Add support for ephemeral volumes #307
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ import ( | |
kataclient "github.com/kata-containers/agent/protocols/client" | ||
"github.com/kata-containers/agent/protocols/grpc" | ||
"github.com/kata-containers/runtime/virtcontainers/device/api" | ||
"github.com/kata-containers/runtime/virtcontainers/device/config" | ||
"github.com/kata-containers/runtime/virtcontainers/device/drivers" | ||
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations" | ||
ns "github.com/kata-containers/runtime/virtcontainers/pkg/nsenter" | ||
|
@@ -51,6 +52,7 @@ var ( | |
sharedDir9pOptions = []string{"trans=virtio,version=9p2000.L", "nodev"} | ||
shmDir = "shm" | ||
kataEphemeralDevType = "ephemeral" | ||
ephemeralPath = filepath.Join(kataGuestSandboxDir, kataEphemeralDevType) | ||
) | ||
|
||
// KataAgentConfig is a structure storing information needed | ||
|
@@ -775,12 +777,38 @@ func (k *kataAgent) createContainer(sandbox *Sandbox, c *Container) (p *Process, | |
return nil, err | ||
} | ||
|
||
var devInfos []config.DeviceInfo | ||
for _, devInfo := range c.config.DeviceInfos { | ||
if devInfo.DevType == "e" { | ||
filename := filepath.Join(ephemeralPath, filepath.Base(devInfo.ContainerPath)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the Base guaranteed to be unique here? If not, I would append this with a randomly generated string to make sure there are no conflicts. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the Base is guaranteed to be unique. In k8s ephemeral volume is defined by,
In the pod yaml. The Base comes from |
||
epheStorage := &grpc.Storage{ | ||
Driver: kataEphemeralDevType, | ||
Source: "tmpfs", | ||
Fstype: "tmpfs", | ||
MountPoint: filename, | ||
} | ||
ctrStorages = append(ctrStorages, epheStorage) | ||
|
||
} else { | ||
devInfos = append(devInfos, devInfo) | ||
} | ||
} | ||
|
||
// Handle container mounts | ||
newMounts, err := c.mountSharedDirMounts(kataHostSharedDir, kataGuestSharedDir) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// Modify the mount source for ephemeral volume | ||
for idx, mnt := range ociSpec.Mounts { | ||
if utils.IsEphemeralDevice(c.config.DeviceInfos, mnt.Source) { | ||
ociSpec.Mounts[idx].Source = filepath.Join(ephemeralPath, filepath.Base(mnt.Source)) | ||
} | ||
} | ||
|
||
c.config.DeviceInfos = devInfos | ||
|
||
// We replace all OCI mount sources that match our container mount | ||
// with the right source path (The guest one). | ||
if err = k.replaceOCIMountSource(ociSpec, newMounts); err != nil { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 still don't like this
IsEphemeralStroage
.Can Kubernetes guarantee this name will be maintained and kept backward compatible? In other words, is this function reliable?
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 wish I had a better way here. :(
In future, if k8s decides to change that path, kata might just end up provisioning the storage over 9pfs just like it does right now.
I am trying to see if we can come up with some sort of standard for ephemeral storage that everyone can comply with (k8s, runtimes etc). Until then, I don't see any other way.
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 do feel that this will break at some point in the future, so I'd rather we get absolute clarification on the best approach from the k8s folk (and ideally some sort of assurances).
Does anyone have a contact from that project who could comment here?
/cc @sameo.
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.
/cc @saad-ali
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.
@jodh-intel @WeiZhang555 @sboeuf I have created a topic in k8s community on the stability of ephemeral volumes they provision, https://groups.google.com/forum/#!topic/kubernetes-dev/4JtfGSSUO_A
Feel free to join the discussion.
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.
Nice, thx @harche.
In the meantime, just make sure our code has enough comment to explain this is not a perfect/stable solution.
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.
@sboeuf sure.
Meanwhile, Looking at Michelle Au's (Google) comment and Tim Hockin's (Google) comment, the general tone there resonates some of the concerns raised here.
However, Michelle mentioned in her reply on slack,
to answer your question, emprydir path on the kubelet should be stable
Quoting's Tim's reply on mailing list,
I would probably NAK any change to the volume implementations that changed the path, but I don't think it is guaranteed.
Although for the longer term, the we need to come up with a solution that doesn't depend on these assurances (or lack of them). There are a couple of approaches,
As Michelle suggested,
we need to find a way to generically invoke volume plugins in the runtime
Or In my opinion, we should decouple storage drivers from kata. Storage drivers should be these pluggable entities which anyone can write for the storage they are dealing with. Pretty much how docker decoupled
runtime
from their code.@egernst @WeiZhang555 @sboeuf @bergwolf @jodh-intel
Let me know your thoughts on how should we proceed in short-term as well as in long-term.
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.
Since this is still a reasonable improvement especially on security aspect, I'm fine to merge it as a short term enhancement.
But it's better to find a solid method doing this later.
LGTM for now to merge this.