Commit 7f271e4e authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Fix handling of agent-token fallback to token

parent a82d4781
...@@ -4,11 +4,11 @@ import ( ...@@ -4,11 +4,11 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"errors"
"os" "os"
"path/filepath" "path/filepath"
"reflect" "reflect"
"github.com/pkg/errors"
"github.com/rancher/k3s/pkg/bootstrap" "github.com/rancher/k3s/pkg/bootstrap"
"github.com/rancher/k3s/pkg/clientaccess" "github.com/rancher/k3s/pkg/clientaccess"
"github.com/rancher/k3s/pkg/daemons/config" "github.com/rancher/k3s/pkg/daemons/config"
...@@ -138,7 +138,7 @@ func (c *Cluster) bootstrap(ctx context.Context) error { ...@@ -138,7 +138,7 @@ func (c *Cluster) bootstrap(ctx context.Context) error {
if c.runtime.HTTPBootstrap { if c.runtime.HTTPBootstrap {
// Assuming we should just compare on managed databases // Assuming we should just compare on managed databases
if err := c.compareConfig(); err != nil { if err := c.compareConfig(); err != nil {
return err return errors.Wrap(err, "failed to validate server configuration")
} }
return c.httpBootstrap() return c.httpBootstrap()
} }
...@@ -165,7 +165,11 @@ func (c *Cluster) Snapshot(ctx context.Context, config *config.Control) error { ...@@ -165,7 +165,11 @@ func (c *Cluster) Snapshot(ctx context.Context, config *config.Control) error {
// compareConfig verifies that the config of the joining control plane node coincides with the cluster's config // compareConfig verifies that the config of the joining control plane node coincides with the cluster's config
func (c *Cluster) compareConfig() error { func (c *Cluster) compareConfig() error {
agentClientAccessInfo, err := clientaccess.ParseAndValidateTokenForUser(c.config.JoinURL, c.config.AgentToken, "node") token := c.config.AgentToken
if token == "" {
token = c.config.Token
}
agentClientAccessInfo, err := clientaccess.ParseAndValidateTokenForUser(c.config.JoinURL, token, "node")
if err != nil { if err != nil {
return err return err
} }
...@@ -186,7 +190,7 @@ func (c *Cluster) compareConfig() error { ...@@ -186,7 +190,7 @@ func (c *Cluster) compareConfig() error {
if !reflect.DeepEqual(clusterControl.CriticalControlArgs, c.config.CriticalControlArgs) { if !reflect.DeepEqual(clusterControl.CriticalControlArgs, c.config.CriticalControlArgs) {
logrus.Debugf("This is the server CriticalControlArgs: %#v", clusterControl.CriticalControlArgs) logrus.Debugf("This is the server CriticalControlArgs: %#v", clusterControl.CriticalControlArgs)
logrus.Debugf("This is the local CriticalControlArgs: %#v", c.config.CriticalControlArgs) logrus.Debugf("This is the local CriticalControlArgs: %#v", c.config.CriticalControlArgs)
return errors.New("Unable to join cluster due to critical configuration value mismatch") return errors.New("critical configuration value mismatch")
} }
return nil return nil
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment