Skip to content

Commit

Permalink
Use timeout for the route table test We use a timeout for route table…
Browse files Browse the repository at this point in the history
… reconcilation considering the route reconciling interval

Signed-off-by: Zhecheng Li <[email protected]>
  • Loading branch information
lzhecheng authored and k8s-infra-cherrypick-robot committed Jul 21, 2023
1 parent de4b993 commit 1f96130
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
3 changes: 3 additions & 0 deletions pkg/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ const (
const (
RouteNameFmt = "%s____%s"
RouteNameSeparator = "____"

// routeUpdateInterval defines the route reconciling interval.
RouteUpdateInterval = 30 * time.Second
)

// cloud provider config secret
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ func (az *Cloud) InitializeCloudFromConfig(config *Config, fromSecret, callFromC
// updating routes and syncing zones only in CCM
if callFromCCM {
// start delayed route updater.
az.routeUpdater = newDelayedRouteUpdater(az, routeUpdateInterval)
az.routeUpdater = newDelayedRouteUpdater(az, consts.RouteUpdateInterval)
go az.routeUpdater.run()

// Azure Stack does not support zone at the moment
Expand Down
5 changes: 0 additions & 5 deletions pkg/provider/azure_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ import (
"sigs.k8s.io/cloud-provider-azure/pkg/metrics"
)

var (
// routeUpdateInterval defines the route reconciling interval.
routeUpdateInterval = 30 * time.Second
)

// routeOperation defines the allowed operations for route updating.
type routeOperation string

Expand Down
29 changes: 17 additions & 12 deletions tests/e2e/network/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"reflect"
"regexp"
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2022-03-01/compute"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2022-07-01/network"
Expand All @@ -31,8 +32,10 @@ import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/wait"
clientset "k8s.io/client-go/kubernetes"

"sigs.k8s.io/cloud-provider-azure/pkg/consts"
"sigs.k8s.io/cloud-provider-azure/tests/e2e/utils"
)

Expand Down Expand Up @@ -247,21 +250,23 @@ var _ = Describe("Azure node resources", Label(utils.TestSuiteLabelNode), func()
}
utils.Logf("nodeSet: %v", nodeSet)

var succeeded bool
for _, routeTable := range *routeTables {
utils.Logf("getting all routes in route table %s", *routeTable.Name)
routeSet, err := utils.GetNodesInRouteTable(routeTable)
Expect(err).NotTo(HaveOccurred())

utils.Logf("routeSet: %v", routeSet)
// Considering the route reconciling interval, the timeout is set to interval + 10s.
err = wait.PollImmediate(5*time.Second, consts.RouteUpdateInterval+10*time.Second, func() (bool, error) {
for _, routeTable := range *routeTables {
routeSet, err := utils.GetNodesInRouteTable(routeTable)
if err != nil {
return false, err
}

if reflect.DeepEqual(nodeSet, routeSet) {
succeeded = true
break
utils.Logf("all routes in route table: %v", routeSet)
if reflect.DeepEqual(nodeSet, routeSet) {
return true, nil
}
}
}
return false, nil
})

Expect(succeeded).To(BeTrue())
Expect(err).NotTo(HaveOccurred())
})
})

Expand Down

0 comments on commit 1f96130

Please sign in to comment.