mirror of https://github.com/k3s-io/k3s
Fix handling of agent-token fallback to token
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>pull/4917/head
parent
4decce56a3
commit
0a1f013f68
|
@ -4,7 +4,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -20,6 +19,7 @@ import (
|
||||||
"github.com/k3s-io/kine/pkg/client"
|
"github.com/k3s-io/kine/pkg/client"
|
||||||
"github.com/k3s-io/kine/pkg/endpoint"
|
"github.com/k3s-io/kine/pkg/endpoint"
|
||||||
"github.com/otiai10/copy"
|
"github.com/otiai10/copy"
|
||||||
|
"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"
|
||||||
|
@ -615,7 +615,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(ctx)
|
return c.httpBootstrap(ctx)
|
||||||
}
|
}
|
||||||
|
@ -635,7 +635,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
|
||||||
}
|
}
|
||||||
|
@ -655,7 +659,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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue