diff --git a/core/kuberes/deployworker.go b/core/kuberes/deployworker.go index cc37928278c4df9ec3cbc21dadb2b5b6573ac5ba..c0c1530c1db752d9114e42c16d2e3cbcc2f1a245 100644 --- a/core/kuberes/deployworker.go +++ b/core/kuberes/deployworker.go @@ -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) diff --git a/dao/application.go b/dao/application.go index b0a6ddafb115cf9386793a1dcbb419ae4528d0a0..82f02180d697c43dfe48d04d8c957f7ea7192656 100644 --- a/dao/application.go +++ b/dao/application.go @@ -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).