diff --git a/cli/go.mod b/cli/go.mod index 63bb14a08fe..a29f6cbc681 100644 --- a/cli/go.mod +++ b/cli/go.mod @@ -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 diff --git a/cli/go.sum b/cli/go.sum index caa08bcca52..8f4d9d20284 100644 --- a/cli/go.sum +++ b/cli/go.sum @@ -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= diff --git a/server/controller/common/vtap_config.go b/server/controller/common/vtap_config.go index d684439dcd9..0e4b3f3b5d4 100644 --- a/server/controller/common/vtap_config.go +++ b/server/controller/common/vtap_config.go @@ -25,6 +25,7 @@ var DefaultVTapGroupConfig = &mysql.VTapGroupConfiguration{ MaxNpbBps: &DefaultMaxNpbBps, MaxCPUs: &DefaultMaxCPUs, MaxMemory: &DefaultMaxMemory, + PlatformSyncInterval: &DefaultPlatformSyncInterval, SyncInterval: &DefaultSyncInterval, StatsInterval: &DefaultStatsInterval, RsyslogEnabled: &DefaultRsyslogEnabled, @@ -95,6 +96,7 @@ var ( DefaultMaxNpbBps = int64(1000000000) DefaultMaxCPUs = 1 DefaultMaxMemory = 768 + DefaultPlatformSyncInterval = 10 DefaultSyncInterval = 60 DefaultStatsInterval = 10 DefaultRsyslogEnabled = 1 diff --git a/server/controller/db/mysql/migration/rawsql/init.sql b/server/controller/db/mysql/migration/rawsql/init.sql index 599503946c0..5fd9963733e 100644 --- a/server/controller/db/mysql/migration/rawsql/init.sql +++ b/server/controller/db/mysql/migration/rawsql/init.sql @@ -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', diff --git a/server/controller/db/mysql/migration/rawsql/issu/6.5.1.14.sql b/server/controller/db/mysql/migration/rawsql/issu/6.5.1.14.sql index 4abe02039d1..b279abd1fa8 100644 --- a/server/controller/db/mysql/migration/rawsql/issu/6.5.1.14.sql +++ b/server/controller/db/mysql/migration/rawsql/issu/6.5.1.14.sql @@ -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) @@ -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; -- 如果列不存在,则添加列 @@ -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; diff --git a/server/controller/db/mysql/migration/rawsql/issu/6.5.1.16.sql b/server/controller/db/mysql/migration/rawsql/issu/6.5.1.16.sql new file mode 100644 index 00000000000..66883927e62 --- /dev/null +++ b/server/controller/db/mysql/migration/rawsql/issu/6.5.1.16.sql @@ -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 diff --git a/server/controller/db/mysql/migration/version.go b/server/controller/db/mysql/migration/version.go index 5181eb908c5..0b00c19624e 100644 --- a/server/controller/db/mysql/migration/version.go +++ b/server/controller/db/mysql/migration/version.go @@ -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" ) diff --git a/server/controller/db/mysql/model.go b/server/controller/db/mysql/model.go index bf70e91e252..7a40a2e01f1 100644 --- a/server/controller/db/mysql/model.go +++ b/server/controller/db/mysql/model.go @@ -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 @@ -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 diff --git a/server/controller/model/agent_group_config_example.yaml b/server/controller/model/agent_group_config_example.yaml index ea15982f5d2..a61e6655acf 100644 --- a/server/controller/model/agent_group_config_example.yaml +++ b/server/controller/model/agent_group_config_example.yaml @@ -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 diff --git a/server/controller/model/model.go b/server/controller/model/model.go index 458d98ad38d..485f754e3d0 100644 --- a/server/controller/model/model.go +++ b/server/controller/model/model.go @@ -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"` @@ -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"` diff --git a/server/controller/trisolaris/services/grpc/synchronize/vtap.go b/server/controller/trisolaris/services/grpc/synchronize/vtap.go index c1e9a7d7b5e..15366e8e186 100644 --- a/server/controller/trisolaris/services/grpc/synchronize/vtap.go +++ b/server/controller/trisolaris/services/grpc/synchronize/vtap.go @@ -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)), @@ -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)), diff --git a/server/go.mod b/server/go.mod index 5c3f2c1372c..ab9dc276820 100644 --- a/server/go.mod +++ b/server/go.mod @@ -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 diff --git a/server/go.sum b/server/go.sum index 3ad2abdbd6f..9eaf5e5cb0c 100644 --- a/server/go.sum +++ b/server/go.sum @@ -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=