feat: add rest routes to take the control of flink jobs
This commit is contained in:
44
internal/managed_job/jar.go
Normal file
44
internal/managed_job/jar.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package managed_job
|
||||
|
||||
import (
|
||||
"flink-kube-operator/internal/jar"
|
||||
"flink-kube-operator/pkg"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// upload jar file and set the jarId for later usages
|
||||
func (job *ManagedJob) upload() error {
|
||||
jarFile, err := jar.NewJarFile(job.def.Spec.JarURI)
|
||||
if err != nil {
|
||||
pkg.Logger.Debug("[manage-job] [upload] error on download jar", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
jarId, err := jarFile.Upload(job.client)
|
||||
if err != nil {
|
||||
pkg.Logger.Debug("[manage-job] [upload] error on upload jar", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
pkg.Logger.Info("[manage-job] [upload] uploaded", zap.Any("upload-jar-resp", jarId))
|
||||
|
||||
job.def.Status.JarId = &jarId
|
||||
job.crd.Patch(job.def.UID, map[string]interface{}{
|
||||
"status": map[string]interface{}{
|
||||
"jarId": job.def.Status.JarId,
|
||||
},
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (job *ManagedJob) RemoveJar() {
|
||||
if job.def.Status.JarId != nil {
|
||||
err := job.client.DeleteJar(*job.def.Status.JarId)
|
||||
pkg.Logger.Error("[managed-job] [jar]", zap.Error(err))
|
||||
err = job.crd.Patch(job.def.UID, map[string]interface{}{
|
||||
"status": map[string]interface{}{
|
||||
"jarId": nil,
|
||||
},
|
||||
})
|
||||
pkg.Logger.Error("[managed-job] [jar]", zap.Error(err))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user