Skip to content

Commit

Permalink
[Server] add agent config platform_sync_interval
Browse files Browse the repository at this point in the history
  • Loading branch information
roryye authored and SongZhen0704 committed Mar 27, 2024
1 parent 89dc540 commit bc0c8c9
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/bitly/go-simplejson v0.5.0
github.com/deepflowio/deepflow/message v0.0.0-20240319084950-7d53b9e423a6
github.com/deepflowio/deepflow/message v0.0.0-20240326080456-66b3b064e7ba
github.com/deepflowio/deepflow/server v0.0.0-20240313030613-182e7a10446e
github.com/golang/protobuf v1.5.4
github.com/mattn/go-runewidth v0.0.14
Expand Down
4 changes: 2 additions & 2 deletions cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deepflowio/deepflow/message v0.0.0-20240319084950-7d53b9e423a6 h1:5WistHmNO+rW26S1F+4UjgCkxesOTArmJIvzO0JyIJ4=
github.com/deepflowio/deepflow/message v0.0.0-20240319084950-7d53b9e423a6/go.mod h1:e+1lUMMlycCvFRKvlwt/y/0vxJnF8wVss3GyR1ARXY0=
github.com/deepflowio/deepflow/message v0.0.0-20240326080456-66b3b064e7ba h1:X86JI74O4jmWozXi88Y+ZGHO6+7k9uGJfQ+vpHuU64Q=
github.com/deepflowio/deepflow/message v0.0.0-20240326080456-66b3b064e7ba/go.mod h1:e+1lUMMlycCvFRKvlwt/y/0vxJnF8wVss3GyR1ARXY0=
github.com/deepflowio/deepflow/server v0.0.0-20240313030613-182e7a10446e h1:ce91uCvubflSBxbKDKan8s9OrOVa/CFzc/lcWTHRPYc=
github.com/deepflowio/deepflow/server v0.0.0-20240313030613-182e7a10446e/go.mod h1:63gxmwUixOVeTT0G37/dvdavSwicaa1ytitmDF9XvvI=
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
Expand Down
2 changes: 2 additions & 0 deletions server/controller/common/vtap_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var DefaultVTapGroupConfig = &mysql.VTapGroupConfiguration{
MaxNpbBps: &DefaultMaxNpbBps,
MaxCPUs: &DefaultMaxCPUs,
MaxMemory: &DefaultMaxMemory,
PlatformSyncInterval: &DefaultPlatformSyncInterval,
SyncInterval: &DefaultSyncInterval,
StatsInterval: &DefaultStatsInterval,
RsyslogEnabled: &DefaultRsyslogEnabled,
Expand Down Expand Up @@ -95,6 +96,7 @@ var (
DefaultMaxNpbBps = int64(1000000000)
DefaultMaxCPUs = 1
DefaultMaxMemory = 768
DefaultPlatformSyncInterval = 10
DefaultSyncInterval = 60
DefaultStatsInterval = 10
DefaultRsyslogEnabled = 1
Expand Down
1 change: 1 addition & 0 deletions server/controller/db/mysql/migration/rawsql/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,7 @@ CREATE TABLE IF NOT EXISTS vtap_group_configuration(
max_npb_bps BIGINT DEFAULT NULL COMMENT 'unit: bps',
max_cpus INTEGER DEFAULT NULL,
max_memory INTEGER DEFAULT NULL COMMENT 'unit: M',
platform_sync_interval INTEGER DEFAULT NULL,
sync_interval INTEGER DEFAULT NULL,
stats_interval INTEGER,
rsyslog_enabled TINYINT(1) COMMENT '0: disabled 1: enabled',
Expand Down
10 changes: 4 additions & 6 deletions server/controller/db/mysql/migration/rawsql/issu/6.5.1.14.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
DROP PROCEDURE IF EXISTS AddColumnIfNotExists;

CREATE PROCEDURE AddColumnIfNotExists(
IN dbName VARCHAR(255),
IN tableName VARCHAR(255),
IN colName VARCHAR(255),
IN colType VARCHAR(255)
Expand All @@ -14,8 +13,7 @@ BEGIN
SELECT COUNT(*)
INTO column_count
FROM information_schema.columns
WHERE table_schema = dbName
AND table_name = tableName
WHERE table_name = tableName
AND column_name = colName;

-- 如果列不存在,则添加列
Expand All @@ -27,9 +25,9 @@ BEGIN
END IF;
END;

CALL AddColumnIfNotExists('deepflow', 'vtap_group_configuration', 'system_load_circuit_breaker_threshold', 'float(8,2)');
CALL AddColumnIfNotExists('deepflow', 'vtap_group_configuration', 'system_load_circuit_breaker_recover', 'float(8,2)');
CALL AddColumnIfNotExists('deepflow', 'vtap_group_configuration', 'system_load_circuit_breaker_metric', 'CHAR(64)');
CALL AddColumnIfNotExists('vtap_group_configuration', 'system_load_circuit_breaker_threshold', 'float(8,2)');
CALL AddColumnIfNotExists('vtap_group_configuration', 'system_load_circuit_breaker_recover', 'float(8,2)');
CALL AddColumnIfNotExists('vtap_group_configuration', 'system_load_circuit_breaker_metric', 'CHAR(64)');

DROP PROCEDURE AddColumnIfNotExists;

Expand Down
36 changes: 36 additions & 0 deletions server/controller/db/mysql/migration/rawsql/issu/6.5.1.16.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-- modify start, add upgrade sql
DROP PROCEDURE IF EXISTS AddColumnIfNotExists;

CREATE PROCEDURE AddColumnIfNotExists(
IN tableName VARCHAR(255),
IN colName VARCHAR(255),
IN colType VARCHAR(255)
)
BEGIN
DECLARE column_count INT;

-- 检查列是否存在
SELECT COUNT(*)
INTO column_count
FROM information_schema.columns
WHERE table_name = tableName
AND column_name = colName;

-- 如果列不存在,则添加列
IF column_count = 0 THEN
SET @sql = CONCAT('ALTER TABLE ', tableName, ' ADD COLUMN ', colName, ' ', colType, ' DEFAULT NULL AFTER max_memory');
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END IF;
END;

CALL AddColumnIfNotExists('vtap_group_configuration', 'platform_sync_interval', 'INTEGER');

DROP PROCEDURE AddColumnIfNotExists;



-- update db_version to latest, remeber update DB_VERSION_EXPECT in migrate/init.go
UPDATE db_version SET version='6.5.1.16';
-- modify end
2 changes: 1 addition & 1 deletion server/controller/db/mysql/migration/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ package migration

const (
DB_VERSION_TABLE = "db_version"
DB_VERSION_EXPECTED = "6.5.1.15"
DB_VERSION_EXPECTED = "6.5.1.16"
)
2 changes: 2 additions & 0 deletions server/controller/db/mysql/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ type VTapGroupConfiguration struct {
MaxNpbBps *int64 `gorm:"column:max_npb_bps;type:bigint;default:null" json:"MAX_NPB_BPS"` // unit: bps
MaxCPUs *int `gorm:"column:max_cpus;type:int;default:null" json:"MAX_CPUS"`
MaxMemory *int `gorm:"column:max_memory;type:int;default:null" json:"MAX_MEMORY"` // unit: M
PlatformSyncInterval *int `gorm:"column:platform_sync_interval;type:int;default:null" json:"PLATFORM_SYNC_INTERVAL"`
SyncInterval *int `gorm:"column:sync_interval;type:int;default:null" json:"SYNC_INTERVAL"`
StatsInterval *int `gorm:"column:stats_interval;type:int;default:null" json:"STATS_INTERVAL"`
RsyslogEnabled *int `gorm:"column:rsyslog_enabled;type:tinyint(1);default:null" json:"RSYSLOG_ENABLED"` // 0: disabled 1:enabled
Expand Down Expand Up @@ -315,6 +316,7 @@ type RVTapGroupConfiguration struct {
MaxNpbBps int64 `gorm:"column:max_npb_bps;type:bigint;default:null" json:"MAX_NPB_BPS"` // unit: bps
MaxCPUs int `gorm:"column:max_cpus;type:int;default:null" json:"MAX_CPUS"`
MaxMemory int `gorm:"column:max_memory;type:int;default:null" json:"MAX_MEMORY"` // unit: M
PlatformSyncInterval int `gorm:"column:platform_sync_interval;type:int;default:null" json:"PLATFORM_SYNC_INTERVAL"`
SyncInterval int `gorm:"column:sync_interval;type:int;default:null" json:"SYNC_INTERVAL"`
StatsInterval int `gorm:"column:stats_interval;type:int;default:null" json:"STATS_INTERVAL"`
RsyslogEnabled int `gorm:"column:rsyslog_enabled;type:tinyint(1);default:null" json:"RSYSLOG_ENABLED"` // 0: disabled 1:enabled
Expand Down
6 changes: 6 additions & 0 deletions server/controller/model/agent_group_config_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ vtap_group_id: g-xxxxxx
## tag information from deepflow-server.
#sync_interval: 60

## Platform Sync Interval
## Unit: second. Default: 10. Range: [10, 3600]
## Note: The interval at which deepflow-agent actively reports resource information
## to deepflow-server.
#platform_sync_interval: 10

## Maximum Escape Time
## Unit: seconds. Default: 3600. Range: [600, 2592000]
## Note: The maximum time that the agent is allowed to work normally when it
Expand Down
2 changes: 2 additions & 0 deletions server/controller/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ type VTapGroupConfiguration struct {
MaxCPUs *int `json:"MAX_CPUS" yaml:"max_cpus,omitempty"`
MaxMemory *int `json:"MAX_MEMORY" yaml:"max_memory,omitempty"` // unit: M
SyncInterval *int `json:"SYNC_INTERVAL" yaml:"sync_interval,omitempty"`
PlatformSyncInterval *int `json:"PLATFORM_SYNC_INTERVAL" yaml:"platform_sync_interval,omitempty"`
StatsInterval *int `json:"STATS_INTERVAL" yaml:"stats_interval,omitempty"`
RsyslogEnabled *int `json:"RSYSLOG_ENABLED" yaml:"rsyslog_enabled,omitempty"` // 0: disabled 1:enabled
SystemLoadCircuitBreakerThreshold *float32 `json:"SYSTEM_LOAD_CIRCUIT_BREAKER_THRESHOLD" yaml:"system_load_circuit_breaker_threshold,omitempty"`
Expand Down Expand Up @@ -559,6 +560,7 @@ type VTapGroupConfigurationResponse struct {
MaxCPUs *int `json:"MAX_CPUS"`
MaxMemory *int `json:"MAX_MEMORY"` // unit: M
SyncInterval *int `json:"SYNC_INTERVAL"`
PlatformSyncInterval *int `json:"PLATFORM_SYNC_INTERVAL"`
StatsInterval *int `json:"STATS_INTERVAL"`
RsyslogEnabled *int `json:"RSYSLOG_ENABLED"` // 0: disabled 1:enabled
SystemLoadCircuitBreakerThreshold *float32 `json:"SYSTEM_LOAD_CIRCUIT_BREAKER_THRESHOLD"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ func (e *VTapEvent) generateConfigInfo(c *vtap.VTapCache, clusterID string) *api
MaxMemory: proto.Uint32(uint32(vtapConfig.MaxMemory)),
StatsInterval: proto.Uint32(uint32(vtapConfig.StatsInterval)),
SyncInterval: proto.Uint32(uint32(vtapConfig.SyncInterval)),
PlatformSyncInterval: proto.Uint32(uint32(vtapConfig.PlatformSyncInterval)),
NpbBpsThreshold: proto.Uint64(uint64(vtapConfig.MaxNpbBps)),
GlobalPpsThreshold: proto.Uint64(uint64(vtapConfig.MaxCollectPps)),
Mtu: proto.Uint32(uint32(vtapConfig.Mtu)),
Expand Down Expand Up @@ -491,6 +492,7 @@ func (e *VTapEvent) generateNoVTapCacheConfig(groupID string) *api.Config {
MaxMemory: proto.Uint32(uint32(vtapConfig.MaxMemory)),
StatsInterval: proto.Uint32(uint32(vtapConfig.StatsInterval)),
SyncInterval: proto.Uint32(uint32(vtapConfig.SyncInterval)),
PlatformSyncInterval: proto.Uint32(uint32(vtapConfig.PlatformSyncInterval)),
NpbBpsThreshold: proto.Uint64(uint64(vtapConfig.MaxNpbBps)),
GlobalPpsThreshold: proto.Uint64(uint64(vtapConfig.MaxCollectPps)),
Mtu: proto.Uint32(uint32(vtapConfig.Mtu)),
Expand Down
2 changes: 1 addition & 1 deletion server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require (
github.com/cornelk/hashmap v1.0.8
github.com/deckarep/golang-set v1.8.0
github.com/deckarep/golang-set/v2 v2.1.0
github.com/deepflowio/deepflow/message v0.0.0-20240319084950-7d53b9e423a6
github.com/deepflowio/deepflow/message v0.0.0-20240326080456-66b3b064e7ba
github.com/deepflowio/deepflow/server/controller/cloud/kubernetes_gather/expand v0.0.0-00010101000000-000000000000
github.com/deepflowio/deepflow/server/controller/cloud/platform v0.0.0-00010101000000-000000000000
github.com/deepflowio/deepflow/server/controller/cloud/tencent/expand v0.0.0-00010101000000-000000000000
Expand Down
4 changes: 2 additions & 2 deletions server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ github.com/deckarep/golang-set v1.8.0 h1:sk9/l/KqpunDwP7pSjUg0keiOOLEnOBHzykLrsP
github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo=
github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI=
github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4=
github.com/deepflowio/deepflow/message v0.0.0-20240319084950-7d53b9e423a6 h1:5WistHmNO+rW26S1F+4UjgCkxesOTArmJIvzO0JyIJ4=
github.com/deepflowio/deepflow/message v0.0.0-20240319084950-7d53b9e423a6/go.mod h1:e+1lUMMlycCvFRKvlwt/y/0vxJnF8wVss3GyR1ARXY0=
github.com/deepflowio/deepflow/message v0.0.0-20240326080456-66b3b064e7ba h1:X86JI74O4jmWozXi88Y+ZGHO6+7k9uGJfQ+vpHuU64Q=
github.com/deepflowio/deepflow/message v0.0.0-20240326080456-66b3b064e7ba/go.mod h1:e+1lUMMlycCvFRKvlwt/y/0vxJnF8wVss3GyR1ARXY0=
github.com/deepflowio/tempopb v0.0.0-20230215110519-15853baf3a79 h1:erRwXyZiUZxxZX/Q1QHesZXgxjiunZUFy+ggCRimkD4=
github.com/deepflowio/tempopb v0.0.0-20230215110519-15853baf3a79/go.mod h1:h2rkZ319TExIUGuK8a2dlcGd8qc6wdhsrcpXWaJQaQE=
github.com/dennwc/varint v1.0.0 h1:kGNFFSSw8ToIy3obO/kKr8U9GZYUAxQEVuix4zfDWzE=
Expand Down

0 comments on commit bc0c8c9

Please sign in to comment.