diff mbox series

[2/2] environment.py: enhance open_create_file to work with courteous server

Message ID 1655314495-17735-2-git-send-email-dai.ngo@oracle.com (mailing list archive)
State New, archived
Headers show
Series [1/2] nfs4lib.py: enhance open_file to work with courteous server | expand

Commit Message

Dai Ngo June 15, 2022, 5:34 p.m. UTC
Enhance open_create_file to handle NFS4ERR_DELAY returned by the server
in case of share/access/delegation conflict.

Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
---
 nfs4.1/server41tests/environment.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/nfs4.1/server41tests/environment.py b/nfs4.1/server41tests/environment.py
index 0b7c976d8582..fb834b28841b 100644
--- a/nfs4.1/server41tests/environment.py
+++ b/nfs4.1/server41tests/environment.py
@@ -483,11 +483,16 @@  def open_create_file(sess, owner, path=None, attrs={FATTR4_MODE: 0o644},
                      deleg_type=None,
                      open_create=OPEN4_NOCREATE,
                      seqid=0, clientid=0):
-    open_op = open_create_file_op(sess, owner, path, attrs, access, deny, mode,
-                            verifier, claim_type, want_deleg, deleg_type,
-                            open_create, seqid, clientid)
-
-    return sess.compound(open_op)
+    while 1:
+        open_op = open_create_file_op(sess, owner, path, attrs, access, deny, mode,
+                       verifier, claim_type, want_deleg, deleg_type,
+                       open_create, seqid, clientid)
+        res = sess.compound(open_op)
+        if res.status == NFS4ERR_DELAY:
+            time.sleep(2)
+        else:
+            break
+    return res
 
 def open_create_file_op(sess, owner, path=None, attrs={FATTR4_MODE: 0o644},
                      access=OPEN4_SHARE_ACCESS_BOTH,