feat: retry upload on jar not found

This commit is contained in:
2024-12-08 01:24:14 +03:30
parent 5abc044d69
commit 91ccfebfeb
3 changed files with 79 additions and 38 deletions

View File

@@ -2,6 +2,7 @@ package managed_job
import (
"flink-kube-operator/internal/crd/v1alpha1"
"strings"
"time"
"gitea.com/logicamp/lc"
@@ -32,23 +33,44 @@ func (job *ManagedJob) Cycle() {
// Init job
if job.def.Status.JobStatus == "" {
err := job.upload()
if err != nil {
job.crd.Patch(job.def.UID, map[string]interface{}{
"status": map[string]interface{}{
"error": "[upload-error] " + err.Error(),
},
})
return
}
err = job.run()
if err != nil {
job.crd.Patch(job.def.UID, map[string]interface{}{
"status": map[string]interface{}{
"error": "[run-error] " + err.Error(),
},
})
return
if job.def.Status.LastSavepointPath == nil {
if job.def.Status.JarId == nil {
err := job.upload()
if err != nil {
job.crd.Patch(job.def.UID, map[string]interface{}{
"status": map[string]interface{}{
"error": "[upload-error] " + err.Error(),
},
})
return
}
}
for {
err := job.run()
if err != nil {
if strings.ContainsAny(err.Error(), ".jar does not exist") {
err := job.upload()
if err != nil {
job.crd.Patch(job.def.UID, map[string]interface{}{
"status": map[string]interface{}{
"error": "[upload-error] " + err.Error(),
},
})
return
}
continue
}
job.crd.Patch(job.def.UID, map[string]interface{}{
"status": map[string]interface{}{
"error": "[run-error] " + err.Error(),
},
})
return
}
return
}
} else {
job.restore()
}
return
}