Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Rainbond2
Commits
f3f2421f
Commit
f3f2421f
authored
6 years ago
by
GLYASAI
Browse files
Options
Download
Email Patches
Plain Diff
[REV] delete config file uuid
parent
b48d0472
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
api/handler/service.go
+2
-7
api/handler/service.go
db/dao/dao.go
+3
-3
db/dao/dao.go
db/model/tenant.go
+1
-3
db/model/tenant.go
db/mysql/dao/tenants.go
+7
-8
db/mysql/dao/tenants.go
db/volume_db_test.go
+3
-3
db/volume_db_test.go
worker/appm/conversion/version.go
+5
-5
worker/appm/conversion/version.go
with
21 additions
and
29 deletions
+21
-29
api/handler/service.go
+
2
-
7
View file @
f3f2421f
...
...
@@ -1214,7 +1214,7 @@ func (s *ServiceAction) VolumnVar(tsv *dbmodel.TenantServiceVolume, tenantID, fi
if
fileContent
!=
""
{
cf
:=
&
dbmodel
.
TenantServiceConfigFile
{
UUID
:
uuid
.
NewV4
()
.
String
(),
Volume
ID
:
tsv
.
UUID
,
Volume
Name
:
tsv
.
VolumeName
,
FileContent
:
fileContent
,
}
if
err
:=
db
.
GetManager
()
.
TenantServiceConfigFileDaoTransactions
(
tx
)
.
AddModel
(
cf
);
err
!=
nil
{
...
...
@@ -1230,11 +1230,6 @@ func (s *ServiceAction) VolumnVar(tsv *dbmodel.TenantServiceVolume, tenantID, fi
case
"delete"
:
// begin transaction
tx
:=
db
.
GetManager
()
.
Begin
()
v
,
err
:=
db
.
GetManager
()
.
TenantServiceVolumeDaoTransactions
(
tx
)
.
GetVolumeByServiceIDAndName
(
tsv
.
ServiceID
,
tsv
.
VolumeName
)
if
err
!=
nil
{
tx
.
Rollback
()
return
util
.
CreateAPIHandleErrorFromDBError
(
"error getting volume"
,
err
)
}
if
tsv
.
VolumeName
!=
""
{
err
:=
db
.
GetManager
()
.
TenantServiceVolumeDaoTransactions
(
tx
)
.
DeleteModel
(
tsv
.
ServiceID
,
tsv
.
VolumeName
)
if
err
!=
nil
&&
err
.
Error
()
!=
gorm
.
ErrRecordNotFound
.
Error
()
{
...
...
@@ -1248,7 +1243,7 @@ func (s *ServiceAction) VolumnVar(tsv *dbmodel.TenantServiceVolume, tenantID, fi
return
util
.
CreateAPIHandleErrorFromDBError
(
"delete volume"
,
err
)
}
}
if
err
:=
db
.
GetManager
()
.
TenantServiceConfigFileDaoTransactions
(
tx
)
.
DelByVolumeID
(
v
.
UUID
);
err
!=
nil
{
if
err
:=
db
.
GetManager
()
.
TenantServiceConfigFileDaoTransactions
(
tx
)
.
DelByVolumeID
(
tsv
.
VolumeName
);
err
!=
nil
{
tx
.
Rollback
()
return
util
.
CreateAPIHandleErrorFromDBError
(
"error deleting config files"
,
err
)
}
...
...
This diff is collapsed.
Click to expand it.
db/dao/dao.go
+
3
-
3
View file @
f3f2421f
...
...
@@ -221,8 +221,8 @@ type TenantServiceVolumeDao interface {
type
TenantServiceConfigFileDao
interface
{
Dao
ListByVolumeID
(
volume
ID
string
)
([]
*
model
.
TenantServiceConfigFile
,
error
)
DelByVolumeID
(
volume
ID
string
)
error
ListByVolumeID
(
volume
Name
string
)
([]
*
model
.
TenantServiceConfigFile
,
error
)
DelByVolumeID
(
volume
Name
string
)
error
}
//TenantServiceLBMappingPortDao vs lb mapping port dao
...
...
@@ -391,4 +391,4 @@ type IPPortDao interface {
type
IPPoolDao
interface
{
Dao
GetIPPoolByEID
(
eid
string
)
(
*
model
.
IPPool
,
error
)
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
db/model/tenant.go
+
1
-
3
View file @
f3f2421f
...
...
@@ -311,7 +311,6 @@ func (vt VolumeType) String() string {
//TenantServiceVolume 应用持久化纪录
type
TenantServiceVolume
struct
{
Model
UUID
string
`gorm:"column:uuid;size:32" json:"uuid"`
ServiceID
string
`gorm:"column:service_id;size:32" json:"service_id"`
//服务类型
Category
string
`gorm:"column:category;size:50" json:"category"`
...
...
@@ -336,8 +335,7 @@ func (t *TenantServiceVolume) TableName() string {
type
TenantServiceConfigFile
struct
{
Model
UUID
string
`gorm:"column:uuid;size:32" json:"uuid"`
VolumeID
string
`gorm:"column:volume_id;size:32" json:"volume_id"`
Filename
string
`gorm:"column:filename" json:"filename"`
VolumeName
string
`gorm:"column:volume_name;size:32" json:"volume_name"`
FileContent
string
`gorm:"column:file_content;size:65535" json:"filename"`
}
...
...
This diff is collapsed.
Click to expand it.
db/mysql/dao/tenants.go
+
7
-
8
View file @
f3f2421f
...
...
@@ -25,10 +25,8 @@ import (
"strconv"
"time"
"github.com/goodrain/rainbond/db/model"
"github.com/Sirupsen/logrus"
"github.com/goodrain/rainbond/db/model"
"github.com/jinzhu/gorm"
)
...
...
@@ -959,6 +957,7 @@ func (t *TenantServiceConfigFileDaoImpl) AddModel(mo model.Interface) error {
return
nil
}
// UpdateModel updates config file
func
(
t
*
TenantServiceConfigFileDaoImpl
)
UpdateModel
(
mo
model
.
Interface
)
error
{
configFile
,
ok
:=
mo
.
(
*
model
.
TenantServiceConfigFile
)
if
!
ok
{
...
...
@@ -971,9 +970,9 @@ func (t *TenantServiceConfigFileDaoImpl) UpdateModel(mo model.Interface) error {
}
// ListByVolumeID lists configFiles by volumeID
func
(
t
*
TenantServiceConfigFileDaoImpl
)
ListByVolumeID
(
volume
ID
string
)
([]
*
model
.
TenantServiceConfigFile
,
error
)
{
func
(
t
*
TenantServiceConfigFileDaoImpl
)
ListByVolumeID
(
volume
Name
string
)
([]
*
model
.
TenantServiceConfigFile
,
error
)
{
var
res
[]
*
model
.
TenantServiceConfigFile
if
err
:=
t
.
DB
.
Where
(
"volume_
id
= ?"
,
volume
ID
)
.
Find
(
&
res
)
.
Error
;
err
!=
nil
{
if
err
:=
t
.
DB
.
Where
(
"volume_
name
= ?"
,
volume
Name
)
.
Find
(
&
res
)
.
Error
;
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -981,9 +980,9 @@ func (t *TenantServiceConfigFileDaoImpl) ListByVolumeID(volumeID string) ([]*mod
}
// DelByVolumeID deletes config files according to volume id
func
(
t
*
TenantServiceConfigFileDaoImpl
)
DelByVolumeID
(
volume
ID
string
)
error
{
var
cfs
[]
model
.
TenantServiceConfigFile
return
t
.
DB
.
Where
(
"volume_
id
= ?"
,
volume
ID
)
.
Delete
(
&
cfs
)
.
Error
func
(
t
*
TenantServiceConfigFileDaoImpl
)
DelByVolumeID
(
volume
Name
string
)
error
{
var
cfs
[]
model
.
TenantServiceConfigFile
return
t
.
DB
.
Where
(
"volume_
name
= ?"
,
volume
Name
)
.
Delete
(
&
cfs
)
.
Error
}
//TenantServiceLBMappingPortDaoImpl stream服务映射
...
...
This diff is collapsed.
Click to expand it.
db/volume_db_test.go
+
3
-
3
View file @
f3f2421f
...
...
@@ -37,9 +37,9 @@ func TestManager_TenantServiceConfigFileDaoImpl_UpdateModel(t *testing.T) {
vid
:=
util
.
NewUUID
()
cf
:=
&
model
.
TenantServiceConfigFile
{
UUID
:
util
.
NewUUID
(),
Volume
ID
:
vid
,
Filename
:
"dummy_filename"
,
UUID
:
util
.
NewUUID
(),
Volume
Name
:
vid
,
Filename
:
"dummy_filename"
,
FileContent
:
"dummy file content"
,
}
if
err
:=
GetManager
()
.
TenantServiceConfigFileDao
()
.
AddModel
(
cf
);
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
worker/appm/conversion/version.go
+
5
-
5
View file @
f3f2421f
...
...
@@ -335,14 +335,14 @@ func createVolumes(as *v1.AppService, version *dbmodel.VersionInfo, dbmanager db
}
// create a configMap which will be mounted as a volume
if
v
.
VolumeType
==
dbmodel
.
ConfigFileVolumeType
.
String
()
{
cfs
,
err
:=
dbmanager
.
TenantServiceConfigFileDao
()
.
ListByVolumeID
(
v
.
UUID
)
cfs
,
err
:=
dbmanager
.
TenantServiceConfigFileDao
()
.
ListByVolumeID
(
v
.
VolumeName
)
if
err
!=
nil
{
logrus
.
Errorf
(
"error listing config files by volume
uuid
(%s): %v"
,
v
.
UUID
,
err
)
return
nil
,
fmt
.
Errorf
(
"error listing config files by volume
uuid
(%s): %v"
,
v
.
UUID
,
err
)
logrus
.
Errorf
(
"error listing config files by volume
name
(%s): %v"
,
v
.
VolumeName
,
err
)
return
nil
,
fmt
.
Errorf
(
"error listing config files by volume
name
(%s): %v"
,
v
.
VolumeName
,
err
)
}
if
cfs
==
nil
||
len
(
cfs
)
==
0
{
logrus
.
Errorf
(
"there is no config files according to volume
id
(%s)"
,
v
.
UUID
)
return
nil
,
fmt
.
Errorf
(
"there is no config files according to volume
id
(%s)"
,
v
.
UUID
)
logrus
.
Errorf
(
"there is no config files according to volume
name
(%s)"
,
v
.
VolumeName
)
return
nil
,
fmt
.
Errorf
(
"there is no config files according to volume
name
(%s)"
,
v
.
VolumeName
)
}
configMap
:=
&
corev1
.
ConfigMap
{
ObjectMeta
:
metav1
.
ObjectMeta
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help