Skip to content

Commit

Permalink
update ut and remote deprecated functions
Browse files Browse the repository at this point in the history
Signed-off-by: l1b0k <[email protected]>
  • Loading branch information
l1b0k committed Jan 6, 2025
1 parent 4ab7a38 commit 64c6bc9
Show file tree
Hide file tree
Showing 23 changed files with 1,226 additions and 154 deletions.
7 changes: 7 additions & 0 deletions pkg/aliyun/client/errors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,10 @@ func TestErrorIs(t *testing.T) {
// Test case 3: Check if no check functions are provided
assert.False(t, ErrorIs(err))
}

func TestErrorIsReturnsFalseWhenNoCheckErrMatches(t *testing.T) {
err := apiErr.NewServerError(403, "{\"Code\": \"err\"}", "")
checkFunc1 := WarpFn("anotherErr")
checkFunc2 := WarpFn("yetAnotherErr")
assert.False(t, ErrorIs(err, checkFunc1, checkFunc2))
}
1 change: 0 additions & 1 deletion pkg/controller/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package all

import (
// register all controllers
_ "github.com/AliyunContainerService/terway/pkg/controller/endpoint"
_ "github.com/AliyunContainerService/terway/pkg/controller/multi-ip/node"
_ "github.com/AliyunContainerService/terway/pkg/controller/multi-ip/pod"
_ "github.com/AliyunContainerService/terway/pkg/controller/node"
Expand Down
14 changes: 0 additions & 14 deletions pkg/controller/common/ctx_default.go

This file was deleted.

114 changes: 0 additions & 114 deletions pkg/controller/endpoint/endpoint.go

This file was deleted.

8 changes: 3 additions & 5 deletions pkg/controller/pod-eni/eni_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ func (m *ReconcilePodENI) gcENIs(ctx context.Context, enis []*aliyunClient.Netwo
}
now := time.Now()
for i, eni := range enis {
if !m.eniFilter(eni, tagFilter) {
if eniFilter(eni, tagFilter) {
continue
}
t, err := time.Parse(layout, eni.CreationTime)
Expand Down Expand Up @@ -672,7 +672,6 @@ func (m *ReconcilePodENI) attachENI(ctx context.Context, podENI *v1beta1.PodENI)
ii := i
g.Go(func() error {
alloc := podENI.Spec.Allocations[ii]
ctx := common.WithCtx(ctx, &alloc)
err := m.aliyun.AttachNetworkInterface(ctx, alloc.ENI.ID, podENI.Status.InstanceID, podENI.Status.TrunkENIID)
if err != nil {
return err
Expand Down Expand Up @@ -712,7 +711,6 @@ func (m *ReconcilePodENI) detachMemberENI(ctx context.Context, podENI *v1beta1.P
}
}()
for _, alloc := range podENI.Spec.Allocations {
ctx := common.WithCtx(ctx, &alloc)
instanceID := podENI.Status.InstanceID
trunkENIID := podENI.Status.TrunkENIID
if podENI.Status.InstanceID == "" {
Expand Down Expand Up @@ -761,7 +759,7 @@ func (m *ReconcilePodENI) deleteMemberENI(ctx context.Context, podENI *v1beta1.P
if alloc.ENI.ID == "" {
continue
}
err = m.aliyun.DeleteNetworkInterface(common.WithCtx(ctx, &alloc), alloc.ENI.ID)
err = m.aliyun.DeleteNetworkInterface(ctx, alloc.ENI.ID)
if err != nil {
return err
}
Expand All @@ -771,7 +769,7 @@ func (m *ReconcilePodENI) deleteMemberENI(ctx context.Context, podENI *v1beta1.P
}

// eniFilter will compare eni tags with filter, if all filter match return true
func (m *ReconcilePodENI) eniFilter(eni *aliyunClient.NetworkInterface, filter map[string]string) bool {
func eniFilter(eni *aliyunClient.NetworkInterface, filter map[string]string) bool {
for k, v := range filter {
found := false
for _, tag := range eni.Tags {
Expand Down
Loading

0 comments on commit 64c6bc9

Please sign in to comment.