Skip to content

Commit

Permalink
IL: lc supports to recover job when restart
Browse files Browse the repository at this point in the history
Signed-off-by: JimmyYang20 <[email protected]>
  • Loading branch information
JimmyYang20 committed Aug 9, 2021
1 parent 44609f0 commit 2cfe1b9
Show file tree
Hide file tree
Showing 2 changed files with 333 additions and 207 deletions.
13 changes: 13 additions & 0 deletions pkg/localcontroller/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ func SaveResource(name string, typeMeta, objectMeta, spec interface{}) error {
return nil
}

// GetResource gets resource info in db
func GetResource(name string) *Resource {
r := Resource{}

queryResult := dbClient.Where("name = ?", name).First(&r)
if queryResult.RowsAffected == 0 {
klog.Warningf("resource(name=%s) not in db", name)
return nil
}

return &r
}

// DeleteResource deletes resource info in db
func DeleteResource(name string) error {
var err error
Expand Down
Loading

0 comments on commit 2cfe1b9

Please sign in to comment.