Skip to contentSkip to conversation

pynfs: report xattrs as unsupported instead of failures if the server doesn't support them

PATCH In review Scott Mayhew 2 participants 2 messages Nov 20

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pynfs: report xattrs as unsupported instead of failures if the server doesn't support them

Extended attributes are an optional feature, so a server not supporting them shouldn't be treated as a hard failure.

---
 nfs4.1/server41tests/st_xattr.py | 72 +++++++++++++++++++++++---------
 1 file changed, 53 insertions(+), 19 deletions(-)
nfs4.1/server41tests/st_xattr.py +53 -19
index f67df95..f83fa74 100644
@@ -28,10 +28,10 @@ def testGetXattrAttribute(t, env):
 
     bitmask = res.resarray[-1].obj_attributes[FATTR4_SUPPORTED_ATTRS]
     if bitmask & (1 << FATTR4_XATTR_SUPPORT) == 0:
-        fail("xattr_support is not included in the set of supported attributes")
+        t.fail_support("xattr_support is not included in the set of supported attributes")
 
     if FATTR4_XATTR_SUPPORT not in res.resarray[-1].obj_attributes:
-        fail("Server doesn't support extended attributes")
+        t.fail_support("Server doesn't support extended attributes")
 
 
 def testGetMissingAttr(t, env):
@@ -48,7 +48,9 @@ def testGetMissingAttr(t, env):
 
     fh = res.resarray[-2].object
     res = sess.compound([op.putfh(fh), op.getxattr("user.attr1".encode("UTF-8"))])
-    check(res, NFS4ERR_NOXATTR)
+    check(res, [NFS4ERR_NOXATTR, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
 def testCreateNewAttr(t, env):
     """Server MUST return NFS4_ON on create.
@@ -66,10 +68,14 @@ def testCreateNewAttr(t, env):
     key = "user.attr1".encode("UTF-8")
     value = "value1".encode("UTF-8")
     res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_CREATE, key, value)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
     res = sess.compound([op.putfh(fh), op.getxattr(key)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
     if value != res.resarray[-1].gxr_value:
         fail("Returned value doesn't")
 
@@ -89,10 +95,14 @@ def testCreateNewIfMissingAttr(t, env):
     key = "user.attr1".encode("UTF-8")
     value = "value1".encode("UTF-8")
     res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_EITHER, key, value)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
     res = sess.compound([op.putfh(fh), op.getxattr(key)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
     if value != res.resarray[-1].gxr_value:
         fail("Returned value doesn't match with expected one.")
 
@@ -112,7 +122,9 @@ def testUpdateOfMissingAttr(t, env):
     key = "user.attr1".encode("UTF-8")
     value = "value1".encode("UTF-8")
     res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_REPLACE, key, value)])
-    check(res, NFS4ERR_NOXATTR)
+    check(res, [NFS4ERR_NOXATTR, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
 def testExclusiveCreateAttr(t, env):
     """Server MUST return NFS4ERR_EXIST on create of existing attribute.
@@ -130,10 +142,14 @@ def testExclusiveCreateAttr(t, env):
     key = "user.attr1".encode("UTF-8")
     value = "value1".encode("UTF-8")
     res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_CREATE, key, value)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
     res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_CREATE, key, value)])
-    check(res, NFS4ERR_EXIST)
+    check(res, [NFS4ERR_EXIST, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
 def testUpdateExistingAttr(t, env):
     """Server MUST return NFS4_ON on update of existing attribute.
@@ -152,13 +168,19 @@ def testUpdateExistingAttr(t, env):
     value1 = "value1".encode("UTF-8")
     value2 = "value2".encode("UTF-8")
     res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_CREATE, key, value1)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
     res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_REPLACE, key, value2)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
     res = sess.compound([op.putfh(fh), op.getxattr(key)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
     if value2 != res.resarray[-1].gxr_value:
         fail("Returned value doesn't match with expected one.")
 
@@ -178,7 +200,9 @@ def testRemoveNonExistingAttr(t, env):
     key = "user.attr1".encode("UTF-8")
 
     res = sess.compound([op.putfh(fh), op.removexattr(key)])
-    check(res, NFS4ERR_NOXATTR)
+    check(res, [NFS4ERR_NOXATTR, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
 def testRemoveExistingAttr(t, env):
     """Server MUST return NFS4_ON on remove of existing attribute.
@@ -196,10 +220,14 @@ def testRemoveExistingAttr(t, env):
     key = "user.attr1".encode("UTF-8")
     value = "value1".encode("UTF-8")
     res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_CREATE, key, value)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
     res = sess.compound([op.putfh(fh), op.removexattr(key)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
 def testListNoAttrs(t, env):
     """Server MUST return NFS4_ON an empty list if no attributes defined.
@@ -216,7 +244,9 @@ def testListNoAttrs(t, env):
     fh = res.resarray[-2].object
 
     res = sess.compound([op.putfh(fh), op.listxattrs(0, 8192)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
     if not res.resarray[-1].lxr_eof:
         fail("EOF flag is not set")
@@ -243,10 +273,14 @@ def testListAttrs(t, env):
     for key in keys:
         value = "value".encode("UTF-8")
         res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_CREATE, key.encode("UTF-8"), value)])
-        check(res)
+        check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+        if (res.status == NFS4ERR_NOTSUPP):
+            t.fail_support("Server doesn't support extended attributes")
 
     res = sess.compound([op.putfh(fh), op.listxattrs(0, 8192)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
     xattrs = [key.decode("UTF-8") for key in res.resarray[-1].lxr_names]
     if len(xattrs) != len(keys):
Signature · 1 line
2.56.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 167 lines · Scott Mayhew

Extended attributes are an optional feature, so a server not supporting them shouldn't be treated as a hard failure.

---
 nfs4.1/server41tests/st_xattr.py | 72 +++++++++++++++++++++++---------
 1 file changed, 53 insertions(+), 19 deletions(-)
nfs4.1/server41tests/st_xattr.py +49 -18
index f67df95..f83fa74 100644
@@ -28,10 +28,10 @@ def testGetXattrAttribute(t, env):
 
     bitmask = res.resarray[-1].obj_attributes[FATTR4_SUPPORTED_ATTRS]
     if bitmask & (1 << FATTR4_XATTR_SUPPORT) == 0:
-        fail("xattr_support is not included in the set of supported attributes")
+        t.fail_support("xattr_support is not included in the set of supported attributes")
 
     if FATTR4_XATTR_SUPPORT not in res.resarray[-1].obj_attributes:
-        fail("Server doesn't support extended attributes")
+        t.fail_support("Server doesn't support extended attributes")
 
 
 def testGetMissingAttr(t, env):
@@ -48,7 +48,9 @@ def testGetMissingAttr(t, env):
 
     fh = res.resarray[-2].object
     res = sess.compound([op.putfh(fh), op.getxattr("user.attr1".encode("UTF-8"))])
-    check(res, NFS4ERR_NOXATTR)
+    check(res, [NFS4ERR_NOXATTR, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
 def testCreateNewAttr(t, env):
     """Server MUST return NFS4_ON on create.
@@ -66,10 +68,14 @@ def testCreateNewAttr(t, env):
     key = "user.attr1".encode("UTF-8")
     value = "value1".encode("UTF-8")
     res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_CREATE, key, value)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
     res = sess.compound([op.putfh(fh), op.getxattr(key)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
     if value != res.resarray[-1].gxr_value:
         fail("Returned value doesn't")
 
@@ -89,10 +95,14 @@ def testCreateNewIfMissingAttr(t, env):
     key = "user.attr1".encode("UTF-8")
     value = "value1".encode("UTF-8")
     res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_EITHER, key, value)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
     res = sess.compound([op.putfh(fh), op.getxattr(key)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
     if value != res.resarray[-1].gxr_value:
         fail("Returned value doesn't match with expected one.")
 
@@ -112,7 +122,9 @@ def testUpdateOfMissingAttr(t, env):
     key = "user.attr1".encode("UTF-8")
     value = "value1".encode("UTF-8")
     res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_REPLACE, key, value)])
-    check(res, NFS4ERR_NOXATTR)
+    check(res, [NFS4ERR_NOXATTR, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
 def testExclusiveCreateAttr(t, env):
     """Server MUST return NFS4ERR_EXIST on create of existing attribute.
@@ -130,10 +142,14 @@ def testExclusiveCreateAttr(t, env):
     key = "user.attr1".encode("UTF-8")
     value = "value1".encode("UTF-8")
     res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_CREATE, key, value)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
     res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_CREATE, key, value)])
-    check(res, NFS4ERR_EXIST)
+    check(res, [NFS4ERR_EXIST, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
 def testUpdateExistingAttr(t, env):
     """Server MUST return NFS4_ON on update of existing attribute.
@@ -152,13 +168,19 @@ def testUpdateExistingAttr(t, env):
     value1 = "value1".encode("UTF-8")
     value2 = "value2".encode("UTF-8")
     res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_CREATE, key, value1)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
     res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_REPLACE, key, value2)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
     res = sess.compound([op.putfh(fh), op.getxattr(key)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
     if value2 != res.resarray[-1].gxr_value:
         fail("Returned value doesn't match with expected one.")
 
@@ -178,7 +200,9 @@ def testRemoveNonExistingAttr(t, env):
     key = "user.attr1".encode("UTF-8")
 
     res = sess.compound([op.putfh(fh), op.removexattr(key)])
-    check(res, NFS4ERR_NOXATTR)
+    check(res, [NFS4ERR_NOXATTR, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
 def testRemoveExistingAttr(t, env):
     """Server MUST return NFS4_ON on remove of existing attribute.
@@ -196,10 +220,14 @@ def testRemoveExistingAttr(t, env):
     key = "user.attr1".encode("UTF-8")
     value = "value1".encode("UTF-8")
     res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_CREATE, key, value)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
     res = sess.compound([op.putfh(fh), op.removexattr(key)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
 def testListNoAttrs(t, env):
     """Server MUST return NFS4_ON an empty list if no attributes defined.
@@ -216,7 +244,9 @@ def testListNoAttrs(t, env):
     fh = res.resarray[-2].object
 
     res = sess.compound([op.putfh(fh), op.listxattrs(0, 8192)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
     if not res.resarray[-1].lxr_eof:
         fail("EOF flag is not set")
@@ -243,10 +273,14 @@ def testListAttrs(t, env):
     for key in keys:
         value = "value".encode("UTF-8")
         res = sess.compound([op.putfh(fh), op.setxattr(SETXATTR4_CREATE, key.encode("UTF-8"), value)])
-        check(res)
+        check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+        if (res.status == NFS4ERR_NOTSUPP):

nfs4.1/server41tests/st_xattr.py def testListAttrs(t, env): · line 286

Quoted 10 lines
nfs4.1/server41tests/st_xattr.py +4 -1
+            t.fail_support("Server doesn't support extended attributes")
 
     res = sess.compound([op.putfh(fh), op.listxattrs(0, 8192)])
-    check(res)
+    check(res, [NFS4_OK, NFS4ERR_NOTSUPP])
+    if (res.status == NFS4ERR_NOTSUPP):
+        t.fail_support("Server doesn't support extended attributes")
 
     xattrs = [key.decode("UTF-8") for key in res.resarray[-1].lxr_names]
     if len(xattrs) != len(keys):