Skip to content

Commit

Permalink
test: retry in discovery tests
Browse files Browse the repository at this point in the history
Sometimes pushing/pulling to Kubernetes registry is delayed due to
backoff on failed attempts to talk to the API server when the cluster is
still bootstrapping. Workaround that by adding retries.

Also disable kernel module controller in container mode, as it will keep
always failing.

Signed-off-by: Andrey Smirnov <[email protected]>
  • Loading branch information
smira committed Dec 28, 2021
1 parent f4219e5 commit d2a7e08
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ import (
"github.com/pmorjan/kmod"
"go.uber.org/zap"

v1alpha1runtime "github.com/talos-systems/talos/internal/app/machined/pkg/runtime"
"github.com/talos-systems/talos/pkg/machinery/resources/runtime"
)

// KernelModuleSpecController watches KernelModuleSpecs, sets/resets kernel params.
type KernelModuleSpecController struct{}
type KernelModuleSpecController struct {
V1Alpha1Mode v1alpha1runtime.Mode
}

// Name implements controller.Controller interface.
func (ctrl *KernelModuleSpecController) Name() string {
Expand All @@ -42,6 +45,11 @@ func (ctrl *KernelModuleSpecController) Outputs() []controller.Output {

// Run implements controller.Controller interface.
func (ctrl *KernelModuleSpecController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
if ctrl.V1Alpha1Mode == v1alpha1runtime.ModeContainer {
// not supported in container mode
return nil
}

manager, err := kmod.New()
if err != nil {
return fmt.Errorf("error initializing kmod manager: %w", err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ func (ctrl *Controller) Run(ctx context.Context, drainer *runtime.Drainer) error
Drainer: drainer,
},
&runtimecontrollers.KernelModuleConfigController{},
&runtimecontrollers.KernelModuleSpecController{},
&runtimecontrollers.KernelModuleSpecController{
V1Alpha1Mode: ctrl.v1alpha1Runtime.State().Platform().Mode(),
},
&runtimecontrollers.KernelParamConfigController{},
&runtimecontrollers.KernelParamDefaultsController{
V1Alpha1Mode: ctrl.v1alpha1Runtime.State().Platform().Mode(),
Expand Down
19 changes: 17 additions & 2 deletions internal/integration/api/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,25 @@ func (suite *DiscoverySuite) TestRegistries() {

members := suite.getMembers(nodeCtx)
localIdentity := suite.getNodeIdentity(nodeCtx)
rawAffiliates := suite.getAffiliates(nodeCtx, cluster.RawNamespaceName)

// raw affiliates don't contain the local node
suite.Assert().Len(rawAffiliates, len(registries)*(len(members)-1))
expectedRawAffiliates := len(registries) * (len(members) - 1)

var rawAffiliates []*cluster.Affiliate

for i := 0; i < 30; i++ {
rawAffiliates = suite.getAffiliates(nodeCtx, cluster.RawNamespaceName)

if len(rawAffiliates) == expectedRawAffiliates {
break
}

suite.T().Logf("waiting for cluster affiliates to be discovered: %d expected, %d found", expectedRawAffiliates, len(rawAffiliates))

time.Sleep(2 * time.Second)
}

suite.Assert().Len(rawAffiliates, expectedRawAffiliates)

rawAffiliatesByID := make(map[string]*cluster.Affiliate)

Expand Down

0 comments on commit d2a7e08

Please sign in to comment.