Skip to content

Commit

Permalink
fix: build of talosctl on non-Linux arches
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
smira committed Aug 30, 2024
1 parent f0a59ce commit 6f7c3a8
Show file tree
Hide file tree
Showing 23 changed files with 43 additions and 39 deletions.
3 changes: 2 additions & 1 deletion cmd/installer/pkg/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion internal/app/machined/pkg/controllers/hardware/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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()
Expand All @@ -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)

Expand All @@ -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")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}
Expand Down
9 changes: 5 additions & 4 deletions internal/app/machined/pkg/runtime/v1alpha1/v1alpha1_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/app/machined/pkg/system/services/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ 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"
"github.com/siderolabs/talos/pkg/logging"
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"
Expand Down
7 changes: 4 additions & 3 deletions internal/app/machined/revert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/dashboard/configurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/dashboard/networkconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
17 changes: 9 additions & 8 deletions internal/pkg/meta/meta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -51,40 +52,40 @@ 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)

assert.NoError(t, m.Flush())

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)

Expand Down
2 changes: 1 addition & 1 deletion pkg/machinery/gendata/data/tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.8.0-alpha.2
v1.8.0-alpha.1
File renamed without changes.
4 changes: 2 additions & 2 deletions website/content/v1.8/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6f7c3a8

Please sign in to comment.