-
Notifications
You must be signed in to change notification settings - Fork 833
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix job not stopped after execute findished
Signed-off-by: Patrick Zhao <[email protected]>
- Loading branch information
Showing
4 changed files
with
161 additions
and
2 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
pkg/microservice/aslan/core/common/repository/mongodb/update_workflow_task_log.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright 2023 The KodeRover Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package mongodb | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pkg/errors" | ||
"go.mongodb.org/mongo-driver/mongo" | ||
|
||
"github.com/koderover/zadig/v2/pkg/microservice/aslan/config" | ||
mongotool "github.com/koderover/zadig/v2/pkg/tool/mongo" | ||
) | ||
|
||
type UpdateWorkflowTaskLogColl struct { | ||
*mongo.Collection | ||
|
||
coll string | ||
} | ||
|
||
type UpdateWorkflowTaskLog struct { | ||
WorkflowName string `bson:"workflow_name" json:"workflow_name"` | ||
TaskID int64 `bson:"task_id" json:"task_id"` | ||
StartTime int64 `bson:"start_time" json:"start_time"` | ||
EndTime int64 `bson:"end_time" json:"end_time"` | ||
Status string `bson:"status" json:"status"` | ||
Data interface{} `bson:"data" json:"data"` | ||
} | ||
|
||
func (c UpdateWorkflowTaskLog) TableName() string { | ||
return "update_workflow_task_log" | ||
} | ||
|
||
func NewUpdateWorkflowTaskLogColl() *UpdateWorkflowTaskLogColl { | ||
name := UpdateWorkflowTaskLog{}.TableName() | ||
return &UpdateWorkflowTaskLogColl{ | ||
Collection: mongotool.Database(config.MongoDatabase()).Collection(name), | ||
coll: name, | ||
} | ||
} | ||
|
||
func (c *UpdateWorkflowTaskLogColl) GetCollectionName() string { | ||
return c.coll | ||
} | ||
|
||
func (c *UpdateWorkflowTaskLogColl) EnsureIndex(ctx context.Context) error { | ||
return nil | ||
} | ||
|
||
func (c *UpdateWorkflowTaskLogColl) Create(args *UpdateWorkflowTaskLog) error { | ||
if args == nil { | ||
return errors.New("nil UpdateWorkflowTaskLog") | ||
} | ||
|
||
_, err := c.InsertOne(context.Background(), args) | ||
return err | ||
} |
70 changes: 70 additions & 0 deletions
70
pkg/microservice/aslan/core/common/repository/mongodb/wait_pod_finish_log.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright 2023 The KodeRover Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package mongodb | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pkg/errors" | ||
"go.mongodb.org/mongo-driver/mongo" | ||
|
||
"github.com/koderover/zadig/v2/pkg/microservice/aslan/config" | ||
mongotool "github.com/koderover/zadig/v2/pkg/tool/mongo" | ||
) | ||
|
||
type WaitPodFinishLogColl struct { | ||
*mongo.Collection | ||
|
||
coll string | ||
} | ||
|
||
type WaitPodFinishLog struct { | ||
JobName string `bson:"job_name" json:"job_name"` | ||
JobStatus string `bson:"job_status" json:"job_status"` | ||
Namespace string `bson:"namespace" json:"namespace"` | ||
PodName string `bson:"pod_name" json:"pod_name"` | ||
Status string `bson:"status" json:"status"` | ||
} | ||
|
||
func (c WaitPodFinishLog) TableName() string { | ||
return "wait_pod_finish_log" | ||
} | ||
|
||
func NewWaitPodFinishLogColl() *WaitPodFinishLogColl { | ||
name := WaitPodFinishLog{}.TableName() | ||
return &WaitPodFinishLogColl{ | ||
Collection: mongotool.Database(config.MongoDatabase()).Collection(name), | ||
coll: name, | ||
} | ||
} | ||
|
||
func (c *WaitPodFinishLogColl) GetCollectionName() string { | ||
return c.coll | ||
} | ||
|
||
func (c *WaitPodFinishLogColl) EnsureIndex(ctx context.Context) error { | ||
return nil | ||
} | ||
|
||
func (c *WaitPodFinishLogColl) Create(args *WaitPodFinishLog) error { | ||
if args == nil { | ||
return errors.New("nil WaitPodFinishLog") | ||
} | ||
|
||
_, err := c.InsertOne(context.Background(), args) | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters