fix: resolve issue with jar upgrade not uploading new jar
Ensure the new jar is properly uploaded during an upgrade process. Previously, the jar was not replaced as expected.
This commit is contained in:
@@ -15,18 +15,21 @@ import (
|
||||
)
|
||||
|
||||
type Manager struct {
|
||||
client *api.Client
|
||||
managedJobs map[types.UID]managed_job.ManagedJob
|
||||
client *api.Client
|
||||
managedJobs map[types.UID]managed_job.ManagedJob
|
||||
processingJobsIds []types.UID
|
||||
}
|
||||
|
||||
func NewManager(client *api.Client, crdInstance *crd.Crd) Manager {
|
||||
ticker := time.NewTicker(5 * time.Second)
|
||||
quit := make(chan struct{})
|
||||
mgr := Manager{
|
||||
client: client,
|
||||
managedJobs: map[types.UID]managed_job.ManagedJob{},
|
||||
client: client,
|
||||
managedJobs: map[types.UID]managed_job.ManagedJob{},
|
||||
processingJobsIds: []types.UID{},
|
||||
}
|
||||
|
||||
mgr.cycle(client, crdInstance)
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
@@ -47,7 +50,6 @@ func (mgr *Manager) cycle(client *api.Client, crdInstance *crd.Crd) {
|
||||
pkg.Logger.Error("[manager] [cycle] cannot check flink jobs status", zap.Error(jobManagerJobStatusError))
|
||||
crdInstance.PatchAll(map[string]interface{}{
|
||||
"status": map[string]interface{}{
|
||||
"jobStatus": "",
|
||||
"lifeCycleStatus": v1alpha1.LifeCycleStatusUnhealthyJobManager,
|
||||
},
|
||||
})
|
||||
@@ -56,8 +58,14 @@ func (mgr *Manager) cycle(client *api.Client, crdInstance *crd.Crd) {
|
||||
|
||||
// Loop over job definitions as Kubernetes CRD
|
||||
for _, uid := range crd.GetAllJobKeys() {
|
||||
if lo.Contains(mgr.processingJobsIds, uid) {
|
||||
pkg.Logger.Warn("[manager] already in process", zap.Any("uid", uid))
|
||||
continue
|
||||
}
|
||||
|
||||
// Get job definition from Kubernetes CRD
|
||||
def := crd.GetJob(uid)
|
||||
mgr.processingJobsIds = append(mgr.processingJobsIds, uid)
|
||||
|
||||
// Check if job exists in manager managed jobs
|
||||
managedJob, ok := mgr.managedJobs[uid]
|
||||
@@ -80,21 +88,24 @@ func (mgr *Manager) cycle(client *api.Client, crdInstance *crd.Crd) {
|
||||
})
|
||||
if ok {
|
||||
pkg.Logger.Debug("[manager] read status from flink", zap.String("name", jobManagerJobOverview.Name), zap.String("state", jobManagerJobOverview.State))
|
||||
var jobLifeCycleStatus *string
|
||||
patchStatusObj := map[string]interface{}{
|
||||
"jobStatus": v1alpha1.JobStatus(jobManagerJobOverview.State),
|
||||
}
|
||||
if jobManagerJobOverview.State == string(v1alpha1.JobStatusRunning) {
|
||||
status := string(v1alpha1.LifeCycleStatusHealthy)
|
||||
jobLifeCycleStatus = &status
|
||||
patchStatusObj["lifeCycleStatus"] = &status
|
||||
}
|
||||
|
||||
crdInstance.Patch(uid, map[string]interface{}{
|
||||
"status": map[string]interface{}{
|
||||
"jobStatus": v1alpha1.JobStatus(jobManagerJobOverview.State),
|
||||
"lifeCycleStatus": jobLifeCycleStatus,
|
||||
},
|
||||
"status": patchStatusObj,
|
||||
})
|
||||
}
|
||||
|
||||
managedJob.Cycle()
|
||||
mgr.managedJobs[uid] = managedJob
|
||||
|
||||
mgr.processingJobsIds = lo.Filter(mgr.processingJobsIds, func(current types.UID, i int) bool {
|
||||
return current != uid
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user