From ad79e8dfcf7f81e2f69abf8f449996e5c12387f4 Mon Sep 17 00:00:00 2001 From: Andrew Rynhard Date: Sun, 11 Aug 2019 19:39:56 +0000 Subject: [PATCH] feat: remove the machine config on reset This wil remove the machine config on a reset so that a new machine configwill be downloaded and used on a reboot. Signed-off-by: Andrew Rynhard --- internal/app/machined/internal/api/reg/reg.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/app/machined/internal/api/reg/reg.go b/internal/app/machined/internal/api/reg/reg.go index 0f6657d70..fa0885969 100644 --- a/internal/app/machined/internal/api/reg/reg.go +++ b/internal/app/machined/internal/api/reg/reg.go @@ -26,6 +26,7 @@ import ( "github.com/talos-systems/talos/internal/pkg/upgrade" "github.com/talos-systems/talos/pkg/archiver" "github.com/talos-systems/talos/pkg/chunker/stream" + "github.com/talos-systems/talos/pkg/constants" "github.com/talos-systems/talos/pkg/userdata" ) @@ -104,16 +105,21 @@ func (r *Registrator) Upgrade(ctx context.Context, in *proto.UpgradeRequest) (da // Reset initiates a Talos upgrade func (r *Registrator) Reset(ctx context.Context, in *empty.Empty) (data *proto.ResetReply, err error) { - // stop kubelet + // Stop the kubelet. if _, err = r.Stop(ctx, &proto.StopRequest{Id: "kubelet"}); err != nil { return data, err } - // kubeadm Reset + // Run `kubeadm reset`. if err = upgrade.Reset(); err != nil { return data, err } + // Remove the machine config. + if err = os.Remove(constants.UserDataPath); err != nil { + return nil, err + } + return &proto.ResetReply{}, err }