Skip to content

Commit

Permalink
chore: disable systeminfo controller in container
Browse files Browse the repository at this point in the history
Disable systeminfo controller in container mode

Fixes: #5849

Signed-off-by: Noel Georgi <[email protected]>
  • Loading branch information
frezbo committed Jul 1, 2022
1 parent 86a0a7b commit 184e113
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
8 changes: 7 additions & 1 deletion internal/app/machined/pkg/controllers/hardware/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ import (
"go.uber.org/zap"

hwadapter "github.com/talos-systems/talos/internal/app/machined/pkg/adapters/hardware"
runtimetalos "github.com/talos-systems/talos/internal/app/machined/pkg/runtime"
pkgSMBIOS "github.com/talos-systems/talos/internal/pkg/smbios"
"github.com/talos-systems/talos/pkg/machinery/resources/hardware"
)

// SystemInfoController populates CPU information of the underlying hardware.
type SystemInfoController struct {
SMBIOS *smbios.SMBIOS
V1Alpha1Mode runtimetalos.Mode
SMBIOS *smbios.SMBIOS
}

// Name implements controller.Controller interface.
Expand Down Expand Up @@ -62,6 +64,10 @@ func (ctrl *SystemInfoController) Run(ctx context.Context, r controller.Runtime,
case <-r.EventCh():
}

// smbios info is not available inside container, so skip the controller
if ctrl.V1Alpha1Mode == runtimetalos.ModeContainer {
return nil
}
// controller runs only once
if ctrl.SMBIOS == nil {
s, err := pkgSMBIOS.GetSMBIOSInfo()
Expand Down
15 changes: 15 additions & 0 deletions internal/app/machined/pkg/controllers/hardware/system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/talos-systems/go-smbios/smbios"

hardwarectrl "github.com/talos-systems/talos/internal/app/machined/pkg/controllers/hardware"
runtimetalos "github.com/talos-systems/talos/internal/app/machined/pkg/runtime"
"github.com/talos-systems/talos/pkg/machinery/resources/hardware"
)

Expand Down Expand Up @@ -124,6 +125,20 @@ func (suite *SystemInfoSuite) TestPopulateSystemInformation() {
}
}

func (suite *SystemInfoSuite) TestPopulateSystemInformationIsDisabledInContainerMode() {
suite.Require().NoError(
suite.runtime.RegisterController(
&hardwarectrl.SystemInfoController{
V1Alpha1Mode: runtimetalos.ModeContainer,
},
),
)

suite.startRuntime()

suite.Assert().NoError(retry.Constant(1*time.Second, retry.WithUnits(100*time.Millisecond)).Retry(suite.assertNoResource(*hardware.NewSystemInformation("systeminformation").Metadata())))
}

func TestSystemInfoSyncSuite(t *testing.T) {
suite.Run(t, new(SystemInfoSuite))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ func (ctrl *Controller) Run(ctx context.Context, drainer *runtime.Drainer) error
EtcPath: "/etc",
ShadowPath: constants.SystemEtcPath,
},
&hardware.SystemInfoController{},
&hardware.SystemInfoController{
V1Alpha1Mode: ctrl.v1alpha1Runtime.State().Platform().Mode(),
},
&k8s.ControlPlaneStaticPodController{},
&k8s.EndpointController{},
&k8s.ExtraManifestController{},
Expand Down

0 comments on commit 184e113

Please sign in to comment.