diff --git a/internal/app/machined/pkg/system/services/kubelet.go b/internal/app/machined/pkg/system/services/kubelet.go index d1275323d2..f9c9cfda7f 100644 --- a/internal/app/machined/pkg/system/services/kubelet.go +++ b/internal/app/machined/pkg/system/services/kubelet.go @@ -203,6 +203,11 @@ func (k *Kubelet) APIRestartAllowed(runtime.Runtime) bool { return true } +// APIStartAllowed implements APIStartableService. +func (k *Kubelet) APIStartAllowed(runtime.Runtime) bool { + return true +} + func kubeletSeccomp(seccomp *specs.LinuxSeccomp) { // for cephfs mounts seccomp.Syscalls = append(seccomp.Syscalls, diff --git a/pkg/machinery/resources/k8s/condition.go b/pkg/machinery/resources/k8s/condition.go deleted file mode 100644 index d00a8ef91b..0000000000 --- a/pkg/machinery/resources/k8s/condition.go +++ /dev/null @@ -1,59 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -package k8s - -import ( - "context" - - "github.com/cosi-project/runtime/pkg/resource" - "github.com/cosi-project/runtime/pkg/state" - - "github.com/talos-systems/talos/pkg/machinery/resources/network" -) - -// NodenameReadyCondition implements condition which waits for the nodename to be ready. -type NodenameReadyCondition struct { - state state.State -} - -// NewNodenameReadyCondition builds a coondition which waits for the network to be ready. -func NewNodenameReadyCondition(state state.State) *NodenameReadyCondition { - return &NodenameReadyCondition{ - state: state, - } -} - -func (condition *NodenameReadyCondition) String() string { - return "nodename" -} - -// Wait implements condition interface. -func (condition *NodenameReadyCondition) Wait(ctx context.Context) error { - _, err := condition.state.WatchFor( - ctx, - resource.NewMetadata(NamespaceName, NodenameType, NodenameID, resource.VersionUndefined), - state.WithCondition(func(r resource.Resource) (bool, error) { - if resource.IsTombstone(r) { - return false, nil - } - - nodename := r.(*Nodename).TypedSpec() - - // check that hostname status version matches one recorded in the nodename - hostnameStatus, err := condition.state.Get(ctx, resource.NewMetadata(network.NamespaceName, network.HostnameStatusType, network.HostnameID, resource.VersionUndefined)) - if err != nil { - return false, err - } - - if hostnameStatus.Metadata().Version().String() != nodename.HostnameVersion { - return false, nil - } - - return true, nil - }), - ) - - return err -} diff --git a/pkg/machinery/resources/k8s/condition_test.go b/pkg/machinery/resources/k8s/condition_test.go deleted file mode 100644 index 35b1f8f039..0000000000 --- a/pkg/machinery/resources/k8s/condition_test.go +++ /dev/null @@ -1,88 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -package k8s_test - -import ( - "context" - "errors" - "testing" - "time" - - "github.com/cosi-project/runtime/pkg/state" - "github.com/cosi-project/runtime/pkg/state/impl/inmem" - "github.com/cosi-project/runtime/pkg/state/impl/namespaced" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/talos-systems/talos/pkg/machinery/resources/k8s" - "github.com/talos-systems/talos/pkg/machinery/resources/network" -) - -func TestCondition(t *testing.T) { - ctx, ctxCancel := context.WithTimeout(context.Background(), time.Second) - t.Cleanup(ctxCancel) - - t.Parallel() - - for _, tt := range []struct { - Name string - NodenameExists bool - VersionMatches bool - Succeeds bool - }{ - { - Name: "no nodename", - Succeeds: false, - }, - { - Name: "version mismatch", - NodenameExists: true, - VersionMatches: false, - Succeeds: false, - }, - { - Name: "success", - NodenameExists: true, - VersionMatches: true, - Succeeds: true, - }, - } { - tt := tt - - t.Run(tt.Name, func(t *testing.T) { - t.Parallel() - - state := state.WrapCore(namespaced.NewState(inmem.Build)) - - hostnameStatus := network.NewHostnameStatus(network.NamespaceName, network.HostnameID) - hostnameStatus.TypedSpec().Hostname = "foo" - - require.NoError(t, state.Create(ctx, hostnameStatus)) - - if tt.NodenameExists { - nodename := k8s.NewNodename(k8s.NamespaceName, k8s.NodenameID) - nodename.TypedSpec().Nodename = "foo" - - md := hostnameStatus.Metadata() - - if !tt.VersionMatches { - md.BumpVersion() - } - - nodename.TypedSpec().HostnameVersion = md.Version().String() - - require.NoError(t, state.Create(ctx, nodename)) - } - - err := k8s.NewNodenameReadyCondition(state).Wait(ctx) - - if tt.Succeeds { - assert.NoError(t, err) - } else { - assert.True(t, errors.Is(err, context.DeadlineExceeded), "error is %v", err) - } - }) - } -}