Skip to content

Commit

Permalink
Merge pull request #652 from l1b0k/fix/clean
Browse files Browse the repository at this point in the history
remove deprecated codes
  • Loading branch information
BSWANG authored Jul 23, 2024
2 parents 8ed3bef + 8adcc66 commit 9215f53
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 124 deletions.
11 changes: 0 additions & 11 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,17 +742,6 @@ func initTrunk(config *daemon.Config, poolConfig *types.PoolConfig, k8sClient k8
// get eni id form node annotation
preferTrunkID := k8sClient.GetTrunkID()

if config.WaitTrunkENI {
// at this mode , we retreat id ONLY by node annotation
if preferTrunkID == "" {
preferTrunkID, err = k8sClient.WaitTrunkReady()
if err != nil {
return "", fmt.Errorf("error wait trunk ready, %w", err)
}
}
return preferTrunkID, nil
}

// already exclude the primary eni
enis, err := f.GetAttachedNetworkInterface(preferTrunkID)
if err != nil {
Expand Down
41 changes: 0 additions & 41 deletions daemon/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,47 +199,6 @@ func Test_initTrunk(t *testing.T) {
},
want: "",
wantErr: assert.NoError,
}, {
name: "enable wait trunk ready",
args: args{
config: &daemon.Config{
IPStack: "dual",
EnableENITrunking: true,
EnableERDMA: true,
WaitTrunkENI: true,
},
poolConfig: &types.PoolConfig{
MaxENI: 2,
},
k8sClient: k8smocks.NewKubernetes(t),
f: factorymocks.NewFactory(t),
},
preStart: func(args args) {
args.k8sClient.On("GetTrunkID").Return("eni-1")
},
want: "eni-1",
wantErr: assert.NoError,
}, {
name: "enable wait trunk ready, get from remote",
args: args{
config: &daemon.Config{
IPStack: "dual",
EnableENITrunking: true,
EnableERDMA: true,
WaitTrunkENI: true,
},
poolConfig: &types.PoolConfig{
MaxENI: 2,
},
k8sClient: k8smocks.NewKubernetes(t),
f: factorymocks.NewFactory(t),
},
preStart: func(args args) {
args.k8sClient.On("GetTrunkID").Return("")
args.k8sClient.On("WaitTrunkReady").Return("eni-1", nil)
},
want: "eni-1",
wantErr: assert.NoError,
},
}
for _, tt := range tests {
Expand Down
1 change: 0 additions & 1 deletion pkg/aliyun/client/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const (
)

const (
eniNamePrefix = "eni-cni-"
eniDescription = "interface create by terway"
maxSinglePageSize = 500
)
Expand Down
5 changes: 0 additions & 5 deletions pkg/controller/common/ctx_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@ import (
"context"

"github.com/AliyunContainerService/terway/pkg/apis/network.alibabacloud.com/v1beta1"
register "github.com/AliyunContainerService/terway/pkg/controller"
)

// WithCtx extract fields from v1beta1.Allocation and set to context.Context
func WithCtx(ctx context.Context, alloc *v1beta1.Allocation) context.Context {
return ctx
}

func Became(ctx context.Context, aliyun register.Interface) (register.Interface, bool, error) {
return aliyun, false, nil
}
11 changes: 1 addition & 10 deletions pkg/controller/pod/pod_controller_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"

"github.com/AliyunContainerService/terway/pkg/apis/network.alibabacloud.com/v1beta1"
"github.com/AliyunContainerService/terway/pkg/controller/common"
"github.com/AliyunContainerService/terway/pkg/vswitch"
"github.com/AliyunContainerService/terway/types/controlplane"
)
Expand Down Expand Up @@ -37,15 +36,7 @@ func (m *ReconcilePod) ParsePodNetworksFromAnnotation(ctx context.Context, zoneI
ExtraConfig: map[string]string{},
}

ctx := common.WithCtx(ctx, alloc)

// allow config route without
realClient, _, err := common.Became(ctx, m.aliyun)
if err != nil {
return nil, err
}

sw, err := m.swPool.GetOne(ctx, realClient, zoneID, c.VSwitchOptions, &vswitch.SelectOptions{
sw, err := m.swPool.GetOne(ctx, m.aliyun, zoneID, c.VSwitchOptions, &vswitch.SelectOptions{
IgnoreZone: false,
})
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion plugin/terway/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
const (
defaultSocketPath = "/var/run/eni/eni.socket"
defaultVethPrefix = "cali"
defaultDialTimeout = 10 * time.Second
defaultCniTimeout = 120 * time.Second
defaultEventTimeout = 10 * time.Second
delegateIpam = "host-local"
Expand Down
47 changes: 20 additions & 27 deletions types/daemon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,26 @@ var addonSecretRootPath = addonSecretPath

// Config configuration of terway daemon
type Config struct {
Version string `yaml:"version" json:"version"`
AccessID secret.Secret `yaml:"access_key" json:"access_key"`
AccessSecret secret.Secret `yaml:"access_secret" json:"access_secret"`
RegionID string `yaml:"region_id" json:"region_id"`
CredentialPath string `yaml:"credential_path" json:"credential_path"`
ServiceCIDR string `yaml:"service_cidr" json:"service_cidr"`
VSwitches map[string][]string `yaml:"vswitches" json:"vswitches"`
ENITags map[string]string `yaml:"eni_tags" json:"eni_tags"`
MaxPoolSize int `yaml:"max_pool_size" json:"max_pool_size"`
MinPoolSize int `yaml:"min_pool_size" json:"min_pool_size"`
MinENI int `yaml:"min_eni" json:"min_eni"`
MaxENI int `yaml:"max_eni" json:"max_eni"`
Prefix string `yaml:"prefix" json:"prefix"`
SecurityGroup string `yaml:"security_group" json:"security_group"`
SecurityGroups []string `yaml:"security_groups" json:"security_groups"`
EniCapRatio float64 `yaml:"eni_cap_ratio" json:"eni_cap_ratio" mod:"default=1"`
EniCapShift int `yaml:"eni_cap_shift" json:"eni_cap_shift"`
VSwitchSelectionPolicy string `yaml:"vswitch_selection_policy" json:"vswitch_selection_policy" mod:"default=random"`
EniSelectionPolicy string `yaml:"eni_selection_policy" json:"eni_selection_policy" mod:"default=most_ips"`
EnableEIPPool string `yaml:"enable_eip_pool" json:"enable_eip_pool"`
// deprecated
EnableEIPMigrate bool `yaml:"enable_eip_migrate" json:"enable_eip_migrate"`
IPStack string `yaml:"ip_stack" json:"ip_stack" validate:"oneof=ipv4 ipv6 dual" mod:"default=ipv4"` // default ipv4 , support ipv4 dual
// rob the eip instance even the eip already bound to other resource
AllowEIPRob string `yaml:"allow_eip_rob" json:"allow_eip_rob"`
Version string `yaml:"version" json:"version"`
AccessID secret.Secret `yaml:"access_key" json:"access_key"`
AccessSecret secret.Secret `yaml:"access_secret" json:"access_secret"`
RegionID string `yaml:"region_id" json:"region_id"`
CredentialPath string `yaml:"credential_path" json:"credential_path"`
ServiceCIDR string `yaml:"service_cidr" json:"service_cidr"`
VSwitches map[string][]string `yaml:"vswitches" json:"vswitches"`
ENITags map[string]string `yaml:"eni_tags" json:"eni_tags"`
MaxPoolSize int `yaml:"max_pool_size" json:"max_pool_size"`
MinPoolSize int `yaml:"min_pool_size" json:"min_pool_size"`
MinENI int `yaml:"min_eni" json:"min_eni"`
MaxENI int `yaml:"max_eni" json:"max_eni"`
Prefix string `yaml:"prefix" json:"prefix"`
SecurityGroup string `yaml:"security_group" json:"security_group"`
SecurityGroups []string `yaml:"security_groups" json:"security_groups"`
EniCapRatio float64 `yaml:"eni_cap_ratio" json:"eni_cap_ratio" mod:"default=1"`
EniCapShift int `yaml:"eni_cap_shift" json:"eni_cap_shift"`
VSwitchSelectionPolicy string `yaml:"vswitch_selection_policy" json:"vswitch_selection_policy" mod:"default=random"`
EniSelectionPolicy string `yaml:"eni_selection_policy" json:"eni_selection_policy" mod:"default=most_ips"`
IPStack string `yaml:"ip_stack" json:"ip_stack" validate:"oneof=ipv4 ipv6 dual" mod:"default=ipv4"` // default ipv4 , support ipv4 dual
EnableENITrunking bool `yaml:"enable_eni_trunking" json:"enable_eni_trunking"`
EnableERDMA bool `yaml:"enable_erdma" json:"enable_erdma"`
CustomStatefulWorkloadKinds []string `yaml:"custom_stateful_workload_kinds" json:"custom_stateful_workload_kinds"`
Expand All @@ -59,9 +54,7 @@ type Config struct {
BackoffOverride map[string]wait.Backoff `json:"backoff_override,omitempty"`
ExtraRoutes []route.Route `json:"extra_routes,omitempty"`
DisableDevicePlugin bool `json:"disable_device_plugin"`
WaitTrunkENI bool `json:"wait_trunk_eni"` // true for don't create trunk eni
ENITagFilter map[string]string `json:"eni_tag_filter"` // if set , only enis match filter, will be managed
DisableSecurityGroupCheck bool `json:"disable_security_group_check"`
KubeClientQPS float32 `json:"kube_client_qps"`
KubeClientBurst int `json:"kube_client_burst"`
ResourceGroupID string `json:"resource_group_id"`
Expand Down
28 changes: 0 additions & 28 deletions types/daemon/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ const (
// DEPRECATED
type InternetChargeType string

// EIP pay type
const (
PayByBandwidth = InternetChargeType("PayByBandwidth")
PayByTraffic = InternetChargeType("PayByTraffic")
)

// network resource type
const (
ResourceTypeVeth = "veth"
Expand Down Expand Up @@ -165,25 +159,3 @@ const (
ResStatusIdle
ResStatusInUse
)

// FakeRes for test
type FakeRes struct {
ID string
Type string
Status ResStatus
}

// GetID GetID
func (r *FakeRes) GetID() string {
return r.ID
}

// GetType GetType
func (r *FakeRes) GetType() string {
return r.Type
}

// GetStatus GetStatus
func (r *FakeRes) GetStatus() ResStatus {
return r.Status
}

0 comments on commit 9215f53

Please sign in to comment.