Adding sleep 0 as workaround when copying files with kubectl exec (#378)

Adding sleep 0 as workaround when copying files with kubectl exec

SUMMARY
For all the commands executed remotely, ** && sleep 0** will be
appended as a workaround for all the commands to terminate properly:
16def8050a/lib/ansible/plugins/action/__init__.py (L1243)
Workaround will be applied in case of kubectl exec too:

  
    
      kubernetes.core/plugins/connection/kubectl.py
    
    
         Line 300
      in
      b19ff9d
    
  
  
    

        
          
           super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable) 
        
    
  


That is not the case in the case of the file copy executed by using kubectl exec, therefore it is possible for the kubectl exec to
terminate before dd finishes properly causing the file to be truncated.
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
changelogs/fragments/321-kubectl_sleep.yml
plugins/connection/kubectl.py
This commit is contained in:
Abhijeet Kasurde
2022-02-14 11:51:25 +05:30
committed by GitHub
parent bf3fe91a5d
commit 1f79a03edf
2 changed files with 4 additions and 1 deletions

View File

@@ -355,7 +355,7 @@ class Connection(ConnectionBase):
[
self._play_context.executable,
"-c",
"dd of=%s bs=%s%s" % (out_path, BUFSIZE, count),
"dd of=%s bs=%s%s && sleep 0" % (out_path, BUFSIZE, count),
]
)
args = [to_bytes(i, errors="surrogate_or_strict") for i in args]