8000 fix(api): clear cache wm after import (#3817) · ovh/cds@b88f80e · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit b88f80e

Browse files
yesnaultsguiheux
authored andcommitted
fix(api): clear cache wm after import (#3817)
Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
1 parent 37cabfc commit b88f80e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

engine/api/worker/model_import.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ import (
66
"github.com/go-gorp/gorp"
77
"github.com/lib/pq"
88

9+
"github.com/ovh/cds/engine/api/cache"
910
"github.com/ovh/cds/engine/api/database/gorpmapping"
1011
"github.com/ovh/cds/engine/api/group"
1112
"github.com/ovh/cds/sdk"
1213
"github.com/ovh/cds/sdk/exportentities"
1314
)
1415

1516
// ParseAndImport parse and import an exportentities.WorkerModel
16-
func ParseAndImport(db gorp.SqlExecutor, eWorkerModel *exportentities.WorkerModel, force bool, u *sdk.User) (*sdk.Model, error) {
17+
func ParseAndImport(db gorp.SqlExecutor, store cache.Store, eWorkerModel *exportentities.WorkerModel, force bool, u *sdk.User) (*sdk.Model, error) {
1718
sdkWm, err := eWorkerModel.GetWorkerModel()
1819
if err != nil {
1920
return nil, err
@@ -131,5 +132,7 @@ currentUGroup:
131132
return nil, sdk.WrapError(errAdd, "cannot add worker model %s", sdkWm.Name)
132133
}
133134

135+
// delete current cache of worker model after import
136+
store.DeleteAll(cache.Key("api:workermodels:*"))
134137
return &sdkWm, nil
135138
}

engine/api/worker_model_import.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (api *API) postWorkerModelImportHandler() service.Handler {
4444
return sdk.WrapError(sdk.ErrWrongRequest, "Unsupported content-type: %s", contentType)
4545
}
4646
if errUnMarshall != nil {
47-
return sdk.NewError(sdk.ErrWrongRequest, errUnMarshall)
47+
return sdk.NewError(sdk.ErrWrongRequest, errUnMarshall)
4848
}
4949

5050
tx, err := api.mustDB().Begin()
@@ -53,7 +53,7 @@ func (api *API) postWorkerModelImportHandler() service.Handler {
5353
}
5454
defer tx.Rollback() //nolint
5555

56-
wm, err := worker.ParseAndImport(tx, &eWorkerModel, force, getUser(ctx))
56+
wm, err := worker.ParseAndImport(tx, api.Cache, &eWorkerModel, force, getUser(ctx))
5757
if err != nil {
5858
return sdk.WrapError(err, "cannot parse and import worker model")
5959
}

0 commit comments

Comments
 (0)
0