fix: build of talosctl on non-Linux arches

Move META constants out to machinery, and fix up imports. The internal
`pkg/meta` package shold not be consumed in public-facing commands.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
This commit is contained in:
Andrey Smirnov 2024-08-30 22:07:09 +04:00
parent f0a59cec71
commit 6f7c3a8e5c
No known key found for this signature in database
GPG Key ID: FE042E3D4085A811
23 changed files with 43 additions and 39 deletions

View File

@ -34,6 +34,7 @@ import (
"github.com/siderolabs/talos/pkg/machinery/constants"
"github.com/siderolabs/talos/pkg/machinery/imager/quirks"
"github.com/siderolabs/talos/pkg/machinery/kernel"
metaconsts "github.com/siderolabs/talos/pkg/machinery/meta"
"github.com/siderolabs/talos/pkg/machinery/overlay"
"github.com/siderolabs/talos/pkg/machinery/version"
)
@ -410,7 +411,7 @@ func (i *Installer) Install(ctx context.Context, mode Mode) (err error) {
var ok bool
if mode == ModeUpgrade {
if ok, err = metaState.SetTag(ctx, meta.Upgrade, bootInstallResult.PreviousLabel); !ok || err != nil {
if ok, err = metaState.SetTag(ctx, metaconsts.Upgrade, bootInstallResult.PreviousLabel); !ok || err != nil {
return fmt.Errorf("failed to set upgrade tag: %q", bootInstallResult.PreviousLabel)
}
}

View File

@ -60,7 +60,6 @@ import (
"github.com/siderolabs/talos/internal/pkg/containers/cri"
"github.com/siderolabs/talos/internal/pkg/etcd"
"github.com/siderolabs/talos/internal/pkg/install"
"github.com/siderolabs/talos/internal/pkg/meta"
"github.com/siderolabs/talos/internal/pkg/miniprocfs"
"github.com/siderolabs/talos/internal/pkg/partition"
"github.com/siderolabs/talos/internal/pkg/pcap"
@ -81,6 +80,7 @@ import (
"github.com/siderolabs/talos/pkg/machinery/config/generate/secrets"
machinetype "github.com/siderolabs/talos/pkg/machinery/config/machine"
"github.com/siderolabs/talos/pkg/machinery/constants"
"github.com/siderolabs/talos/pkg/machinery/meta"
"github.com/siderolabs/talos/pkg/machinery/nethelpers"
"github.com/siderolabs/talos/pkg/machinery/resources/block"
etcdresource "github.com/siderolabs/talos/pkg/machinery/resources/etcd"

View File

@ -16,13 +16,13 @@ import (
"github.com/siderolabs/go-blockdevice/v2/encryption"
"go.uber.org/zap"
"github.com/siderolabs/talos/internal/pkg/meta"
"github.com/siderolabs/talos/internal/pkg/partition"
"github.com/siderolabs/talos/pkg/machinery/cel"
"github.com/siderolabs/talos/pkg/machinery/cel/celenv"
cfg "github.com/siderolabs/talos/pkg/machinery/config/config"
"github.com/siderolabs/talos/pkg/machinery/config/types/v1alpha1"
"github.com/siderolabs/talos/pkg/machinery/constants"
"github.com/siderolabs/talos/pkg/machinery/meta"
"github.com/siderolabs/talos/pkg/machinery/resources/block"
"github.com/siderolabs/talos/pkg/machinery/resources/config"
"github.com/siderolabs/talos/pkg/machinery/resources/runtime"

View File

@ -15,10 +15,10 @@ import (
blockctrls "github.com/siderolabs/talos/internal/app/machined/pkg/controllers/block"
"github.com/siderolabs/talos/internal/app/machined/pkg/controllers/ctest"
"github.com/siderolabs/talos/internal/pkg/meta"
"github.com/siderolabs/talos/pkg/machinery/config/container"
"github.com/siderolabs/talos/pkg/machinery/config/types/v1alpha1"
"github.com/siderolabs/talos/pkg/machinery/constants"
"github.com/siderolabs/talos/pkg/machinery/meta"
"github.com/siderolabs/talos/pkg/machinery/resources/block"
"github.com/siderolabs/talos/pkg/machinery/resources/config"
"github.com/siderolabs/talos/pkg/machinery/resources/runtime"

View File

@ -18,8 +18,8 @@ import (
hwadapter "github.com/siderolabs/talos/internal/app/machined/pkg/adapters/hardware"
runtimetalos "github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
"github.com/siderolabs/talos/internal/pkg/meta"
pkgSMBIOS "github.com/siderolabs/talos/internal/pkg/smbios"
"github.com/siderolabs/talos/pkg/machinery/meta"
"github.com/siderolabs/talos/pkg/machinery/resources/hardware"
"github.com/siderolabs/talos/pkg/machinery/resources/runtime"
)

View File

@ -17,7 +17,7 @@ import (
"github.com/siderolabs/talos/internal/app/machined/pkg/controllers/ctest"
hardwarectrl "github.com/siderolabs/talos/internal/app/machined/pkg/controllers/hardware"
runtimetalos "github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
"github.com/siderolabs/talos/internal/pkg/meta"
"github.com/siderolabs/talos/pkg/machinery/meta"
"github.com/siderolabs/talos/pkg/machinery/resources/hardware"
"github.com/siderolabs/talos/pkg/machinery/resources/runtime"
)

View File

@ -15,7 +15,7 @@ import (
"go.uber.org/zap"
machineruntime "github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
"github.com/siderolabs/talos/internal/pkg/meta"
"github.com/siderolabs/talos/pkg/machinery/meta"
"github.com/siderolabs/talos/pkg/machinery/resources/runtime"
)

View File

@ -22,6 +22,7 @@ import (
"github.com/siderolabs/talos/internal/app/machined/pkg/controllers/runtime"
machineruntime "github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
"github.com/siderolabs/talos/internal/pkg/meta"
metaconsts "github.com/siderolabs/talos/pkg/machinery/meta"
runtimeres "github.com/siderolabs/talos/pkg/machinery/resources/runtime"
)
@ -67,7 +68,7 @@ func TestUpgradeFallbackControllerSuite(t *testing.T) {
}
func (suite *DropUpgradeFallbackControllerSuite) TestDropUpgradeFallback() {
_, err := suite.meta.SetTag(suite.Ctx(), meta.Upgrade, "A")
_, err := suite.meta.SetTag(suite.Ctx(), metaconsts.Upgrade, "A")
suite.Require().NoError(err)
machineStatus := runtimeres.NewMachineStatus()
@ -78,7 +79,7 @@ func (suite *DropUpgradeFallbackControllerSuite) TestDropUpgradeFallback() {
time.Sleep(time.Second)
// controller should not remove the tag
val, ok := suite.meta.ReadTag(meta.Upgrade)
val, ok := suite.meta.ReadTag(metaconsts.Upgrade)
suite.Require().True(ok)
suite.Require().Equal("A", val)
@ -88,7 +89,7 @@ func (suite *DropUpgradeFallbackControllerSuite) TestDropUpgradeFallback() {
suite.Require().NoError(suite.State().Update(suite.Ctx(), machineStatus))
suite.AssertWithin(time.Second, 10*time.Millisecond, func() error {
_, ok = suite.meta.ReadTag(meta.Upgrade)
_, ok = suite.meta.ReadTag(metaconsts.Upgrade)
if ok {
return retry.ExpectedErrorf("tag is still present")
}

View File

@ -14,7 +14,7 @@ import (
"github.com/siderolabs/gen/optional"
"go.uber.org/zap"
"github.com/siderolabs/talos/internal/pkg/meta"
"github.com/siderolabs/talos/pkg/machinery/meta"
"github.com/siderolabs/talos/pkg/machinery/resources/runtime"
)

View File

@ -29,9 +29,9 @@ import (
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/internal/netutils"
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/metal/oauth2"
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/metal/url"
"github.com/siderolabs/talos/internal/pkg/meta"
"github.com/siderolabs/talos/pkg/download"
"github.com/siderolabs/talos/pkg/machinery/constants"
"github.com/siderolabs/talos/pkg/machinery/meta"
"github.com/siderolabs/talos/pkg/machinery/resources/hardware"
runtimeres "github.com/siderolabs/talos/pkg/machinery/resources/runtime"
)

View File

@ -18,8 +18,8 @@ import (
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/metal"
"github.com/siderolabs/talos/internal/pkg/meta"
"github.com/siderolabs/talos/pkg/machinery/constants"
"github.com/siderolabs/talos/pkg/machinery/meta"
"github.com/siderolabs/talos/pkg/machinery/resources/hardware"
runtimeres "github.com/siderolabs/talos/pkg/machinery/resources/runtime"
)

View File

@ -18,7 +18,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/platform/metal/url"
"github.com/siderolabs/talos/internal/pkg/meta"
"github.com/siderolabs/talos/pkg/machinery/meta"
"github.com/siderolabs/talos/pkg/machinery/nethelpers"
"github.com/siderolabs/talos/pkg/machinery/resources/hardware"
"github.com/siderolabs/talos/pkg/machinery/resources/network"

View File

@ -10,7 +10,7 @@ import (
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/talos/internal/pkg/meta"
"github.com/siderolabs/talos/pkg/machinery/meta"
"github.com/siderolabs/talos/pkg/machinery/resources/hardware"
"github.com/siderolabs/talos/pkg/machinery/resources/network"
"github.com/siderolabs/talos/pkg/machinery/resources/runtime"

View File

@ -57,7 +57,6 @@ import (
"github.com/siderolabs/talos/internal/pkg/etcd"
"github.com/siderolabs/talos/internal/pkg/install"
"github.com/siderolabs/talos/internal/pkg/logind"
"github.com/siderolabs/talos/internal/pkg/meta"
"github.com/siderolabs/talos/internal/pkg/mount"
mountv2 "github.com/siderolabs/talos/internal/pkg/mount/v2"
"github.com/siderolabs/talos/internal/pkg/partition"
@ -1640,7 +1639,7 @@ func ResetSystemDiskSpec(_ runtime.Sequence, data any) (runtime.TaskExecutionFun
if stateWiped && !metaWiped {
var removed bool
removed, err = r.State().Machine().Meta().DeleteTag(ctx, meta.StateEncryptionConfig)
removed, err = r.State().Machine().Meta().DeleteTag(ctx, metamachinery.StateEncryptionConfig)
if err != nil {
return fmt.Errorf("failed to remove state encryption META config tag: %w", err)
}
@ -1766,7 +1765,7 @@ func SaveStateEncryptionConfig(runtime.Sequence, any) (runtime.TaskExecutionFunc
return err
}
ok, err := r.State().Machine().Meta().SetTagBytes(ctx, meta.StateEncryptionConfig, data)
ok, err := r.State().Machine().Meta().SetTagBytes(ctx, metamachinery.StateEncryptionConfig, data)
if err != nil {
return err
}

View File

@ -20,6 +20,7 @@ import (
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha2"
"github.com/siderolabs/talos/internal/pkg/meta"
"github.com/siderolabs/talos/pkg/machinery/constants"
metaconsts "github.com/siderolabs/talos/pkg/machinery/meta"
"github.com/siderolabs/talos/pkg/machinery/resources/block"
)
@ -201,15 +202,15 @@ func (s *MachineState) Flush() error {
}
func (s *MachineState) probeMeta() {
stagedInstallImageRef, ok1 := s.meta.ReadTag(meta.StagedUpgradeImageRef)
stagedInstallOptions, ok2 := s.meta.ReadTag(meta.StagedUpgradeInstallOptions)
stagedInstallImageRef, ok1 := s.meta.ReadTag(metaconsts.StagedUpgradeImageRef)
stagedInstallOptions, ok2 := s.meta.ReadTag(metaconsts.StagedUpgradeInstallOptions)
s.stagedInstall = ok1 && ok2
if s.stagedInstall {
// clear the staged install flags
_, err1 := s.meta.DeleteTag(context.Background(), meta.StagedUpgradeImageRef)
_, err2 := s.meta.DeleteTag(context.Background(), meta.StagedUpgradeInstallOptions)
_, err1 := s.meta.DeleteTag(context.Background(), metaconsts.StagedUpgradeImageRef)
_, err2 := s.meta.DeleteTag(context.Background(), metaconsts.StagedUpgradeInstallOptions)
if err := s.meta.Flush(); err != nil || err1 != nil || err2 != nil {
// failed to delete staged install tags, clear the stagedInstall to prevent boot looping

View File

@ -39,7 +39,6 @@ import (
"github.com/siderolabs/talos/internal/pkg/containers/image"
"github.com/siderolabs/talos/internal/pkg/environment"
"github.com/siderolabs/talos/internal/pkg/etcd"
"github.com/siderolabs/talos/internal/pkg/meta"
"github.com/siderolabs/talos/pkg/argsbuilder"
"github.com/siderolabs/talos/pkg/conditions"
"github.com/siderolabs/talos/pkg/filetree"
@ -47,6 +46,7 @@ import (
machineapi "github.com/siderolabs/talos/pkg/machinery/api/machine"
"github.com/siderolabs/talos/pkg/machinery/config/machine"
"github.com/siderolabs/talos/pkg/machinery/constants"
"github.com/siderolabs/talos/pkg/machinery/meta"
"github.com/siderolabs/talos/pkg/machinery/nethelpers"
etcdresource "github.com/siderolabs/talos/pkg/machinery/resources/etcd"
"github.com/siderolabs/talos/pkg/machinery/resources/k8s"

View File

@ -15,6 +15,7 @@ import (
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/bootloader"
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime/v1alpha1/bootloader/options"
"github.com/siderolabs/talos/internal/pkg/meta"
metaconsts "github.com/siderolabs/talos/pkg/machinery/meta"
"github.com/siderolabs/talos/pkg/machinery/resources/block"
)
@ -59,13 +60,13 @@ func revertBootloadInternal(ctx context.Context, resourceState state.State) erro
return err
}
label, ok := metaState.ReadTag(meta.Upgrade)
label, ok := metaState.ReadTag(metaconsts.Upgrade)
if !ok {
return nil
}
if label == "" {
if _, err = metaState.DeleteTag(ctx, meta.Upgrade); err != nil {
if _, err = metaState.DeleteTag(ctx, metaconsts.Upgrade); err != nil {
return err
}
@ -85,7 +86,7 @@ func revertBootloadInternal(ctx context.Context, resourceState state.State) erro
return err
}
if _, err = metaState.DeleteTag(ctx, meta.Upgrade); err != nil {
if _, err = metaState.DeleteTag(ctx, metaconsts.Upgrade); err != nil {
return err
}

View File

@ -15,8 +15,8 @@ import (
"google.golang.org/grpc/status"
"github.com/siderolabs/talos/internal/pkg/dashboard/resourcedata"
"github.com/siderolabs/talos/internal/pkg/meta"
"github.com/siderolabs/talos/pkg/machinery/constants"
"github.com/siderolabs/talos/pkg/machinery/meta"
runtimeres "github.com/siderolabs/talos/pkg/machinery/resources/runtime"
)

View File

@ -18,7 +18,7 @@ import (
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
"github.com/siderolabs/talos/internal/pkg/dashboard/resourcedata"
"github.com/siderolabs/talos/internal/pkg/meta"
"github.com/siderolabs/talos/pkg/machinery/meta"
"github.com/siderolabs/talos/pkg/machinery/resources/network"
runtimeres "github.com/siderolabs/talos/pkg/machinery/resources/runtime"
)

View File

@ -19,6 +19,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/siderolabs/talos/internal/pkg/meta"
metaconsts "github.com/siderolabs/talos/pkg/machinery/meta"
"github.com/siderolabs/talos/pkg/machinery/resources/runtime"
)
@ -51,22 +52,22 @@ func TestFlow(t *testing.T) {
ctx := context.Background()
ok, err := m.SetTag(ctx, meta.Upgrade, "1.2.3")
ok, err := m.SetTag(ctx, metaconsts.Upgrade, "1.2.3")
require.NoError(t, err)
assert.True(t, ok)
val, ok := m.ReadTag(meta.Upgrade)
val, ok := m.ReadTag(metaconsts.Upgrade)
assert.True(t, ok)
assert.Equal(t, "1.2.3", val)
_, ok = m.ReadTag(meta.StagedUpgradeImageRef)
_, ok = m.ReadTag(metaconsts.StagedUpgradeImageRef)
assert.False(t, ok)
ok, err = m.DeleteTag(ctx, meta.Upgrade)
ok, err = m.DeleteTag(ctx, metaconsts.Upgrade)
require.NoError(t, err)
assert.True(t, ok)
ok, err = m.SetTag(ctx, meta.StagedUpgradeInstallOptions, "install-fast")
ok, err = m.SetTag(ctx, metaconsts.StagedUpgradeInstallOptions, "install-fast")
require.NoError(t, err)
assert.True(t, ok)
@ -74,17 +75,17 @@ func TestFlow(t *testing.T) {
assert.NoError(t, m.Reload(ctx))
val, ok = m.ReadTag(meta.StagedUpgradeInstallOptions)
val, ok = m.ReadTag(metaconsts.StagedUpgradeInstallOptions)
assert.True(t, ok)
assert.Equal(t, "install-fast", val)
m2, err := meta.New(ctx, st, meta.WithFixedPath(path))
require.NoError(t, err)
_, ok = m2.ReadTag(meta.Upgrade)
_, ok = m2.ReadTag(metaconsts.Upgrade)
assert.False(t, ok)
val, ok = m2.ReadTag(meta.StagedUpgradeInstallOptions)
val, ok = m2.ReadTag(metaconsts.StagedUpgradeInstallOptions)
assert.True(t, ok)
assert.Equal(t, "install-fast", val)

View File

@ -1 +1 @@
v1.8.0-alpha.2
v1.8.0-alpha.1

View File

@ -96,7 +96,7 @@ talosctl cluster create [flags]
--bad-rtc launch VM with bad RTC state (QEMU only)
--cidr string CIDR of the cluster network (IPv4, ULA network for IPv6 is derived in automated way) (default "10.5.0.0/24")
--cni-bin-path strings search path for CNI binaries (VM only) (default [/home/user/.talos/cni/bin])
--cni-bundle-url string URL to download CNI bundle from (VM only) (default "https://github.com/siderolabs/talos/releases/download/v1.8.0-alpha.2/talosctl-cni-bundle-${ARCH}.tar.gz")
--cni-bundle-url string URL to download CNI bundle from (VM only) (default "https://github.com/siderolabs/talos/releases/download/v1.8.0-alpha.1/talosctl-cni-bundle-${ARCH}.tar.gz")
--cni-cache-dir string CNI cache directory path (VM only) (default "/home/user/.talos/cni/cache")
--cni-conf-dir string CNI config directory path (VM only) (default "/home/user/.talos/cni/conf.d")
--config-patch stringArray patch generated machineconfigs (applied to all node types), use @file to read a patch from file
@ -2901,7 +2901,7 @@ talosctl upgrade [flags]
--debug debug operation from kernel logs. --wait is set to true when this flag is set
-f, --force force the upgrade (skip checks on etcd health and members, might lead to data loss)
-h, --help help for upgrade
-i, --image string the container image to use for performing the install (default "ghcr.io/siderolabs/installer:v1.8.0-alpha.2")
-i, --image string the container image to use for performing the install (default "ghcr.io/siderolabs/installer:v1.8.0-alpha.1")
--insecure upgrade using the insecure (encrypted with no auth) maintenance service
-m, --reboot-mode string select the reboot mode during upgrade. Mode "powercycle" bypasses kexec. Valid values are: ["default" "powercycle"]. (default "default")
-s, --stage stage the upgrade to perform it after a reboot