mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-01 19:28:05 +08:00
create/delete hpa during app starting/stopping
This commit is contained in:
parent
e3b9fe5011
commit
8d847bde95
@ -274,6 +274,20 @@ func (mr *MockTenantDaoMockRecorder) GetTenantByUUIDIsExist(uuid interface{}) *g
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTenantByUUIDIsExist", reflect.TypeOf((*MockTenantDao)(nil).GetTenantByUUIDIsExist), uuid)
|
||||
}
|
||||
|
||||
// DelByTenantID mocks base method
|
||||
func (m *MockTenantDao) DelByTenantID(tenantID string) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "DelByTenantID", tenantID)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// DelByTenantID indicates an expected call of DelByTenantID
|
||||
func (mr *MockTenantDaoMockRecorder) DelByTenantID(tenantID interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DelByTenantID", reflect.TypeOf((*MockTenantDao)(nil).DelByTenantID), tenantID)
|
||||
}
|
||||
|
||||
// MockAppDao is a mock of AppDao interface
|
||||
type MockAppDao struct {
|
||||
ctrl *gomock.Controller
|
||||
@ -709,6 +723,21 @@ func (mr *MockTenantServiceDaoMockRecorder) ListThirdPartyServices() *gomock.Cal
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListThirdPartyServices", reflect.TypeOf((*MockTenantServiceDao)(nil).ListThirdPartyServices))
|
||||
}
|
||||
|
||||
// ListServicesByTenantID mocks base method
|
||||
func (m *MockTenantServiceDao) ListServicesByTenantID(tenantID string) ([]*model.TenantServices, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListServicesByTenantID", tenantID)
|
||||
ret0, _ := ret[0].([]*model.TenantServices)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListServicesByTenantID indicates an expected call of ListServicesByTenantID
|
||||
func (mr *MockTenantServiceDaoMockRecorder) ListServicesByTenantID(tenantID interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListServicesByTenantID", reflect.TypeOf((*MockTenantServiceDao)(nil).ListServicesByTenantID), tenantID)
|
||||
}
|
||||
|
||||
// MockTenantServiceDeleteDao is a mock of TenantServiceDeleteDao interface
|
||||
type MockTenantServiceDeleteDao struct {
|
||||
ctrl *gomock.Controller
|
||||
@ -1101,6 +1130,21 @@ func (mr *MockTenantPluginDaoMockRecorder) ListByIDs(ids interface{}) *gomock.Ca
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListByIDs", reflect.TypeOf((*MockTenantPluginDao)(nil).ListByIDs), ids)
|
||||
}
|
||||
|
||||
// ListByTenantID mocks base method
|
||||
func (m *MockTenantPluginDao) ListByTenantID(tenantID string) ([]*model.TenantPlugin, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListByTenantID", tenantID)
|
||||
ret0, _ := ret[0].([]*model.TenantPlugin)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListByTenantID indicates an expected call of ListByTenantID
|
||||
func (mr *MockTenantPluginDaoMockRecorder) ListByTenantID(tenantID interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListByTenantID", reflect.TypeOf((*MockTenantPluginDao)(nil).ListByTenantID), tenantID)
|
||||
}
|
||||
|
||||
// MockTenantPluginDefaultENVDao is a mock of TenantPluginDefaultENVDao interface
|
||||
type MockTenantPluginDefaultENVDao struct {
|
||||
ctrl *gomock.Controller
|
||||
@ -4977,3 +5021,164 @@ func (mr *MockGwRuleConfigDaoMockRecorder) ListByRuleID(rid interface{}) *gomock
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListByRuleID", reflect.TypeOf((*MockGwRuleConfigDao)(nil).ListByRuleID), rid)
|
||||
}
|
||||
|
||||
// MockTenantServceAutoscalerRulesDao is a mock of TenantServceAutoscalerRulesDao interface
|
||||
type MockTenantServceAutoscalerRulesDao struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockTenantServceAutoscalerRulesDaoMockRecorder
|
||||
}
|
||||
|
||||
// MockTenantServceAutoscalerRulesDaoMockRecorder is the mock recorder for MockTenantServceAutoscalerRulesDao
|
||||
type MockTenantServceAutoscalerRulesDaoMockRecorder struct {
|
||||
mock *MockTenantServceAutoscalerRulesDao
|
||||
}
|
||||
|
||||
// NewMockTenantServceAutoscalerRulesDao creates a new mock instance
|
||||
func NewMockTenantServceAutoscalerRulesDao(ctrl *gomock.Controller) *MockTenantServceAutoscalerRulesDao {
|
||||
mock := &MockTenantServceAutoscalerRulesDao{ctrl: ctrl}
|
||||
mock.recorder = &MockTenantServceAutoscalerRulesDaoMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockTenantServceAutoscalerRulesDao) EXPECT() *MockTenantServceAutoscalerRulesDaoMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// AddModel mocks base method
|
||||
func (m *MockTenantServceAutoscalerRulesDao) AddModel(arg0 model.Interface) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AddModel", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// AddModel indicates an expected call of AddModel
|
||||
func (mr *MockTenantServceAutoscalerRulesDaoMockRecorder) AddModel(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddModel", reflect.TypeOf((*MockTenantServceAutoscalerRulesDao)(nil).AddModel), arg0)
|
||||
}
|
||||
|
||||
// UpdateModel mocks base method
|
||||
func (m *MockTenantServceAutoscalerRulesDao) UpdateModel(arg0 model.Interface) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateModel", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// UpdateModel indicates an expected call of UpdateModel
|
||||
func (mr *MockTenantServceAutoscalerRulesDaoMockRecorder) UpdateModel(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateModel", reflect.TypeOf((*MockTenantServceAutoscalerRulesDao)(nil).UpdateModel), arg0)
|
||||
}
|
||||
|
||||
// GetByRuleID mocks base method
|
||||
func (m *MockTenantServceAutoscalerRulesDao) GetByRuleID(ruleID string) (*model.TenantServiceAutoscalerRules, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetByRuleID", ruleID)
|
||||
ret0, _ := ret[0].(*model.TenantServiceAutoscalerRules)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetByRuleID indicates an expected call of GetByRuleID
|
||||
func (mr *MockTenantServceAutoscalerRulesDaoMockRecorder) GetByRuleID(ruleID interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByRuleID", reflect.TypeOf((*MockTenantServceAutoscalerRulesDao)(nil).GetByRuleID), ruleID)
|
||||
}
|
||||
|
||||
// ListByServiceID mocks base method
|
||||
func (m *MockTenantServceAutoscalerRulesDao) ListByServiceID(serviceID string) ([]*model.TenantServiceAutoscalerRules, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListByServiceID", serviceID)
|
||||
ret0, _ := ret[0].([]*model.TenantServiceAutoscalerRules)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListByServiceID indicates an expected call of ListByServiceID
|
||||
func (mr *MockTenantServceAutoscalerRulesDaoMockRecorder) ListByServiceID(serviceID interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListByServiceID", reflect.TypeOf((*MockTenantServceAutoscalerRulesDao)(nil).ListByServiceID), serviceID)
|
||||
}
|
||||
|
||||
// MockTenantServceAutoscalerRuleMetricsDao is a mock of TenantServceAutoscalerRuleMetricsDao interface
|
||||
type MockTenantServceAutoscalerRuleMetricsDao struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockTenantServceAutoscalerRuleMetricsDaoMockRecorder
|
||||
}
|
||||
|
||||
// MockTenantServceAutoscalerRuleMetricsDaoMockRecorder is the mock recorder for MockTenantServceAutoscalerRuleMetricsDao
|
||||
type MockTenantServceAutoscalerRuleMetricsDaoMockRecorder struct {
|
||||
mock *MockTenantServceAutoscalerRuleMetricsDao
|
||||
}
|
||||
|
||||
// NewMockTenantServceAutoscalerRuleMetricsDao creates a new mock instance
|
||||
func NewMockTenantServceAutoscalerRuleMetricsDao(ctrl *gomock.Controller) *MockTenantServceAutoscalerRuleMetricsDao {
|
||||
mock := &MockTenantServceAutoscalerRuleMetricsDao{ctrl: ctrl}
|
||||
mock.recorder = &MockTenantServceAutoscalerRuleMetricsDaoMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockTenantServceAutoscalerRuleMetricsDao) EXPECT() *MockTenantServceAutoscalerRuleMetricsDaoMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// AddModel mocks base method
|
||||
func (m *MockTenantServceAutoscalerRuleMetricsDao) AddModel(arg0 model.Interface) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AddModel", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// AddModel indicates an expected call of AddModel
|
||||
func (mr *MockTenantServceAutoscalerRuleMetricsDaoMockRecorder) AddModel(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddModel", reflect.TypeOf((*MockTenantServceAutoscalerRuleMetricsDao)(nil).AddModel), arg0)
|
||||
}
|
||||
|
||||
// UpdateModel mocks base method
|
||||
func (m *MockTenantServceAutoscalerRuleMetricsDao) UpdateModel(arg0 model.Interface) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateModel", arg0)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// UpdateModel indicates an expected call of UpdateModel
|
||||
func (mr *MockTenantServceAutoscalerRuleMetricsDaoMockRecorder) UpdateModel(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateModel", reflect.TypeOf((*MockTenantServceAutoscalerRuleMetricsDao)(nil).UpdateModel), arg0)
|
||||
}
|
||||
|
||||
// UpdateOrCreate mocks base method
|
||||
func (m *MockTenantServceAutoscalerRuleMetricsDao) UpdateOrCreate(metric *model.TenantServiceAutoscalerRuleMetrics) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateOrCreate", metric)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// UpdateOrCreate indicates an expected call of UpdateOrCreate
|
||||
func (mr *MockTenantServceAutoscalerRuleMetricsDaoMockRecorder) UpdateOrCreate(metric interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateOrCreate", reflect.TypeOf((*MockTenantServceAutoscalerRuleMetricsDao)(nil).UpdateOrCreate), metric)
|
||||
}
|
||||
|
||||
// ListByRuleID mocks base method
|
||||
func (m *MockTenantServceAutoscalerRuleMetricsDao) ListByRuleID(ruleID string) ([]*model.TenantServiceAutoscalerRuleMetrics, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ListByRuleID", ruleID)
|
||||
ret0, _ := ret[0].([]*model.TenantServiceAutoscalerRuleMetrics)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// ListByRuleID indicates an expected call of ListByRuleID
|
||||
func (mr *MockTenantServceAutoscalerRuleMetricsDaoMockRecorder) ListByRuleID(ruleID interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListByRuleID", reflect.TypeOf((*MockTenantServceAutoscalerRuleMetricsDao)(nil).ListByRuleID), ruleID)
|
||||
}
|
||||
|
@ -62,6 +62,20 @@ func (mr *MockManagerMockRecorder) Begin() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Begin", reflect.TypeOf((*MockManager)(nil).Begin))
|
||||
}
|
||||
|
||||
// EnsureEndTransactionFunc mocks base method
|
||||
func (m *MockManager) EnsureEndTransactionFunc() func(*gorm.DB) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "EnsureEndTransactionFunc")
|
||||
ret0, _ := ret[0].(func(*gorm.DB))
|
||||
return ret0
|
||||
}
|
||||
|
||||
// EnsureEndTransactionFunc indicates an expected call of EnsureEndTransactionFunc
|
||||
func (mr *MockManagerMockRecorder) EnsureEndTransactionFunc() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnsureEndTransactionFunc", reflect.TypeOf((*MockManager)(nil).EnsureEndTransactionFunc))
|
||||
}
|
||||
|
||||
// LicenseDao mocks base method
|
||||
func (m *MockManager) LicenseDao() dao.LicenseDao {
|
||||
m.ctrl.T.Helper()
|
||||
@ -832,6 +846,20 @@ func (mr *MockManagerMockRecorder) AppBackupDao() *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AppBackupDao", reflect.TypeOf((*MockManager)(nil).AppBackupDao))
|
||||
}
|
||||
|
||||
// AppBackupDaoTransactions mocks base method
|
||||
func (m *MockManager) AppBackupDaoTransactions(db *gorm.DB) dao.AppBackupDao {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "AppBackupDaoTransactions", db)
|
||||
ret0, _ := ret[0].(dao.AppBackupDao)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// AppBackupDaoTransactions indicates an expected call of AppBackupDaoTransactions
|
||||
func (mr *MockManagerMockRecorder) AppBackupDaoTransactions(db interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AppBackupDaoTransactions", reflect.TypeOf((*MockManager)(nil).AppBackupDaoTransactions), db)
|
||||
}
|
||||
|
||||
// ServiceSourceDao mocks base method
|
||||
func (m *MockManager) ServiceSourceDao() dao.ServiceSourceDao {
|
||||
m.ctrl.T.Helper()
|
||||
@ -1041,3 +1069,59 @@ func (mr *MockManagerMockRecorder) ThirdPartySvcDiscoveryCfgDaoTransactions(db i
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ThirdPartySvcDiscoveryCfgDaoTransactions", reflect.TypeOf((*MockManager)(nil).ThirdPartySvcDiscoveryCfgDaoTransactions), db)
|
||||
}
|
||||
|
||||
// TenantServceAutoscalerRulesDao mocks base method
|
||||
func (m *MockManager) TenantServceAutoscalerRulesDao() dao.TenantServceAutoscalerRulesDao {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "TenantServceAutoscalerRulesDao")
|
||||
ret0, _ := ret[0].(dao.TenantServceAutoscalerRulesDao)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// TenantServceAutoscalerRulesDao indicates an expected call of TenantServceAutoscalerRulesDao
|
||||
func (mr *MockManagerMockRecorder) TenantServceAutoscalerRulesDao() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TenantServceAutoscalerRulesDao", reflect.TypeOf((*MockManager)(nil).TenantServceAutoscalerRulesDao))
|
||||
}
|
||||
|
||||
// TenantServceAutoscalerRulesDaoTransactions mocks base method
|
||||
func (m *MockManager) TenantServceAutoscalerRulesDaoTransactions(db *gorm.DB) dao.TenantServceAutoscalerRulesDao {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "TenantServceAutoscalerRulesDaoTransactions", db)
|
||||
ret0, _ := ret[0].(dao.TenantServceAutoscalerRulesDao)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// TenantServceAutoscalerRulesDaoTransactions indicates an expected call of TenantServceAutoscalerRulesDaoTransactions
|
||||
func (mr *MockManagerMockRecorder) TenantServceAutoscalerRulesDaoTransactions(db interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TenantServceAutoscalerRulesDaoTransactions", reflect.TypeOf((*MockManager)(nil).TenantServceAutoscalerRulesDaoTransactions), db)
|
||||
}
|
||||
|
||||
// TenantServceAutoscalerRuleMetricsDao mocks base method
|
||||
func (m *MockManager) TenantServceAutoscalerRuleMetricsDao() dao.TenantServceAutoscalerRuleMetricsDao {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "TenantServceAutoscalerRuleMetricsDao")
|
||||
ret0, _ := ret[0].(dao.TenantServceAutoscalerRuleMetricsDao)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// TenantServceAutoscalerRuleMetricsDao indicates an expected call of TenantServceAutoscalerRuleMetricsDao
|
||||
func (mr *MockManagerMockRecorder) TenantServceAutoscalerRuleMetricsDao() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TenantServceAutoscalerRuleMetricsDao", reflect.TypeOf((*MockManager)(nil).TenantServceAutoscalerRuleMetricsDao))
|
||||
}
|
||||
|
||||
// TenantServceAutoscalerRuleMetricsDaoTransactions mocks base method
|
||||
func (m *MockManager) TenantServceAutoscalerRuleMetricsDaoTransactions(db *gorm.DB) dao.TenantServceAutoscalerRuleMetricsDao {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "TenantServceAutoscalerRuleMetricsDaoTransactions", db)
|
||||
ret0, _ := ret[0].(dao.TenantServceAutoscalerRuleMetricsDao)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// TenantServceAutoscalerRuleMetricsDaoTransactions indicates an expected call of TenantServceAutoscalerRuleMetricsDaoTransactions
|
||||
func (mr *MockManagerMockRecorder) TenantServceAutoscalerRuleMetricsDaoTransactions(db interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TenantServceAutoscalerRuleMetricsDaoTransactions", reflect.TypeOf((*MockManager)(nil).TenantServceAutoscalerRuleMetricsDaoTransactions), db)
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ func (m *MockManager) EXPECT() *MockManagerMockRecorder {
|
||||
|
||||
// GetLogger mocks base method
|
||||
func (m *MockManager) GetLogger(eventID string) Logger {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetLogger", eventID)
|
||||
ret0, _ := ret[0].(Logger)
|
||||
return ret0
|
||||
@ -42,11 +43,13 @@ func (m *MockManager) GetLogger(eventID string) Logger {
|
||||
|
||||
// GetLogger indicates an expected call of GetLogger
|
||||
func (mr *MockManagerMockRecorder) GetLogger(eventID interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLogger", reflect.TypeOf((*MockManager)(nil).GetLogger), eventID)
|
||||
}
|
||||
|
||||
// Start mocks base method
|
||||
func (m *MockManager) Start() error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Start")
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
@ -54,11 +57,13 @@ func (m *MockManager) Start() error {
|
||||
|
||||
// Start indicates an expected call of Start
|
||||
func (mr *MockManagerMockRecorder) Start() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockManager)(nil).Start))
|
||||
}
|
||||
|
||||
// Close mocks base method
|
||||
func (m *MockManager) Close() error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Close")
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
@ -66,16 +71,19 @@ func (m *MockManager) Close() error {
|
||||
|
||||
// Close indicates an expected call of Close
|
||||
func (mr *MockManagerMockRecorder) Close() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockManager)(nil).Close))
|
||||
}
|
||||
|
||||
// ReleaseLogger mocks base method
|
||||
func (m *MockManager) ReleaseLogger(arg0 Logger) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "ReleaseLogger", arg0)
|
||||
}
|
||||
|
||||
// ReleaseLogger indicates an expected call of ReleaseLogger
|
||||
func (mr *MockManagerMockRecorder) ReleaseLogger(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReleaseLogger", reflect.TypeOf((*MockManager)(nil).ReleaseLogger), arg0)
|
||||
}
|
||||
|
||||
@ -104,36 +112,43 @@ func (m *MockLogger) EXPECT() *MockLoggerMockRecorder {
|
||||
|
||||
// Info mocks base method
|
||||
func (m *MockLogger) Info(arg0 string, arg1 map[string]string) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Info", arg0, arg1)
|
||||
}
|
||||
|
||||
// Info indicates an expected call of Info
|
||||
func (mr *MockLoggerMockRecorder) Info(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Info", reflect.TypeOf((*MockLogger)(nil).Info), arg0, arg1)
|
||||
}
|
||||
|
||||
// Error mocks base method
|
||||
func (m *MockLogger) Error(arg0 string, arg1 map[string]string) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Error", arg0, arg1)
|
||||
}
|
||||
|
||||
// Error indicates an expected call of Error
|
||||
func (mr *MockLoggerMockRecorder) Error(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Error", reflect.TypeOf((*MockLogger)(nil).Error), arg0, arg1)
|
||||
}
|
||||
|
||||
// Debug mocks base method
|
||||
func (m *MockLogger) Debug(arg0 string, arg1 map[string]string) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Debug", arg0, arg1)
|
||||
}
|
||||
|
||||
// Debug indicates an expected call of Debug
|
||||
func (mr *MockLoggerMockRecorder) Debug(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Debug", reflect.TypeOf((*MockLogger)(nil).Debug), arg0, arg1)
|
||||
}
|
||||
|
||||
// Event mocks base method
|
||||
func (m *MockLogger) Event() string {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Event")
|
||||
ret0, _ := ret[0].(string)
|
||||
return ret0
|
||||
@ -141,11 +156,13 @@ func (m *MockLogger) Event() string {
|
||||
|
||||
// Event indicates an expected call of Event
|
||||
func (mr *MockLoggerMockRecorder) Event() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Event", reflect.TypeOf((*MockLogger)(nil).Event))
|
||||
}
|
||||
|
||||
// CreateTime mocks base method
|
||||
func (m *MockLogger) CreateTime() time.Time {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CreateTime")
|
||||
ret0, _ := ret[0].(time.Time)
|
||||
return ret0
|
||||
@ -153,11 +170,13 @@ func (m *MockLogger) CreateTime() time.Time {
|
||||
|
||||
// CreateTime indicates an expected call of CreateTime
|
||||
func (mr *MockLoggerMockRecorder) CreateTime() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateTime", reflect.TypeOf((*MockLogger)(nil).CreateTime))
|
||||
}
|
||||
|
||||
// GetChan mocks base method
|
||||
func (m *MockLogger) GetChan() chan []byte {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetChan")
|
||||
ret0, _ := ret[0].(chan []byte)
|
||||
return ret0
|
||||
@ -165,21 +184,25 @@ func (m *MockLogger) GetChan() chan []byte {
|
||||
|
||||
// GetChan indicates an expected call of GetChan
|
||||
func (mr *MockLoggerMockRecorder) GetChan() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetChan", reflect.TypeOf((*MockLogger)(nil).GetChan))
|
||||
}
|
||||
|
||||
// SetChan mocks base method
|
||||
func (m *MockLogger) SetChan(arg0 chan []byte) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "SetChan", arg0)
|
||||
}
|
||||
|
||||
// SetChan indicates an expected call of SetChan
|
||||
func (mr *MockLoggerMockRecorder) SetChan(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetChan", reflect.TypeOf((*MockLogger)(nil).SetChan), arg0)
|
||||
}
|
||||
|
||||
// GetWriter mocks base method
|
||||
func (m *MockLogger) GetWriter(step, level string) LoggerWriter {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetWriter", step, level)
|
||||
ret0, _ := ret[0].(LoggerWriter)
|
||||
return ret0
|
||||
@ -187,6 +210,7 @@ func (m *MockLogger) GetWriter(step, level string) LoggerWriter {
|
||||
|
||||
// GetWriter indicates an expected call of GetWriter
|
||||
func (mr *MockLoggerMockRecorder) GetWriter(step, level interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWriter", reflect.TypeOf((*MockLogger)(nil).GetWriter), step, level)
|
||||
}
|
||||
|
||||
@ -215,6 +239,7 @@ func (m *MockLoggerWriter) EXPECT() *MockLoggerWriterMockRecorder {
|
||||
|
||||
// Write mocks base method
|
||||
func (m *MockLoggerWriter) Write(p []byte) (int, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Write", p)
|
||||
ret0, _ := ret[0].(int)
|
||||
ret1, _ := ret[1].(error)
|
||||
@ -223,15 +248,18 @@ func (m *MockLoggerWriter) Write(p []byte) (int, error) {
|
||||
|
||||
// Write indicates an expected call of Write
|
||||
func (mr *MockLoggerWriterMockRecorder) Write(p interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Write", reflect.TypeOf((*MockLoggerWriter)(nil).Write), p)
|
||||
}
|
||||
|
||||
// SetFormat mocks base method
|
||||
func (m *MockLoggerWriter) SetFormat(arg0 map[string]interface{}) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "SetFormat", arg0)
|
||||
}
|
||||
|
||||
// SetFormat indicates an expected call of SetFormat
|
||||
func (mr *MockLoggerWriterMockRecorder) SetFormat(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetFormat", reflect.TypeOf((*MockLoggerWriter)(nil).SetFormat), arg0)
|
||||
}
|
||||
|
@ -144,6 +144,17 @@ func (s *startController) startOne(app v1.AppService) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if hpas := app.GetHPAs(); len(hpas) != 0 {
|
||||
for _, hpa := range hpas {
|
||||
_, err := s.manager.client.AutoscalingV2beta1().HorizontalPodAutoscalers(hpa.GetNamespace()).Create(hpa)
|
||||
if err != nil && !errors.IsAlreadyExists(err) {
|
||||
logrus.Debugf("hpa: %#v", hpa)
|
||||
return fmt.Errorf("create hpa: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//step 6: waiting endpoint ready
|
||||
app.Logger.Info("Create all app model success, will waiting app ready", event.GetLoggerOption("running"))
|
||||
return s.WaitingReady(app)
|
||||
|
@ -139,6 +139,17 @@ func (s *stopController) stopOne(app v1.AppService) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if hpas := app.GetHPAs(); len(hpas) != 0 {
|
||||
for _, hpa := range hpas {
|
||||
err := s.manager.client.AutoscalingV2beta1().HorizontalPodAutoscalers(hpa.GetNamespace()).Delete(hpa.GetName(), &metav1.DeleteOptions{})
|
||||
if err != nil && !errors.IsNotFound(err) {
|
||||
return fmt.Errorf("delete hpa: %v", err)
|
||||
}
|
||||
s.manager.store.OnDelete(hpa)
|
||||
}
|
||||
}
|
||||
|
||||
//step 7: waiting endpoint ready
|
||||
app.Logger.Info("Delete all app model success, will waiting app closed", event.GetLoggerOption("running"))
|
||||
return s.WaitingReady(app)
|
||||
|
141
worker/appm/conversion/autoscaler.go
Normal file
141
worker/appm/conversion/autoscaler.go
Normal file
@ -0,0 +1,141 @@
|
||||
// RAINBOND, Application Management Platform
|
||||
// Copyright (C) 2014-2017 Goodrain Co., Ltd.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version. For any non-GPL usage of Rainbond,
|
||||
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
|
||||
// must be obtained first.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package conversion
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
|
||||
v2beta1 "k8s.io/api/autoscaling/v2beta1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/goodrain/rainbond/db"
|
||||
"github.com/goodrain/rainbond/db/model"
|
||||
"github.com/goodrain/rainbond/util"
|
||||
v1 "github.com/goodrain/rainbond/worker/appm/types/v1"
|
||||
)
|
||||
|
||||
var str2ResourceName = map[string]corev1.ResourceName{
|
||||
"cpu": corev1.ResourceCPU,
|
||||
"memory": corev1.ResourceMemory,
|
||||
}
|
||||
|
||||
// TenantServiceAutoscaler -
|
||||
func TenantServiceAutoscaler(as *v1.AppService, dbmanager db.Manager) error {
|
||||
hpas, err := newHPAs(as, dbmanager)
|
||||
if err != nil {
|
||||
return fmt.Errorf("create HPAs: %v", err)
|
||||
}
|
||||
|
||||
as.SetHPAs(hpas)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func newHPAs(as *v1.AppService, dbmanager db.Manager) ([]*v2beta1.HorizontalPodAutoscaler, error) {
|
||||
xpaRules, err := dbmanager.TenantServceAutoscalerRulesDao().ListByServiceID(as.ServiceID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var hpas []*v2beta1.HorizontalPodAutoscaler
|
||||
for _, rule := range xpaRules {
|
||||
metrics, err := dbmanager.TenantServceAutoscalerRuleMetricsDao().ListByRuleID(rule.RuleID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var kind, name string
|
||||
if as.GetStatefulSet() != nil {
|
||||
kind, name = "Statefulset", as.GetStatefulSet().GetName()
|
||||
} else {
|
||||
kind, name = "Deployment", as.GetDeployment().GetName()
|
||||
}
|
||||
|
||||
labels := as.GetCommonLabels(map[string]string{
|
||||
"rule_id": rule.RuleID,
|
||||
})
|
||||
|
||||
hpa := newHPA(as.TenantID, kind, name, labels, rule, metrics)
|
||||
|
||||
hpas = append(hpas, hpa)
|
||||
}
|
||||
|
||||
return hpas, nil
|
||||
}
|
||||
|
||||
func createResourceMetrics(metric *model.TenantServiceAutoscalerRuleMetrics) v2beta1.MetricSpec {
|
||||
ms := v2beta1.MetricSpec{
|
||||
Type: v2beta1.ResourceMetricSourceType,
|
||||
Resource: &v2beta1.ResourceMetricSource{
|
||||
Name: str2ResourceName[metric.MetricsName],
|
||||
},
|
||||
}
|
||||
|
||||
if metric.MetricTargetType == "utilization" {
|
||||
value := int32(metric.MetricTargetValue)
|
||||
ms.Resource.TargetAverageUtilization = &value
|
||||
}
|
||||
if metric.MetricTargetType == "average_value" {
|
||||
if metric.MetricsName == "cpu" {
|
||||
ms.Resource.TargetAverageValue = resource.NewMilliQuantity(int64(metric.MetricTargetValue), resource.DecimalSI)
|
||||
}
|
||||
if metric.MetricsName == "memory" {
|
||||
ms.Resource.TargetAverageValue = resource.NewQuantity(int64(metric.MetricTargetValue*1024*1024), resource.BinarySI)
|
||||
}
|
||||
}
|
||||
|
||||
return ms
|
||||
}
|
||||
|
||||
func newHPA(namespace, kind, name string, labels map[string]string, rule *model.TenantServiceAutoscalerRules, metrics []*model.TenantServiceAutoscalerRuleMetrics) *v2beta1.HorizontalPodAutoscaler {
|
||||
hpa := &v2beta1.HorizontalPodAutoscaler{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: rule.RuleID,
|
||||
Namespace: namespace,
|
||||
Labels: labels,
|
||||
},
|
||||
}
|
||||
|
||||
spec := v2beta1.HorizontalPodAutoscalerSpec{
|
||||
MinReplicas: util.Int32(int32(rule.MinReplicas)),
|
||||
MaxReplicas: int32(rule.MaxReplicas),
|
||||
ScaleTargetRef: v2beta1.CrossVersionObjectReference{
|
||||
Kind: kind,
|
||||
Name: name,
|
||||
APIVersion: "apps/v1",
|
||||
},
|
||||
}
|
||||
|
||||
for _, metric := range metrics {
|
||||
if metric.MetricsType != "resource_metrics" {
|
||||
logrus.Warningf("rule id: %s; unsupported metric type: %s", rule.RuleID, metric.MetricsType)
|
||||
continue
|
||||
}
|
||||
|
||||
ms := createResourceMetrics(metric)
|
||||
spec.Metrics = append(spec.Metrics, ms)
|
||||
}
|
||||
hpa.Spec = spec
|
||||
|
||||
return hpa
|
||||
}
|
62
worker/appm/conversion/autoscaler_test.go
Normal file
62
worker/appm/conversion/autoscaler_test.go
Normal file
@ -0,0 +1,62 @@
|
||||
package conversion
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/goodrain/rainbond/db/model"
|
||||
k8sutil "github.com/goodrain/rainbond/util/k8s"
|
||||
)
|
||||
|
||||
func TestCreateMetricSpec(t *testing.T) {
|
||||
metric := &model.TenantServiceAutoscalerRuleMetrics{
|
||||
MetricsType: "resource_metrics",
|
||||
MetricsName: "memory",
|
||||
MetricTargetType: "average_value",
|
||||
MetricTargetValue: 60,
|
||||
}
|
||||
|
||||
metricSpec := createResourceMetrics(metric)
|
||||
t.Logf("%#v", metricSpec)
|
||||
|
||||
if metricSpec.Resource.TargetAverageValue == nil {
|
||||
t.Errorf("empty target average value.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewHPA(t *testing.T) {
|
||||
rule := &model.TenantServiceAutoscalerRules{
|
||||
RuleID: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
||||
ServiceID: "45197f4936cf45efa2ac4831ce42025a",
|
||||
MinReplicas: 1,
|
||||
MaxReplicas: 10,
|
||||
}
|
||||
metrics := []*model.TenantServiceAutoscalerRuleMetrics{
|
||||
{
|
||||
MetricsType: "resource_metrics",
|
||||
MetricsName: "cpu",
|
||||
MetricTargetType: "utilization",
|
||||
MetricTargetValue: 50,
|
||||
},
|
||||
{
|
||||
MetricsType: "resource_metrics",
|
||||
MetricsName: "memory",
|
||||
MetricTargetType: "average_value",
|
||||
MetricTargetValue: 60,
|
||||
},
|
||||
}
|
||||
namespace := "bab18e6b1c8640979b91f8dfdd211226"
|
||||
kind := "Deployment"
|
||||
name := "45197f4936cf45efa2ac4831ce42025a-deployment-6d84f798b4-tmvfc"
|
||||
|
||||
hpa := newHPA(namespace, kind, name, nil, rule, metrics)
|
||||
|
||||
clientset, err := k8sutil.NewClientset("/opt/rainbond/etc/kubernetes/kubecfg/admin.kubeconfig")
|
||||
if err != nil {
|
||||
t.Fatalf("error creating k8s clientset: %s", err.Error())
|
||||
}
|
||||
|
||||
_, err = clientset.AutoscalingV2beta1().HorizontalPodAutoscalers(hpa.GetNamespace()).Create(hpa)
|
||||
if err != nil {
|
||||
t.Fatalf("create hpa: %v", err)
|
||||
}
|
||||
}
|
@ -36,6 +36,7 @@ func init() {
|
||||
RegistConversion("TenantServicePlugin", TenantServicePlugin)
|
||||
//step5 conv service inner and outer regist
|
||||
RegistConversion("TenantServiceRegist", TenantServiceRegist)
|
||||
RegistConversion("TenantServiceAutoscaler", TenantServiceAutoscaler)
|
||||
}
|
||||
|
||||
//Conversion conversion function
|
||||
|
@ -38,6 +38,7 @@ func (m *MockStorer) EXPECT() *MockStorerMockRecorder {
|
||||
|
||||
// Start mocks base method
|
||||
func (m *MockStorer) Start() error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Start")
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
@ -45,11 +46,13 @@ func (m *MockStorer) Start() error {
|
||||
|
||||
// Start indicates an expected call of Start
|
||||
func (mr *MockStorerMockRecorder) Start() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockStorer)(nil).Start))
|
||||
}
|
||||
|
||||
// Ready mocks base method
|
||||
func (m *MockStorer) Ready() bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Ready")
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
@ -57,21 +60,25 @@ func (m *MockStorer) Ready() bool {
|
||||
|
||||
// Ready indicates an expected call of Ready
|
||||
func (mr *MockStorerMockRecorder) Ready() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Ready", reflect.TypeOf((*MockStorer)(nil).Ready))
|
||||
}
|
||||
|
||||
// RegistAppService mocks base method
|
||||
func (m *MockStorer) RegistAppService(arg0 *v1.AppService) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "RegistAppService", arg0)
|
||||
}
|
||||
|
||||
// RegistAppService indicates an expected call of RegistAppService
|
||||
func (mr *MockStorerMockRecorder) RegistAppService(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegistAppService", reflect.TypeOf((*MockStorer)(nil).RegistAppService), arg0)
|
||||
}
|
||||
|
||||
// GetAppService mocks base method
|
||||
func (m *MockStorer) GetAppService(serviceID string) *v1.AppService {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetAppService", serviceID)
|
||||
ret0, _ := ret[0].(*v1.AppService)
|
||||
return ret0
|
||||
@ -79,11 +86,13 @@ func (m *MockStorer) GetAppService(serviceID string) *v1.AppService {
|
||||
|
||||
// GetAppService indicates an expected call of GetAppService
|
||||
func (mr *MockStorerMockRecorder) GetAppService(serviceID interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAppService", reflect.TypeOf((*MockStorer)(nil).GetAppService), serviceID)
|
||||
}
|
||||
|
||||
// UpdateGetAppService mocks base method
|
||||
func (m *MockStorer) UpdateGetAppService(serviceID string) *v1.AppService {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "UpdateGetAppService", serviceID)
|
||||
ret0, _ := ret[0].(*v1.AppService)
|
||||
return ret0
|
||||
@ -91,11 +100,13 @@ func (m *MockStorer) UpdateGetAppService(serviceID string) *v1.AppService {
|
||||
|
||||
// UpdateGetAppService indicates an expected call of UpdateGetAppService
|
||||
func (mr *MockStorerMockRecorder) UpdateGetAppService(serviceID interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateGetAppService", reflect.TypeOf((*MockStorer)(nil).UpdateGetAppService), serviceID)
|
||||
}
|
||||
|
||||
// GetAllAppServices mocks base method
|
||||
func (m *MockStorer) GetAllAppServices() []*v1.AppService {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetAllAppServices")
|
||||
ret0, _ := ret[0].([]*v1.AppService)
|
||||
return ret0
|
||||
@ -103,11 +114,13 @@ func (m *MockStorer) GetAllAppServices() []*v1.AppService {
|
||||
|
||||
// GetAllAppServices indicates an expected call of GetAllAppServices
|
||||
func (mr *MockStorerMockRecorder) GetAllAppServices() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllAppServices", reflect.TypeOf((*MockStorer)(nil).GetAllAppServices))
|
||||
}
|
||||
|
||||
// GetAppServiceStatus mocks base method
|
||||
func (m *MockStorer) GetAppServiceStatus(serviceID string) string {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetAppServiceStatus", serviceID)
|
||||
ret0, _ := ret[0].(string)
|
||||
return ret0
|
||||
@ -115,11 +128,13 @@ func (m *MockStorer) GetAppServiceStatus(serviceID string) string {
|
||||
|
||||
// GetAppServiceStatus indicates an expected call of GetAppServiceStatus
|
||||
func (mr *MockStorerMockRecorder) GetAppServiceStatus(serviceID interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAppServiceStatus", reflect.TypeOf((*MockStorer)(nil).GetAppServiceStatus), serviceID)
|
||||
}
|
||||
|
||||
// GetAppServicesStatus mocks base method
|
||||
func (m *MockStorer) GetAppServicesStatus(serviceIDs []string) map[string]string {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetAppServicesStatus", serviceIDs)
|
||||
ret0, _ := ret[0].(map[string]string)
|
||||
return ret0
|
||||
@ -127,11 +142,13 @@ func (m *MockStorer) GetAppServicesStatus(serviceIDs []string) map[string]string
|
||||
|
||||
// GetAppServicesStatus indicates an expected call of GetAppServicesStatus
|
||||
func (mr *MockStorerMockRecorder) GetAppServicesStatus(serviceIDs interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAppServicesStatus", reflect.TypeOf((*MockStorer)(nil).GetAppServicesStatus), serviceIDs)
|
||||
}
|
||||
|
||||
// GetTenantResource mocks base method
|
||||
func (m *MockStorer) GetTenantResource(tenantID string) *v1.TenantResource {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetTenantResource", tenantID)
|
||||
ret0, _ := ret[0].(*v1.TenantResource)
|
||||
return ret0
|
||||
@ -139,11 +156,13 @@ func (m *MockStorer) GetTenantResource(tenantID string) *v1.TenantResource {
|
||||
|
||||
// GetTenantResource indicates an expected call of GetTenantResource
|
||||
func (mr *MockStorerMockRecorder) GetTenantResource(tenantID interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTenantResource", reflect.TypeOf((*MockStorer)(nil).GetTenantResource), tenantID)
|
||||
}
|
||||
|
||||
// GetTenantRunningApp mocks base method
|
||||
func (m *MockStorer) GetTenantRunningApp(tenantID string) []*v1.AppService {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetTenantRunningApp", tenantID)
|
||||
ret0, _ := ret[0].([]*v1.AppService)
|
||||
return ret0
|
||||
@ -151,11 +170,13 @@ func (m *MockStorer) GetTenantRunningApp(tenantID string) []*v1.AppService {
|
||||
|
||||
// GetTenantRunningApp indicates an expected call of GetTenantRunningApp
|
||||
func (mr *MockStorerMockRecorder) GetTenantRunningApp(tenantID interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTenantRunningApp", reflect.TypeOf((*MockStorer)(nil).GetTenantRunningApp), tenantID)
|
||||
}
|
||||
|
||||
// GetNeedBillingStatus mocks base method
|
||||
func (m *MockStorer) GetNeedBillingStatus(serviceIDs []string) map[string]string {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetNeedBillingStatus", serviceIDs)
|
||||
ret0, _ := ret[0].(map[string]string)
|
||||
return ret0
|
||||
@ -163,21 +184,25 @@ func (m *MockStorer) GetNeedBillingStatus(serviceIDs []string) map[string]string
|
||||
|
||||
// GetNeedBillingStatus indicates an expected call of GetNeedBillingStatus
|
||||
func (mr *MockStorerMockRecorder) GetNeedBillingStatus(serviceIDs interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetNeedBillingStatus", reflect.TypeOf((*MockStorer)(nil).GetNeedBillingStatus), serviceIDs)
|
||||
}
|
||||
|
||||
// OnDelete mocks base method
|
||||
func (m *MockStorer) OnDelete(obj interface{}) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "OnDelete", obj)
|
||||
}
|
||||
|
||||
// OnDelete indicates an expected call of OnDelete
|
||||
func (mr *MockStorerMockRecorder) OnDelete(obj interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "OnDelete", reflect.TypeOf((*MockStorer)(nil).OnDelete), obj)
|
||||
}
|
||||
|
||||
// GetPodLister mocks base method
|
||||
func (m *MockStorer) GetPodLister() v11.PodLister {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetPodLister")
|
||||
ret0, _ := ret[0].(v11.PodLister)
|
||||
return ret0
|
||||
@ -185,31 +210,37 @@ func (m *MockStorer) GetPodLister() v11.PodLister {
|
||||
|
||||
// GetPodLister indicates an expected call of GetPodLister
|
||||
func (mr *MockStorerMockRecorder) GetPodLister() *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPodLister", reflect.TypeOf((*MockStorer)(nil).GetPodLister))
|
||||
}
|
||||
|
||||
// RegistPodUpdateListener mocks base method
|
||||
func (m *MockStorer) RegistPodUpdateListener(arg0 string, arg1 chan<- *v10.Pod) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "RegistPodUpdateListener", arg0, arg1)
|
||||
}
|
||||
|
||||
// RegistPodUpdateListener indicates an expected call of RegistPodUpdateListener
|
||||
func (mr *MockStorerMockRecorder) RegistPodUpdateListener(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegistPodUpdateListener", reflect.TypeOf((*MockStorer)(nil).RegistPodUpdateListener), arg0, arg1)
|
||||
}
|
||||
|
||||
// UnRegistPodUpdateListener mocks base method
|
||||
func (m *MockStorer) UnRegistPodUpdateListener(arg0 string) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "UnRegistPodUpdateListener", arg0)
|
||||
}
|
||||
|
||||
// UnRegistPodUpdateListener indicates an expected call of UnRegistPodUpdateListener
|
||||
func (mr *MockStorerMockRecorder) UnRegistPodUpdateListener(arg0 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UnRegistPodUpdateListener", reflect.TypeOf((*MockStorer)(nil).UnRegistPodUpdateListener), arg0)
|
||||
}
|
||||
|
||||
// InitOneThirdPartService mocks base method
|
||||
func (m *MockStorer) InitOneThirdPartService(service *model.TenantServices) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "InitOneThirdPartService", service)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
@ -217,5 +248,6 @@ func (m *MockStorer) InitOneThirdPartService(service *model.TenantServices) erro
|
||||
|
||||
// InitOneThirdPartService indicates an expected call of InitOneThirdPartService
|
||||
func (mr *MockStorerMockRecorder) InitOneThirdPartService(service interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "InitOneThirdPartService", reflect.TypeOf((*MockStorer)(nil).InitOneThirdPartService), service)
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
v2beta1 "k8s.io/api/autoscaling/v2beta1"
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/eapache/channels"
|
||||
"github.com/goodrain/rainbond/cmd/worker/option"
|
||||
@ -538,6 +539,21 @@ func (a *appRuntimeStore) OnAdd(obj interface{}) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if hpa, ok := obj.(*v2beta1.HorizontalPodAutoscaler); ok {
|
||||
serviceID := hpa.Labels["service_id"]
|
||||
version := hpa.Labels["version"]
|
||||
createrID := hpa.Labels["creater_id"]
|
||||
if serviceID != "" && version != "" && createrID != "" {
|
||||
appservice, err := a.getAppService(serviceID, version, createrID, true)
|
||||
if err == conversion.ErrServiceNotFound {
|
||||
a.conf.KubeClient.AutoscalingV2beta1().HorizontalPodAutoscalers(hpa.GetNamespace()).Delete(hpa.GetName(), &metav1.DeleteOptions{})
|
||||
}
|
||||
if appservice != nil {
|
||||
appservice.SetHPA(hpa)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//getAppService if creater is true, will create new app service where not found in store
|
||||
@ -664,6 +680,21 @@ func (a *appRuntimeStore) OnDelete(obj interface{}) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if hpa, ok := obj.(*v2beta1.HorizontalPodAutoscaler); ok {
|
||||
serviceID := hpa.Labels["service_id"]
|
||||
version := hpa.Labels["version"]
|
||||
createrID := hpa.Labels["creater_id"]
|
||||
if serviceID != "" && version != "" && createrID != "" {
|
||||
appservice, _ := a.getAppService(serviceID, version, createrID, false)
|
||||
if appservice != nil {
|
||||
appservice.DelHPA(hpa)
|
||||
if appservice.IsClosed() {
|
||||
a.DeleteAppService(appservice)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//RegistAppService regist a app model to store.
|
||||
|
@ -24,12 +24,14 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
v1 "k8s.io/api/apps/v1"
|
||||
v2beta1 "k8s.io/api/autoscaling/v2beta1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
extensions "k8s.io/api/extensions/v1beta1"
|
||||
|
||||
"github.com/goodrain/rainbond/builder"
|
||||
"github.com/goodrain/rainbond/db/model"
|
||||
"github.com/goodrain/rainbond/event"
|
||||
v1 "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
extensions "k8s.io/api/extensions/v1beta1"
|
||||
)
|
||||
|
||||
// EventType type of event
|
||||
@ -101,6 +103,7 @@ type AppService struct {
|
||||
tenant *corev1.Namespace
|
||||
statefulset *v1.StatefulSet
|
||||
deployment *v1.Deployment
|
||||
hpas []*v2beta1.HorizontalPodAutoscaler
|
||||
replicasets []*v1.ReplicaSet
|
||||
services []*corev1.Service
|
||||
delServices []*corev1.Service
|
||||
@ -550,6 +553,42 @@ func (a *AppService) DistinguishPod(pod *corev1.Pod) bool {
|
||||
return !pod.ObjectMeta.CreationTimestamp.Before(&rss.ObjectMeta.CreationTimestamp)
|
||||
}
|
||||
|
||||
// SetHPAs -
|
||||
func (a *AppService) SetHPAs(hpas []*v2beta1.HorizontalPodAutoscaler) {
|
||||
a.hpas = hpas
|
||||
}
|
||||
|
||||
// SetHPA -
|
||||
func (a *AppService) SetHPA(hpa *v2beta1.HorizontalPodAutoscaler) {
|
||||
if len(a.hpas) > 0 {
|
||||
for i, old := range a.hpas {
|
||||
if old.GetName() == hpa.GetName() {
|
||||
a.hpas[i] = hpa
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
a.hpas = append(a.hpas, hpa)
|
||||
}
|
||||
|
||||
// GetHPAs -
|
||||
func (a *AppService) GetHPAs() []*v2beta1.HorizontalPodAutoscaler {
|
||||
return a.hpas
|
||||
}
|
||||
|
||||
// DelHPA -
|
||||
func (a *AppService) DelHPA(hpa *v2beta1.HorizontalPodAutoscaler) {
|
||||
if len(a.hpas) == 0 {
|
||||
return
|
||||
}
|
||||
for i, old := range a.hpas {
|
||||
if old.GetName() == hpa.GetName() {
|
||||
a.hpas = append(a.hpas[0:i], a.hpas[i+1:]...)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *AppService) String() string {
|
||||
return fmt.Sprintf(`
|
||||
-----------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user