Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: removes vinterface vtap_id/netns_id field #7854

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions server/controller/cloud/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,6 @@ type VInterface struct {
NetworkLcuuid string `json:"network_lcuuid"`
VPCLcuuid string `json:"vpc_lcuuid"` // TODO not used
RegionLcuuid string `json:"region_lcuuid" binding:"required"`
NetnsID uint32 `json:"netns_id"`
VTapID uint32 `json:"vtap_id" binding:"required"`
SubDomainLcuuid string `json:"sub_domain_lcuuid"`
}

Expand Down
2 changes: 0 additions & 2 deletions server/controller/db/mysql/migration/rawsql/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,6 @@ CREATE TABLE IF NOT EXISTS vinterface (
vlantag INTEGER DEFAULT 0,
devicetype INTEGER COMMENT 'Type 0.unknown 1.vm 2.vgw 3.third-party-device 4.vmwaf 5.NSP-vgateway 6.host-device 7.network-device 9.DHCP-port 10.pod 11.pod_service 12. redis_instance 13. rds_instance 14. pod_node 15. load_balance 16. nat_gateway',
deviceid INTEGER COMMENT 'unknown: Senseless ID, vm: vm ID, vgw/NSP-vgateway: vnet ID, third-party-device: third_party_device ID, vmwaf: vmwaf ID, host-device: host_device ID, network-device: network_device ID',
netns_id INTEGER UNSIGNED DEFAULT 0,
vtap_id INTEGER DEFAULT 0,
sub_domain CHAR(64) DEFAULT '',
domain CHAR(64) DEFAULT '',
region CHAR(64) DEFAULT '',
Expand Down
36 changes: 36 additions & 0 deletions server/controller/db/mysql/migration/rawsql/issu/6.6.1.10.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-- modify start, add upgrade sql
DROP PROCEDURE IF EXISTS BakColumn;

CREATE PROCEDURE BakColumn(
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_SCHEMA = DATABASE()
AND TABLE_NAME = tableName
AND column_name = colName;

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

CALL BakColumn('vinterface', 'netns_id', 'INTEGER UNSIGNED DEFAULT 0');
CALL BakColumn('vinterface', 'vtap_id', 'INTEGER DEFAULT 0');

DROP PROCEDURE BakColumn;

-- update db_version to latest, remeber update DB_VERSION_EXPECT in migrate/init.go
UPDATE db_version SET version='6.6.1.10';
-- 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.6.1.9"
DB_VERSION_EXPECTED = "6.6.1.10"
)
2 changes: 0 additions & 2 deletions server/controller/db/mysql/platform_rsc_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,6 @@ type VInterface struct {
VlanTag int `gorm:"column:vlantag;type:int;default:0" json:"VLANTAG" mapstructure:"VLANTAG"`
DeviceType int `gorm:"column:devicetype;type:int;default:null" json:"DEVICE_TYPE" mapstructure:"DEVICE_TYPE"` // Type 0.unknown 1.vm 2.vgw 3.third-party-device 4.vmwaf 5.NSP-vgateway 6.host-device 7.network-device 9.DHCP-port 10.pod 11.pod_service 12. redis_instance 13. rds_instance 14. pod_node 15. load_balance 16. nat_gateway
DeviceID int `gorm:"column:deviceid;type:int;default:null" json:"DEVICE_ID" mapstructure:"DEVICE_ID"` // unknown: Senseless ID, vm: vm ID, vgw/NSP-vgateway: vnet ID, third-party-device: third_party_device ID, vmwaf: vmwaf ID, host-device: host_device ID, network-device: network_device ID
NetnsID uint32 `gorm:"column:netns_id;type:int unsigned;default:0" json:"NETNS_ID" mapstructure:"NETNS_ID"` // used to associate processes with cloud and container resources
VtapID uint32 `gorm:"column:vtap_id;type:int;default:0" json:"VTAP_ID" mapstructure:"VTAP_ID"`
SubDomain string `gorm:"column:sub_domain;type:char(64);default:''" json:"SUB_DOMAIN" mapstructure:"SUB_DOMAIN"`
Domain string `gorm:"column:domain;type:char(64);not null" json:"DOMAIN" mapstructure:"DOMAIN"`
Region string `gorm:"column:region;type:char(64);default:''" json:"REGION" mapstructure:"REGION"`
Expand Down
6 changes: 0 additions & 6 deletions server/controller/recorder/cache/diffbase/vinterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ func (b *DataSet) AddVInterface(dbItem *mysql.VInterface, seq int, toolDataSet *
},
Name: dbItem.Name,
Type: dbItem.Type,
VtapID: dbItem.VtapID,
NetnsID: dbItem.NetnsID,
TapMac: dbItem.TapMac,
DeviceType: dbItem.DeviceType,
DeviceLcuuid: deviceLcuuid,
Expand All @@ -61,8 +59,6 @@ type VInterface struct {
Name string `json:"name"`
Type int `json:"type"`
TapMac string `json:"tap_mac"`
NetnsID uint32 `json:"netns_id"`
VtapID uint32 `json:"vtap_id"`
DeviceType int `json:"device_type"`
DeviceLcuuid string `json:"device_lcuuid"`
NetworkLcuuid string `json:"network_lcuuid"`
Expand All @@ -74,8 +70,6 @@ func (v *VInterface) Update(cloudItem *cloudmodel.VInterface) {
v.Name = cloudItem.Name
v.Type = cloudItem.Type
v.TapMac = cloudItem.TapMac
v.NetnsID = cloudItem.NetnsID
v.VtapID = cloudItem.VTapID
v.DeviceLcuuid = cloudItem.DeviceLcuuid
v.NetworkLcuuid = cloudItem.NetworkLcuuid
v.RegionLcuuid = cloudItem.RegionLcuuid
Expand Down
2 changes: 0 additions & 2 deletions server/controller/recorder/pubsub/message/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,6 @@ type VInterfaceFieldsUpdate struct {
Name fieldDetail[string]
TapMac fieldDetail[string]
Type fieldDetail[int]
NetnsID fieldDetail[uint32]
VTapID fieldDetail[uint32]
NetworkID fieldDetail[int]
NetworkLcuuid fieldDetail[string]
RegionLcuuid fieldDetail[string]
Expand Down
10 changes: 0 additions & 10 deletions server/controller/recorder/updater/vinterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ func (i *VInterface) generateDBItemToAdd(cloudItem *cloudmodel.VInterface) (*mys
SubDomain: cloudItem.SubDomainLcuuid,
Domain: i.metadata.Domain.Lcuuid,
Region: cloudItem.RegionLcuuid,
NetnsID: cloudItem.NetnsID,
VtapID: cloudItem.VTapID,
}
dbItem.Lcuuid = cloudItem.Lcuuid
return dbItem, true
Expand Down Expand Up @@ -178,13 +176,5 @@ func (i *VInterface) generateUpdateInfo(diffBase *diffbase.VInterface, cloudItem
mapInfo["iftype"] = cloudItem.Type
structInfo.Type.Set(diffBase.Type, cloudItem.Type)
}
if diffBase.NetnsID != cloudItem.NetnsID {
mapInfo["netns_id"] = cloudItem.NetnsID
structInfo.NetnsID.Set(diffBase.NetnsID, cloudItem.NetnsID)
}
if diffBase.VtapID != cloudItem.VTapID {
mapInfo["vtap_id"] = cloudItem.VTapID
structInfo.VTapID.Set(diffBase.VtapID, cloudItem.VTapID)
}
return structInfo, mapInfo, len(mapInfo) > 0
}
Loading