Skip to content

Commit dedd273

Browse files
committed
fix: bond config via platform
Call `FillDefaults` on platform-acquired bond config. As platform config controller might have cached (saved) representation of bond config, we need to ensure we adapt it to the latest bond configuration. In particular, new fields introduced in v1.12 require some values to be set which `.FillDefaults()` does for us. Otherwise, Talos enters a loop trying to reconfigure the bond in a loop. Prove with a unit-test (it fails if `.FillDefaults()` is removed). Fixes #12561 Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com> (cherry picked from commit 99f2dda)
1 parent f527cff commit dedd273

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

internal/app/machined/pkg/controllers/network/link_spec_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,55 @@ func (suite *LinkSpecSuite) TestBond() {
461461
ctest.AssertNoResource[*network.LinkStatus](suite, bondName)
462462
}
463463

464+
func (suite *LinkSpecSuite) TestBondActiveBackup() {
465+
bondName := suite.uniqueDummyInterface()
466+
bond := network.NewLinkSpec(network.NamespaceName, bondName)
467+
*bond.TypedSpec() = network.LinkSpecSpec{
468+
Name: bondName,
469+
Type: nethelpers.LinkEther,
470+
Kind: network.LinkKindBond,
471+
Up: true,
472+
Logical: true,
473+
BondMaster: network.BondMasterSpec{
474+
Mode: nethelpers.BondModeActiveBackup,
475+
HashPolicy: nethelpers.BondXmitPolicyLayer2,
476+
LACPRate: nethelpers.LACPRateSlow,
477+
ARPValidate: nethelpers.ARPValidateNone,
478+
ARPAllTargets: nethelpers.ARPAllTargetsAny,
479+
PrimaryReselect: nethelpers.PrimaryReselectAlways,
480+
FailOverMac: nethelpers.FailOverMACNone,
481+
},
482+
ConfigLayer: network.ConfigDefault,
483+
}
484+
485+
networkadapter.BondMasterSpec(&bond.TypedSpec().BondMaster).FillDefaults()
486+
487+
for idx := range 2 {
488+
dummyName := suite.uniqueDummyInterface()
489+
dummy := network.NewLinkSpec(network.NamespaceName, dummyName)
490+
*dummy.TypedSpec() = network.LinkSpecSpec{
491+
Name: dummyName,
492+
Type: nethelpers.LinkEther,
493+
Kind: "dummy",
494+
Up: true,
495+
Logical: true,
496+
BondSlave: network.BondSlave{
497+
MasterName: bondName,
498+
SlaveIndex: idx,
499+
},
500+
ConfigLayer: network.ConfigDefault,
501+
}
502+
suite.Create(dummy)
503+
}
504+
505+
suite.Create(bond)
506+
507+
ctest.AssertResource(suite, bondName, func(r *network.LinkStatus, asrt *assert.Assertions) {
508+
asrt.Equal(network.LinkKindBond, r.TypedSpec().Kind)
509+
asrt.Contains([]nethelpers.OperationalState{nethelpers.OperStateUp, nethelpers.OperStateUnknown}, r.TypedSpec().OperationalState)
510+
})
511+
}
512+
464513
//nolint:gocyclo
465514
func (suite *LinkSpecSuite) TestBond8023ad() {
466515
bondName := suite.uniqueDummyInterface()

internal/app/machined/pkg/controllers/network/platform_config_apply.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/cosi-project/runtime/pkg/safe"
1515
"go.uber.org/zap"
1616

17+
networkadapter "github.com/siderolabs/talos/internal/app/machined/pkg/adapters/network"
1718
v1alpha1runtime "github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
1819
"github.com/siderolabs/talos/pkg/machinery/nethelpers"
1920
"github.com/siderolabs/talos/pkg/machinery/resources/network"
@@ -201,6 +202,10 @@ func (ctrl *PlatformConfigApplyController) apply(ctx context.Context, r controll
201202
*spec = newSpec.(network.LinkSpecSpec) //nolint:forcetypeassert
202203
spec.ConfigLayer = network.ConfigPlatform
203204

205+
if spec.Kind == network.LinkKindBond {
206+
networkadapter.BondMasterSpec(&spec.BondMaster).FillDefaults()
207+
}
208+
204209
return nil
205210
}
206211
},

0 commit comments

Comments
 (0)