Remove strict checks around mount annotations.

Earlier runsc was erroring out when a mount annotation was specified and runsc
did not support the key value pair. Instead, just log a warning and ignore
such mount annotations.

This is helpful when launching new features. The release cycle of runsc and the
user (who configures annotations) may be different. This would relax the
constraints around feature development in these two components.

PiperOrigin-RevId: 524316661
This commit is contained in:
Ayush Ranjan
2023-04-14 09:57:52 -07:00
committed by gVisor bot
parent ca4626f24f
commit 927e99ebaa
2 changed files with 5 additions and 22 deletions
+2 -2
View File
@@ -99,12 +99,12 @@ func newPodMountHints(spec *specs.Spec) (*podMountHints, error) {
mnts[name] = mnt
}
if err := mnt.setField(parts[1], v); err != nil {
return nil, err
log.Warningf("ignoring invalid mount annotation (name = %q, key = %q, value = %q): %v", name, parts[1], v, err)
}
}
}
// Validate all hints after done parsing.
// Validate all the parsed hints.
for name, m := range mnts {
log.Infof("Mount annotation found, name: %s, source: %q, type: %s, share: %v", name, m.mount.Source, m.mount.Type, m.share)
if m.share == invalid {
+3 -20
View File
@@ -120,13 +120,6 @@ func TestPodMountHintsErrors(t *testing.T) {
},
error: "share field",
},
{
name: "invalid field name",
annotations: map[string]string{
MountPrefix + "mount1.invalid": "foo",
},
error: "invalid mount annotation",
},
{
name: "invalid source",
annotations: map[string]string{
@@ -134,7 +127,7 @@ func TestPodMountHintsErrors(t *testing.T) {
MountPrefix + "mount1.type": "tmpfs",
MountPrefix + "mount1.share": "pod",
},
error: "source cannot be empty",
error: "source field for \"mount1\" has not been set",
},
{
name: "invalid type",
@@ -143,7 +136,7 @@ func TestPodMountHintsErrors(t *testing.T) {
MountPrefix + "mount1.type": "invalid-type",
MountPrefix + "mount1.share": "pod",
},
error: "invalid type",
error: "type field for \"mount1\" has not been set",
},
{
name: "invalid share",
@@ -152,17 +145,7 @@ func TestPodMountHintsErrors(t *testing.T) {
MountPrefix + "mount1.type": "tmpfs",
MountPrefix + "mount1.share": "invalid-share",
},
error: "invalid share",
},
{
name: "invalid options",
annotations: map[string]string{
MountPrefix + "mount1.source": "foo",
MountPrefix + "mount1.type": "tmpfs",
MountPrefix + "mount1.share": "pod",
MountPrefix + "mount1.options": "invalid-option",
},
error: "unknown mount option",
error: "share field for \"mount1\" has not been set",
},
{
name: "duplicate source",