From 927e99ebaacbc6059bd5fd6ff615431f1471d32d Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Fri, 14 Apr 2023 09:55:11 -0700 Subject: [PATCH] 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 --- runsc/boot/mount_hints.go | 4 ++-- runsc/boot/mount_hints_test.go | 23 +++-------------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/runsc/boot/mount_hints.go b/runsc/boot/mount_hints.go index 794356d61..373a84a2d 100644 --- a/runsc/boot/mount_hints.go +++ b/runsc/boot/mount_hints.go @@ -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 { diff --git a/runsc/boot/mount_hints_test.go b/runsc/boot/mount_hints_test.go index 8330df462..16dc83d12 100644 --- a/runsc/boot/mount_hints_test.go +++ b/runsc/boot/mount_hints_test.go @@ -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",