Skip to content

Commit

Permalink
feature: 限制同步远程插件包任务只能运行单个实例 TencentBlueKing#275
Browse files Browse the repository at this point in the history
  • Loading branch information
pagezz-canway committed May 28, 2019
1 parent 61c9c3e commit e1170ff
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion gcloud/external_plugins/resources.py
Expand Up @@ -35,8 +35,10 @@
from gcloud.external_plugins.models import (
source_cls_factory,
CachePackageSource,
SyncTask
SyncTask,
RUNNING
)

from gcloud.external_plugins.schemas import ADD_SOURCE_SCHEMA, UPDATE_SOURCE_SCHEMA

logger = logging.getLogger('root')
Expand Down Expand Up @@ -306,3 +308,9 @@ class Meta:
}
q_fields = ["id", "pipeline_template__name"]
limit = 0

def obj_create(self, bundle, **kwargs):
model = bundle.obj.__class__
if model.objects.filter(status=RUNNING).exists():
raise BadRequest('There is already a running sync task, please wait for it to complete and try again')
return super(SyncTaskResource, self).obj_create(bundle, **kwargs)

0 comments on commit e1170ff

Please sign in to comment.