Skip to content

Commit

Permalink
fix(kbuild): Implement command retry to firmware clone
Browse files Browse the repository at this point in the history
As often firmware git clone fails - implement retry, so
build wont fail.

Signed-off-by: Denys Fedoryshchenko <[email protected]>
  • Loading branch information
nuclearcat committed Nov 6, 2024
1 parent 8549d0e commit e141e99
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion kernelci/kbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,22 @@ def startjob(self, jobname):
cmd = f'echo jobsts:{jobname}=$(date +%s) >> {self._af_dir}/state.txt'
self._steps.append(cmd)

def addcmdretry(self, cmd, retries=10):
'''
Retry command if it fails up to retries times
'''
self.addcomment(f"Retry command {cmd} {retries} times")
self.addcmd("for i in $(seq 1 " + str(retries) + "); do")
self.addcmd(" echo \"Attempt $i\"")
self.addcmd(" sleep 1")
self.addcmd(" " + cmd + " && break")
self.addcmd("done")
self.addcmd("if [ $? -ne 0 ]; then")
self.addcmd(" echo \"Failed to run " + cmd + "\"")
self.addcmd(" exit 1")
self.addcmd("fi")


def addcmd(self, cmd, critical=True):
'''
critical - if True, check return code and exit, as command is critical
Expand All @@ -397,7 +413,8 @@ def _fetch_firmware(self):
TODO: Implement firmware commit id meta/settings
'''
self.startjob("fetch_firmware")
self.addcmd(f"git clone {FW_GIT} --depth 1", False)
#self.addcmd(f"git clone {FW_GIT} --depth 1", False)
self.addcmdretry(f"git clone {FW_GIT} --depth 1", 10)
self.addcmd("cd linux-firmware")
self.addcmd("./copy-firmware.sh " + self._firmware_dir)
self.addcmd("cd ..")
Expand Down

0 comments on commit e141e99

Please sign in to comment.