未验证 提交 d7e1e910 编写于 作者: C colynn.liu 提交者: GitHub

Merge pull request #24 from sampsonye/bugfix-remove-apprescheck

删除不必要的deployment资源唯一性检查
......@@ -54,10 +54,6 @@ func NewDeployWorker(name, namespace, kind string, ar *AppRes, eparam *Extension
func (wk *DeployWorker) Start(templateName string, param AppParam) error {
log.Log.Info("deploying application: ", wk.Name)
err := wk.checkAppRes(param.Name)
if err != nil {
return err
}
app, err := wk.arHandle.Appmodel.GetAppByName(wk.arHandle.Cluster, wk.kubeRes.Namespace, param.Name)
if err == nil {
return wk.updateAppRes(*app)
......@@ -69,45 +65,6 @@ func (wk *DeployWorker) Start(templateName string, param AppParam) error {
}
//check app res, maybe delete some data
func (wk *DeployWorker) checkAppRes(appname string) error {
// check app name uniqueness in signal cluster
exoticapps, err := wk.arHandle.Appmodel.GetExoticAppListByName(wk.arHandle.Cluster, wk.kubeRes.Namespace, appname)
if err != nil {
return err
}
if len(exoticapps) != 0 {
var exoticns []string
if wk.extension.Force {
//check right
for _, app := range exoticapps {
exoticns = append(exoticns, app.Namespace)
}
if len(exoticns) == 0 {
//uninstall
for _, app := range exoticapps {
log.Log.Warn(fmt.Sprintf("deleting application(%s), cluster(%s), namespace(%s), and you have right to do it...", appname, wk.arHandle.Cluster, app.Namespace))
if err = wk.arHandle.DeleteApp(app.Namespace, app.Name); err != nil {
return fmt.Errorf("the application(%s) is existed in namespace %v of cluster %v, and delete old application failed: %s",
appname, app.Namespace, wk.arHandle.Cluster, err.Error())
}
log.Log.Warn(fmt.Sprintf("delete application(%s), cluster(%s), namespace(%s) successfully, and you have right to do it...", appname, wk.arHandle.Cluster, app.Namespace))
}
}
} else {
//no right
for _, app := range exoticapps {
exoticns = append(exoticns, app.Namespace)
}
}
if len(exoticns) != 0 {
return fmt.Errorf("the application(%s) is existed in namespace %v of cluster %v, and you have no right to cover the old application", appname, exoticns, wk.arHandle.Cluster)
}
}
return nil
}
func (wk *DeployWorker) updateAppRes(app models.CaasApplication) error {
//delete possible resource
log.Log.Info("delete possible deploy and pod resource: ", wk.arHandle.Cluster, wk.kubeRes.Namespace, app.Name, app.Kind)
......
......@@ -173,17 +173,6 @@ func (am *AppModel) SetDeployStatus(cluster, namespace, name, status string) err
return err
}
//return apps which namespace is different with gived namespace
func (am *AppModel) GetExoticAppListByName(cluster, namespace, name string) ([]models.CaasApplication, error) {
var apps []models.CaasApplication
_, err := am.tOrmer.QueryTable(am.TableName).
Filter("name", name).
Filter("cluster", cluster).
Filter("deleted", 0).
Exclude("namespace", namespace).All(&apps)
return apps, err
}
func (am *AppModel) AppExist(cluster, namespace, name string) bool {
return am.tOrmer.QueryTable(am.TableName).
Filter("cluster", cluster).Filter("namespace", namespace).
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册