Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion internal/guest/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ func networkingMountPaths() []string {
func GenerateWorkloadContainerNetworkMounts(sandboxID string, spec *oci.Spec) []oci.Mount {
var nMounts []oci.Mount

// In multipod mode, the sandbox writes networking files (resolv.conf, hostname, hosts)
// under the virtual pod root directory. Use VirtualPodAwareSandboxRootDir to ensure
// workload containers mount from the correct path.
virtualSandboxID := spec.Annotations[annotations.VirtualPodID]
rootDir := VirtualPodAwareSandboxRootDir(sandboxID, virtualSandboxID)

logrus.WithFields(logrus.Fields{
"sandboxID": sandboxID,
"virtualSandboxID": virtualSandboxID,
"rootDir": rootDir,
}).Info("GenerateWorkloadContainerNetworkMounts: resolved mount source root directory")

for _, mountPath := range networkingMountPaths() {
// Don't override if the mount is present in the spec
if MountPresent(mountPath, spec.Mounts) {
Expand All @@ -56,7 +68,7 @@ func GenerateWorkloadContainerNetworkMounts(sandboxID string, spec *oci.Spec) []
mt := oci.Mount{
Destination: mountPath,
Type: "bind",
Source: filepath.Join(SandboxRootDir(sandboxID), trimmedMountPath),
Source: filepath.Join(rootDir, trimmedMountPath),
Options: options,
}
nMounts = append(nMounts, mt)
Expand Down
3 changes: 2 additions & 1 deletion pkg/securitypolicy/securitypolicy_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const osType = "linux"

func ExtendPolicyWithNetworkingMounts(sandboxID string, enforcer SecurityPolicyEnforcer, spec *oci.Spec) error {
roSpec := &oci.Spec{
Root: spec.Root,
Root: spec.Root,
Annotations: spec.Annotations,
}
networkingMounts := specInternal.GenerateWorkloadContainerNetworkMounts(sandboxID, roSpec)
if err := enforcer.ExtendDefaultMounts(networkingMounts); err != nil {
Expand Down