add patch table sql, return k8s app

This commit is contained in:
yangk 2021-12-09 20:45:10 +08:00
parent 965d681354
commit 9d2ca2b5ab
3 changed files with 9 additions and 1 deletions

View File

@ -467,6 +467,7 @@ func (a *ApplicationAction) GetStatus(ctx context.Context, app *dbmodel.Applicat
Conditions: conditions,
AppID: app.AppID,
AppName: app.AppName,
K8sApp: app.K8sApp,
}
return res, nil
}
@ -828,7 +829,7 @@ func changeVolumeDirectoryNames(parentDir, newPath string) error {
oldPath := fmt.Sprintf("%s/%s", parentDir, f.Name())
newVolPath := newPath + suffix
if err := os.Rename(oldPath, newVolPath); err != nil {
if err == os.ErrExist || strings.Contains(err.Error(), "file exists"){
if err == os.ErrExist || strings.Contains(err.Error(), "file exists") {
logrus.Infof("Ingore change volume path err: [%v]", err)
continue
}

View File

@ -23,6 +23,7 @@ type AppStatus struct {
Version string `json:"version"`
Overrides []string `json:"overrides"`
Conditions []*AppStatusCondition `json:"conditions"`
K8sApp string `json:"k8s_app"`
}
// AppStatusCondition is the conditon of app status.

View File

@ -204,4 +204,10 @@ func (m *Manager) patchTable() {
if err := m.db.Exec("update tenants set namespace=uuid where namespace is NULL;").Error; err != nil {
logrus.Errorf("update tenants namespace error: %s", err.Error())
}
if err := m.db.Exec("update applications set k8s_app=concat('app-',LEFT(app_id,8)) where k8s_app is NULL;").Error; err != nil {
logrus.Errorf("update tenants namespace error: %s", err.Error())
}
if err := m.db.Exec("update tenant_services set k8s_component_name=service_alias where k8s_component_name is NULL;").Error; err != nil {
logrus.Errorf("update tenants namespace error: %s", err.Error())
}
}