diff --git a/go.mod b/go.mod index e3a1c458ae..29ef58c058 100644 --- a/go.mod +++ b/go.mod @@ -81,6 +81,7 @@ require ( github.com/gorilla/mux v1.7.4 github.com/gorilla/websocket v1.4.1 github.com/k3s-io/helm-controller v0.8.3 + github.com/k3s-io/kine v0.6.2 github.com/kubernetes-sigs/cri-tools v0.0.0-00010101000000-000000000000 github.com/lib/pq v1.8.0 github.com/mattn/go-sqlite3 v1.14.4 @@ -92,7 +93,6 @@ require ( github.com/pierrec/lz4 v2.5.2+incompatible github.com/pkg/errors v0.9.1 github.com/rancher/dynamiclistener v0.2.2 - github.com/rancher/kine v0.5.1 github.com/rancher/remotedialer v0.2.0 github.com/rancher/wrangler v0.6.2 github.com/rancher/wrangler-api v0.6.0 diff --git a/go.sum b/go.sum index d8502bc962..3734be98c6 100644 --- a/go.sum +++ b/go.sum @@ -475,6 +475,8 @@ github.com/k3s-io/etcd v0.5.0-alpha.5.0.20201208200253-50621aee4aea h1:7cwby0GoN github.com/k3s-io/etcd v0.5.0-alpha.5.0.20201208200253-50621aee4aea/go.mod h1:yVHk9ub3CSBatqGNg7GRmsnfLWtoW60w4eDYfh7vHDg= github.com/k3s-io/helm-controller v0.8.3 h1:GWxavyMz7Bw2ClxH5okkeOL8o5U6IBK7uauc44SDCjU= github.com/k3s-io/helm-controller v0.8.3/go.mod h1:nZP8FH3KZrNNUf5r+SwwiMR63HS6lxdHdpHijgPfF74= +github.com/k3s-io/kine v0.6.2 h1:1aJTPfB8HG4exqMKFVE5H0z4bepF05tJHtYNXotWXa4= +github.com/k3s-io/kine v0.6.2/go.mod h1:rzCs93+rQHZGOiewMd84PDrER92QeZ6eeHbWkfEy4+w= github.com/k3s-io/kubernetes v1.19.13-k3s1 h1:Kl++d1Z1z21THbkAgMrnnPH5xqKNEg5jyNxn+YR1QHw= github.com/k3s-io/kubernetes v1.19.13-k3s1/go.mod h1:HD/Q62CbvekHttYG9YffbrTHx54dkZCnF7t3oJCzxOA= github.com/k3s-io/kubernetes/staging/src/k8s.io/api v1.19.13-k3s1 h1:CMaqfM1UbCqqSQbvPFH7Rtn6ytrfNda/0jBPmjA/IzQ= diff --git a/pkg/cli/server/server.go b/pkg/cli/server/server.go index 23e7d579d2..7a3e6fcdd4 100644 --- a/pkg/cli/server/server.go +++ b/pkg/cli/server/server.go @@ -14,6 +14,7 @@ import ( "github.com/pkg/errors" "github.com/rancher/k3s/pkg/agent" "github.com/rancher/k3s/pkg/cli/cmds" + "github.com/rancher/k3s/pkg/clientaccess" "github.com/rancher/k3s/pkg/datadir" "github.com/rancher/k3s/pkg/etcd" "github.com/rancher/k3s/pkg/netutil" @@ -315,7 +316,7 @@ func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomCont } url := fmt.Sprintf("https://%s:%d", ip, serverConfig.ControlConfig.SupervisorPort) - token, err := server.FormatToken(serverConfig.ControlConfig.Runtime.AgentToken, serverConfig.ControlConfig.Runtime.ServerCA) + token, err := clientaccess.FormatToken(serverConfig.ControlConfig.Runtime.AgentToken, serverConfig.ControlConfig.Runtime.ServerCA) if err != nil { return err } diff --git a/pkg/clientaccess/token.go b/pkg/clientaccess/token.go index e0f1586adf..516293fc71 100644 --- a/pkg/clientaccess/token.go +++ b/pkg/clientaccess/token.go @@ -275,3 +275,20 @@ func get(u string, client *http.Client, username, password string) ([]byte, erro return ioutil.ReadAll(resp.Body) } + +func FormatToken(token string, certFile string) (string, error) { + if len(token) == 0 { + return token, nil + } + + certHash := "" + if len(certFile) > 0 { + bytes, err := ioutil.ReadFile(certFile) + if err != nil { + return "", nil + } + digest := sha256.Sum256(bytes) + certHash = tokenPrefix + hex.EncodeToString(digest[:]) + "::" + } + return certHash + token, nil +} diff --git a/pkg/cluster/bootstrap.go b/pkg/cluster/bootstrap.go index 15ecb3f4cb..76c119b475 100644 --- a/pkg/cluster/bootstrap.go +++ b/pkg/cluster/bootstrap.go @@ -132,7 +132,7 @@ func (c *Cluster) httpBootstrap() error { func (c *Cluster) bootstrap(ctx context.Context) error { c.joining = true - // bootstrap managed database via HTTP + // bootstrap managed database via HTTPS if c.runtime.HTTPBootstrap { return c.httpBootstrap() } diff --git a/pkg/cluster/cluster.go b/pkg/cluster/cluster.go index 65eec7e14f..3de54c122d 100644 --- a/pkg/cluster/cluster.go +++ b/pkg/cluster/cluster.go @@ -3,15 +3,16 @@ package cluster import ( "context" "net/url" + "runtime" "strings" + "github.com/k3s-io/kine/pkg/client" + "github.com/k3s-io/kine/pkg/endpoint" "github.com/pkg/errors" "github.com/rancher/k3s/pkg/clientaccess" "github.com/rancher/k3s/pkg/cluster/managed" "github.com/rancher/k3s/pkg/daemons/config" "github.com/rancher/k3s/pkg/etcd" - "github.com/rancher/kine/pkg/client" - "github.com/rancher/kine/pkg/endpoint" "github.com/sirupsen/logrus" ) @@ -77,7 +78,6 @@ func (c *Cluster) Start(ctx context.Context) (<-chan struct{}, error) { if err != nil { return nil, err } - // if necessary, store bootstrap data to datastore if c.saveBootstrap { if err := c.save(ctx); err != nil { @@ -92,7 +92,31 @@ func (c *Cluster) Start(ctx context.Context) (<-chan struct{}, error) { } } - return ready, c.startStorage(ctx) + if err := c.startStorage(ctx); err != nil { + return nil, err + } + + // at this point, if etcd is in use, it's bootstrapping is complete + // so save the bootstrap data. We will need for etcd to be up. If + // the save call returns an error, we panic since subsequent etcd + // snapshots will be empty. + if c.managedDB != nil { + go func() { + for { + select { + case <-ready: + if err := c.save(ctx); err != nil { + panic(err) + } + return + default: + runtime.Gosched() + } + } + }() + } + + return ready, nil } diff --git a/pkg/cluster/https.go b/pkg/cluster/https.go index d7fa1f0aed..c23038281d 100644 --- a/pkg/cluster/https.go +++ b/pkg/cluster/https.go @@ -6,6 +6,7 @@ import ( "log" "net" "net/http" + "os" "path/filepath" "github.com/rancher/dynamiclistener" @@ -14,6 +15,7 @@ import ( "github.com/rancher/dynamiclistener/storage/kubernetes" "github.com/rancher/dynamiclistener/storage/memory" "github.com/rancher/k3s/pkg/daemons/config" + "github.com/rancher/k3s/pkg/etcd" "github.com/rancher/k3s/pkg/version" "github.com/rancher/wrangler-api/pkg/generated/controllers/core" "github.com/sirupsen/logrus" @@ -24,16 +26,21 @@ import ( // dynamiclistener will use the cluster's Server CA to sign the dynamically generate certificate, // and will sync the certs into the Kubernetes datastore, with a local disk cache. func (c *Cluster) newListener(ctx context.Context) (net.Listener, http.Handler, error) { + if c.managedDB != nil { + if _, err := os.Stat(etcd.ResetFile(c.config)); err == nil { + // delete the dynamic listener file if it exists after restoration to fix restoration + // on fresh nodes + os.Remove(filepath.Join(c.config.DataDir, "tls/dynamic-cert.json")) + } + } tcp, err := dynamiclistener.NewTCPListener(c.config.BindAddress, c.config.SupervisorPort) if err != nil { return nil, nil, err } - cert, key, err := factory.LoadCerts(c.runtime.ServerCA, c.runtime.ServerCAKey) if err != nil { return nil, nil, err } - storage := tlsStorage(ctx, c.config.DataDir, c.runtime) return dynamiclistener.NewListener(tcp, storage, cert, key, dynamiclistener.Config{ ExpirationDaysCheck: config.CertificateRenewDays, diff --git a/pkg/cluster/managed.go b/pkg/cluster/managed.go index 5493324a5f..a7cb78ffb0 100644 --- a/pkg/cluster/managed.go +++ b/pkg/cluster/managed.go @@ -11,11 +11,11 @@ import ( "strings" "time" + "github.com/rancher/k3s/pkg/cluster/managed" "github.com/rancher/k3s/pkg/etcd" - "github.com/rancher/k3s/pkg/cluster/managed" + "github.com/k3s-io/kine/pkg/endpoint" "github.com/rancher/k3s/pkg/version" - "github.com/rancher/kine/pkg/endpoint" "github.com/sirupsen/logrus" ) diff --git a/pkg/cluster/storage.go b/pkg/cluster/storage.go index ae2364bf45..210173d7cc 100644 --- a/pkg/cluster/storage.go +++ b/pkg/cluster/storage.go @@ -3,9 +3,14 @@ package cluster import ( "bytes" "context" + "errors" + "io/ioutil" + "os" + "path/filepath" + "github.com/k3s-io/kine/pkg/client" "github.com/rancher/k3s/pkg/bootstrap" - "github.com/rancher/kine/pkg/client" + "github.com/rancher/k3s/pkg/clientaccess" "github.com/sirupsen/logrus" ) @@ -18,8 +23,20 @@ func (c *Cluster) save(ctx context.Context) error { if err := bootstrap.Write(buf, &c.runtime.ControlRuntimeBootstrap); err != nil { return err } + token := c.config.Token + if token == "" { + tokenFromFile, err := readTokenFromFile(c.runtime.ServerToken, c.runtime.ServerCA, c.config.DataDir) + if err != nil { + return err + } + token = tokenFromFile + } + normalizedToken, err := normalizeToken(token) + if err != nil { + return err + } - data, err := encrypt(c.config.Token, buf.Bytes()) + data, err := encrypt(normalizedToken, buf.Bytes()) if err != nil { return err } @@ -28,9 +45,14 @@ func (c *Cluster) save(ctx context.Context) error { return err } - if err := storageClient.Create(ctx, storageKey(c.config.Token), data); err != nil { + _, _, err = c.getBootstrapKeyFromStorage(ctx, storageClient, normalizedToken) + if err != nil { + return err + } + + if err := storageClient.Create(ctx, storageKey(normalizedToken), data); err != nil { if err.Error() == "key exists" { - logrus.Warnln("Bootstrap key exists. Please follow documentation updating a node after restore.") + logrus.Warnln("bootstrap key exists; please follow documentation on updating a node after snapshot restore") return nil } return err @@ -41,6 +63,7 @@ func (c *Cluster) save(ctx context.Context) error { // storageBootstrap loads data from the datastore into the ControlRuntimeBootstrap struct. // The storage key and encryption passphrase are both derived from the join token. +// token is either passed func (c *Cluster) storageBootstrap(ctx context.Context) error { if err := c.startStorage(ctx); err != nil { return err @@ -51,18 +74,104 @@ func (c *Cluster) storageBootstrap(ctx context.Context) error { return err } - value, err := storageClient.Get(ctx, storageKey(c.config.Token)) - if err == client.ErrNotFound { - c.saveBootstrap = true - return nil - } else if err != nil { + token := c.config.Token + if token == "" { + tokenFromFile, err := readTokenFromFile(c.runtime.ServerToken, c.runtime.ServerCA, c.config.DataDir) + if err != nil { + return err + } + if tokenFromFile == "" { + // at this point this is a fresh start in a non managed environment + c.saveBootstrap = true + return nil + } + token = tokenFromFile + } + normalizedToken, err := normalizeToken(token) + if err != nil { return err } - data, err := decrypt(c.config.Token, value.Data) + value, emptyKey, err := c.getBootstrapKeyFromStorage(ctx, storageClient, normalizedToken) + if err != nil { + return err + } + if value == nil { + return nil + } + if emptyKey { + normalizedToken = "" + } + data, err := decrypt(normalizedToken, value.Data) if err != nil { return err } return bootstrap.Read(bytes.NewBuffer(data), &c.runtime.ControlRuntimeBootstrap) } + +// getBootstrapKeyFromStorage will list all keys that has prefix /bootstrap and will check for key that is +// hashed with empty string and will check for any key that is hashed by different token than the one +// passed to it, it will return error if it finds a key that is hashed with different token and will return +// value if it finds the key hashed by passed token or empty string +func (c *Cluster) getBootstrapKeyFromStorage(ctx context.Context, storageClient client.Client, token string) (*client.Value, bool, error) { + emptyStringKey := storageKey("") + tokenKey := storageKey(token) + + bootstrapList, err := storageClient.List(ctx, "/bootstrap", 0) + if err != nil { + return nil, false, err + } + if len(bootstrapList) == 0 { + c.saveBootstrap = true + return nil, false, nil + } + if len(bootstrapList) > 1 { + return nil, false, errors.New("found more than one bootstrap keys in storage") + } + bootstrapKV := bootstrapList[0] + // checking for empty string bootstrap key + switch string(bootstrapKV.Key) { + case emptyStringKey: + logrus.Warn("bootstrap data already found and encrypted with empty string, deleting empty key") + c.saveBootstrap = true + if err := storageClient.Delete(ctx, emptyStringKey, bootstrapKV.Modified); err != nil { + return nil, false, err + } + return &bootstrapKV, true, nil + case tokenKey: + return &bootstrapKV, false, nil + } + + return nil, false, errors.New("bootstrap data already found and encrypted with different token") +} + +// readTokenFromFile will attempt to get the token from /token if it the file not found +// in case of fresh installation it will try to use the runtime serverToken saved in memory +// after stripping it from any additional information like the username or cahash, if the file +// found then it will still strip the token from any additional info +func readTokenFromFile(serverToken, certs, dataDir string) (string, error) { + tokenFile := filepath.Join(dataDir, "token") + b, err := ioutil.ReadFile(tokenFile) + if err != nil { + if os.IsNotExist(err) { + token, err := clientaccess.FormatToken(serverToken, certs) + if err != nil { + return token, err + } + return token, nil + } + return "", err + } + // strip the token from any new line if its read from file + return string(bytes.TrimRight(b, "\n")), nil +} + +// normalizeToken will normalize the token read from file or passed as a cli flag +func normalizeToken(token string) (string, error) { + _, password, ok := clientaccess.ParseUsernamePassword(token) + if !ok { + return password, errors.New("failed to normalize token") + } + return password, nil +} diff --git a/pkg/daemons/config/types.go b/pkg/daemons/config/types.go index 8225536b22..0f8cf7b218 100644 --- a/pkg/daemons/config/types.go +++ b/pkg/daemons/config/types.go @@ -9,7 +9,7 @@ import ( "sort" "strings" - "github.com/rancher/kine/pkg/endpoint" + "github.com/k3s-io/kine/pkg/endpoint" "github.com/rancher/wrangler-api/pkg/generated/controllers/core" "k8s.io/apiserver/pkg/authentication/authenticator" ) diff --git a/pkg/server/server.go b/pkg/server/server.go index 467b6b5dd0..6707dcdb81 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -2,8 +2,6 @@ package server import ( "context" - "crypto/sha256" - "encoding/hex" "fmt" "io/ioutil" net2 "net" @@ -379,30 +377,12 @@ func printToken(httpsPort int, advertiseIP, prefix, cmd string) { logrus.Infof("%s %s %s -s https://%s:%d -t ${NODE_TOKEN}", prefix, version.Program, cmd, ip, httpsPort) } -func FormatToken(token string, certFile string) (string, error) { - if len(token) == 0 { - return token, nil - } - - prefix := "K10" - if len(certFile) > 0 { - bytes, err := ioutil.ReadFile(certFile) - if err != nil { - return "", nil - } - digest := sha256.Sum256(bytes) - prefix = "K10" + hex.EncodeToString(digest[:]) + "::" - } - - return prefix + token, nil -} - func writeToken(token, file, certs string) error { if len(token) == 0 { return nil } - token, err := FormatToken(token, certs) + token, err := clientaccess.FormatToken(token, certs) if err != nil { return err } diff --git a/vendor/github.com/rancher/kine/LICENSE b/vendor/github.com/k3s-io/kine/LICENSE similarity index 100% rename from vendor/github.com/rancher/kine/LICENSE rename to vendor/github.com/k3s-io/kine/LICENSE diff --git a/vendor/github.com/rancher/kine/pkg/broadcaster/broadcaster.go b/vendor/github.com/k3s-io/kine/pkg/broadcaster/broadcaster.go similarity index 100% rename from vendor/github.com/rancher/kine/pkg/broadcaster/broadcaster.go rename to vendor/github.com/k3s-io/kine/pkg/broadcaster/broadcaster.go diff --git a/vendor/github.com/rancher/kine/pkg/client/client.go b/vendor/github.com/k3s-io/kine/pkg/client/client.go similarity index 85% rename from vendor/github.com/rancher/kine/pkg/client/client.go rename to vendor/github.com/k3s-io/kine/pkg/client/client.go index 8dfc8ae70d..812aaaa842 100644 --- a/vendor/github.com/rancher/kine/pkg/client/client.go +++ b/vendor/github.com/k3s-io/kine/pkg/client/client.go @@ -6,7 +6,7 @@ import ( "fmt" "time" - "github.com/rancher/kine/pkg/endpoint" + "github.com/k3s-io/kine/pkg/endpoint" "go.etcd.io/etcd/clientv3" ) @@ -26,6 +26,7 @@ type Client interface { Put(ctx context.Context, key string, value []byte) error Create(ctx context.Context, key string, value []byte) error Update(ctx context.Context, key string, revision int64, value []byte) error + Delete(ctx context.Context, key string, revision int64) error Close() error } @@ -128,6 +129,21 @@ func (c *client) Update(ctx context.Context, key string, revision int64, value [ return nil } +func (c *client) Delete(ctx context.Context, key string, revision int64) error { + resp, err := c.c.Txn(ctx). + If(clientv3.Compare(clientv3.ModRevision(key), "=", revision)). + Then(clientv3.OpDelete(key)). + Else(clientv3.OpGet(key)). + Commit() + if err != nil { + return err + } + if !resp.Succeeded { + return fmt.Errorf("revision %d doesnt match", revision) + } + return nil +} + func (c *client) Close() error { return c.c.Close() } diff --git a/vendor/github.com/rancher/kine/pkg/drivers/dqlite/dqlite.go b/vendor/github.com/k3s-io/kine/pkg/drivers/dqlite/dqlite.go similarity index 97% rename from vendor/github.com/rancher/kine/pkg/drivers/dqlite/dqlite.go rename to vendor/github.com/k3s-io/kine/pkg/drivers/dqlite/dqlite.go index 70226e90fe..35a99ab8bb 100644 --- a/vendor/github.com/rancher/kine/pkg/drivers/dqlite/dqlite.go +++ b/vendor/github.com/k3s-io/kine/pkg/drivers/dqlite/dqlite.go @@ -14,10 +14,10 @@ import ( "github.com/canonical/go-dqlite" "github.com/canonical/go-dqlite/client" "github.com/canonical/go-dqlite/driver" + "github.com/k3s-io/kine/pkg/drivers/generic" + "github.com/k3s-io/kine/pkg/drivers/sqlite" + "github.com/k3s-io/kine/pkg/server" "github.com/pkg/errors" - "github.com/rancher/kine/pkg/drivers/generic" - "github.com/rancher/kine/pkg/drivers/sqlite" - "github.com/rancher/kine/pkg/server" "github.com/sirupsen/logrus" ) diff --git a/vendor/github.com/rancher/kine/pkg/drivers/dqlite/no_dqlite.go b/vendor/github.com/k3s-io/kine/pkg/drivers/dqlite/no_dqlite.go similarity index 77% rename from vendor/github.com/rancher/kine/pkg/drivers/dqlite/no_dqlite.go rename to vendor/github.com/k3s-io/kine/pkg/drivers/dqlite/no_dqlite.go index bbcb85c73c..d880965867 100644 --- a/vendor/github.com/rancher/kine/pkg/drivers/dqlite/no_dqlite.go +++ b/vendor/github.com/k3s-io/kine/pkg/drivers/dqlite/no_dqlite.go @@ -6,8 +6,8 @@ import ( "context" "errors" - "github.com/rancher/kine/pkg/drivers/generic" - "github.com/rancher/kine/pkg/server" + "github.com/k3s-io/kine/pkg/drivers/generic" + "github.com/k3s-io/kine/pkg/server" ) func New(ctx context.Context, datasourceName string, connPoolConfig generic.ConnectionPoolConfig) (server.Backend, error) { diff --git a/vendor/github.com/rancher/kine/pkg/drivers/generic/generic.go b/vendor/github.com/k3s-io/kine/pkg/drivers/generic/generic.go similarity index 100% rename from vendor/github.com/rancher/kine/pkg/drivers/generic/generic.go rename to vendor/github.com/k3s-io/kine/pkg/drivers/generic/generic.go diff --git a/vendor/github.com/rancher/kine/pkg/drivers/generic/tx.go b/vendor/github.com/k3s-io/kine/pkg/drivers/generic/tx.go similarity index 100% rename from vendor/github.com/rancher/kine/pkg/drivers/generic/tx.go rename to vendor/github.com/k3s-io/kine/pkg/drivers/generic/tx.go diff --git a/vendor/github.com/rancher/kine/pkg/drivers/mysql/mysql.go b/vendor/github.com/k3s-io/kine/pkg/drivers/mysql/mysql.go similarity index 94% rename from vendor/github.com/rancher/kine/pkg/drivers/mysql/mysql.go rename to vendor/github.com/k3s-io/kine/pkg/drivers/mysql/mysql.go index f52b056e1f..9a40c33e4a 100644 --- a/vendor/github.com/rancher/kine/pkg/drivers/mysql/mysql.go +++ b/vendor/github.com/k3s-io/kine/pkg/drivers/mysql/mysql.go @@ -6,11 +6,11 @@ import ( "database/sql" "github.com/go-sql-driver/mysql" - "github.com/rancher/kine/pkg/drivers/generic" - "github.com/rancher/kine/pkg/logstructured" - "github.com/rancher/kine/pkg/logstructured/sqllog" - "github.com/rancher/kine/pkg/server" - "github.com/rancher/kine/pkg/tls" + "github.com/k3s-io/kine/pkg/drivers/generic" + "github.com/k3s-io/kine/pkg/logstructured" + "github.com/k3s-io/kine/pkg/logstructured/sqllog" + "github.com/k3s-io/kine/pkg/server" + "github.com/k3s-io/kine/pkg/tls" "github.com/sirupsen/logrus" ) diff --git a/vendor/github.com/rancher/kine/pkg/drivers/pgsql/pgsql.go b/vendor/github.com/k3s-io/kine/pkg/drivers/pgsql/pgsql.go similarity index 95% rename from vendor/github.com/rancher/kine/pkg/drivers/pgsql/pgsql.go rename to vendor/github.com/k3s-io/kine/pkg/drivers/pgsql/pgsql.go index dd410483ec..8d2669f0dd 100644 --- a/vendor/github.com/rancher/kine/pkg/drivers/pgsql/pgsql.go +++ b/vendor/github.com/k3s-io/kine/pkg/drivers/pgsql/pgsql.go @@ -8,12 +8,12 @@ import ( "strconv" "strings" + "github.com/k3s-io/kine/pkg/drivers/generic" + "github.com/k3s-io/kine/pkg/logstructured" + "github.com/k3s-io/kine/pkg/logstructured/sqllog" + "github.com/k3s-io/kine/pkg/server" + "github.com/k3s-io/kine/pkg/tls" "github.com/lib/pq" - "github.com/rancher/kine/pkg/drivers/generic" - "github.com/rancher/kine/pkg/logstructured" - "github.com/rancher/kine/pkg/logstructured/sqllog" - "github.com/rancher/kine/pkg/server" - "github.com/rancher/kine/pkg/tls" "github.com/sirupsen/logrus" ) diff --git a/vendor/github.com/rancher/kine/pkg/drivers/sqlite/sqlite.go b/vendor/github.com/k3s-io/kine/pkg/drivers/sqlite/sqlite.go similarity index 94% rename from vendor/github.com/rancher/kine/pkg/drivers/sqlite/sqlite.go rename to vendor/github.com/k3s-io/kine/pkg/drivers/sqlite/sqlite.go index 0a4be501c9..86d1086167 100644 --- a/vendor/github.com/rancher/kine/pkg/drivers/sqlite/sqlite.go +++ b/vendor/github.com/k3s-io/kine/pkg/drivers/sqlite/sqlite.go @@ -8,12 +8,12 @@ import ( "os" "time" + "github.com/k3s-io/kine/pkg/drivers/generic" + "github.com/k3s-io/kine/pkg/logstructured" + "github.com/k3s-io/kine/pkg/logstructured/sqllog" + "github.com/k3s-io/kine/pkg/server" "github.com/mattn/go-sqlite3" "github.com/pkg/errors" - "github.com/rancher/kine/pkg/drivers/generic" - "github.com/rancher/kine/pkg/logstructured" - "github.com/rancher/kine/pkg/logstructured/sqllog" - "github.com/rancher/kine/pkg/server" "github.com/sirupsen/logrus" // sqlite db driver diff --git a/vendor/github.com/rancher/kine/pkg/drivers/sqlite/sqlite_nocgo.go b/vendor/github.com/k3s-io/kine/pkg/drivers/sqlite/sqlite_nocgo.go similarity index 86% rename from vendor/github.com/rancher/kine/pkg/drivers/sqlite/sqlite_nocgo.go rename to vendor/github.com/k3s-io/kine/pkg/drivers/sqlite/sqlite_nocgo.go index 9146650efe..951319fad8 100644 --- a/vendor/github.com/rancher/kine/pkg/drivers/sqlite/sqlite_nocgo.go +++ b/vendor/github.com/k3s-io/kine/pkg/drivers/sqlite/sqlite_nocgo.go @@ -7,8 +7,8 @@ import ( "database/sql" "errors" - "github.com/rancher/kine/pkg/drivers/generic" - "github.com/rancher/kine/pkg/server" + "github.com/k3s-io/kine/pkg/drivers/generic" + "github.com/k3s-io/kine/pkg/server" ) var errNoCgo = errors.New("this binary is built without CGO, sqlite is disabled") diff --git a/vendor/github.com/rancher/kine/pkg/endpoint/endpoint.go b/vendor/github.com/k3s-io/kine/pkg/endpoint/endpoint.go similarity index 92% rename from vendor/github.com/rancher/kine/pkg/endpoint/endpoint.go rename to vendor/github.com/k3s-io/kine/pkg/endpoint/endpoint.go index b40dd18d2e..5dbd438877 100644 --- a/vendor/github.com/rancher/kine/pkg/endpoint/endpoint.go +++ b/vendor/github.com/k3s-io/kine/pkg/endpoint/endpoint.go @@ -7,14 +7,14 @@ import ( "os" "strings" + "github.com/k3s-io/kine/pkg/drivers/dqlite" + "github.com/k3s-io/kine/pkg/drivers/generic" + "github.com/k3s-io/kine/pkg/drivers/mysql" + "github.com/k3s-io/kine/pkg/drivers/pgsql" + "github.com/k3s-io/kine/pkg/drivers/sqlite" + "github.com/k3s-io/kine/pkg/server" + "github.com/k3s-io/kine/pkg/tls" "github.com/pkg/errors" - "github.com/rancher/kine/pkg/drivers/dqlite" - "github.com/rancher/kine/pkg/drivers/generic" - "github.com/rancher/kine/pkg/drivers/mysql" - "github.com/rancher/kine/pkg/drivers/pgsql" - "github.com/rancher/kine/pkg/drivers/sqlite" - "github.com/rancher/kine/pkg/server" - "github.com/rancher/kine/pkg/tls" "github.com/sirupsen/logrus" "google.golang.org/grpc" ) diff --git a/vendor/github.com/rancher/kine/pkg/logstructured/logstructured.go b/vendor/github.com/k3s-io/kine/pkg/logstructured/logstructured.go similarity index 99% rename from vendor/github.com/rancher/kine/pkg/logstructured/logstructured.go rename to vendor/github.com/k3s-io/kine/pkg/logstructured/logstructured.go index 02ed2fad08..3db92c125c 100644 --- a/vendor/github.com/rancher/kine/pkg/logstructured/logstructured.go +++ b/vendor/github.com/k3s-io/kine/pkg/logstructured/logstructured.go @@ -5,7 +5,7 @@ import ( "sync" "time" - "github.com/rancher/kine/pkg/server" + "github.com/k3s-io/kine/pkg/server" "github.com/sirupsen/logrus" ) diff --git a/vendor/github.com/rancher/kine/pkg/logstructured/sqllog/sql.go b/vendor/github.com/k3s-io/kine/pkg/logstructured/sqllog/sql.go similarity index 98% rename from vendor/github.com/rancher/kine/pkg/logstructured/sqllog/sql.go rename to vendor/github.com/k3s-io/kine/pkg/logstructured/sqllog/sql.go index b252c8cb48..5aa115ff28 100644 --- a/vendor/github.com/rancher/kine/pkg/logstructured/sqllog/sql.go +++ b/vendor/github.com/k3s-io/kine/pkg/logstructured/sqllog/sql.go @@ -6,10 +6,10 @@ import ( "strings" "time" + "github.com/k3s-io/kine/pkg/broadcaster" + "github.com/k3s-io/kine/pkg/drivers/generic" + "github.com/k3s-io/kine/pkg/server" "github.com/pkg/errors" - "github.com/rancher/kine/pkg/broadcaster" - "github.com/rancher/kine/pkg/drivers/generic" - "github.com/rancher/kine/pkg/server" "github.com/sirupsen/logrus" ) @@ -53,9 +53,9 @@ type Dialect interface { BeginTx(ctx context.Context, opts *sql.TxOptions) (*generic.Tx, error) } -func (s *SQLLog) Start(ctx context.Context) (err error) { +func (s *SQLLog) Start(ctx context.Context) error { s.ctx = ctx - return + return s.compactStart(s.ctx) } func (s *SQLLog) compactStart(ctx context.Context) error { @@ -365,10 +365,6 @@ func filter(events interface{}, checkPrefix bool, prefix string) ([]*server.Even } func (s *SQLLog) startWatch() (chan interface{}, error) { - if err := s.compactStart(s.ctx); err != nil { - return nil, err - } - pollStart, err := s.d.GetCompactRevision(s.ctx) if err != nil { return nil, err diff --git a/vendor/github.com/rancher/kine/pkg/server/compact.go b/vendor/github.com/k3s-io/kine/pkg/server/compact.go similarity index 100% rename from vendor/github.com/rancher/kine/pkg/server/compact.go rename to vendor/github.com/k3s-io/kine/pkg/server/compact.go diff --git a/vendor/github.com/rancher/kine/pkg/server/create.go b/vendor/github.com/k3s-io/kine/pkg/server/create.go similarity index 100% rename from vendor/github.com/rancher/kine/pkg/server/create.go rename to vendor/github.com/k3s-io/kine/pkg/server/create.go diff --git a/vendor/github.com/rancher/kine/pkg/server/delete.go b/vendor/github.com/k3s-io/kine/pkg/server/delete.go similarity index 100% rename from vendor/github.com/rancher/kine/pkg/server/delete.go rename to vendor/github.com/k3s-io/kine/pkg/server/delete.go diff --git a/vendor/github.com/rancher/kine/pkg/server/get.go b/vendor/github.com/k3s-io/kine/pkg/server/get.go similarity index 100% rename from vendor/github.com/rancher/kine/pkg/server/get.go rename to vendor/github.com/k3s-io/kine/pkg/server/get.go diff --git a/vendor/github.com/rancher/kine/pkg/server/lease.go b/vendor/github.com/k3s-io/kine/pkg/server/lease.go similarity index 100% rename from vendor/github.com/rancher/kine/pkg/server/lease.go rename to vendor/github.com/k3s-io/kine/pkg/server/lease.go diff --git a/vendor/github.com/rancher/kine/pkg/server/limited.go b/vendor/github.com/k3s-io/kine/pkg/server/limited.go similarity index 100% rename from vendor/github.com/rancher/kine/pkg/server/limited.go rename to vendor/github.com/k3s-io/kine/pkg/server/limited.go diff --git a/vendor/github.com/rancher/kine/pkg/server/list.go b/vendor/github.com/k3s-io/kine/pkg/server/list.go similarity index 100% rename from vendor/github.com/rancher/kine/pkg/server/list.go rename to vendor/github.com/k3s-io/kine/pkg/server/list.go diff --git a/vendor/github.com/rancher/kine/pkg/server/server.go b/vendor/github.com/k3s-io/kine/pkg/server/server.go similarity index 100% rename from vendor/github.com/rancher/kine/pkg/server/server.go rename to vendor/github.com/k3s-io/kine/pkg/server/server.go diff --git a/vendor/github.com/rancher/kine/pkg/server/types.go b/vendor/github.com/k3s-io/kine/pkg/server/types.go similarity index 100% rename from vendor/github.com/rancher/kine/pkg/server/types.go rename to vendor/github.com/k3s-io/kine/pkg/server/types.go diff --git a/vendor/github.com/rancher/kine/pkg/server/update.go b/vendor/github.com/k3s-io/kine/pkg/server/update.go similarity index 100% rename from vendor/github.com/rancher/kine/pkg/server/update.go rename to vendor/github.com/k3s-io/kine/pkg/server/update.go diff --git a/vendor/github.com/rancher/kine/pkg/server/watch.go b/vendor/github.com/k3s-io/kine/pkg/server/watch.go similarity index 100% rename from vendor/github.com/rancher/kine/pkg/server/watch.go rename to vendor/github.com/k3s-io/kine/pkg/server/watch.go diff --git a/vendor/github.com/rancher/kine/pkg/tls/config.go b/vendor/github.com/k3s-io/kine/pkg/tls/config.go similarity index 100% rename from vendor/github.com/rancher/kine/pkg/tls/config.go rename to vendor/github.com/k3s-io/kine/pkg/tls/config.go diff --git a/vendor/modules.txt b/vendor/modules.txt index 71e436f0b3..9dea3c062c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -688,6 +688,20 @@ github.com/k3s-io/helm-controller/pkg/generated/informers/externalversions/helm. github.com/k3s-io/helm-controller/pkg/generated/informers/externalversions/internalinterfaces github.com/k3s-io/helm-controller/pkg/generated/listers/helm.cattle.io/v1 github.com/k3s-io/helm-controller/pkg/helm +# github.com/k3s-io/kine v0.6.2 +## explicit +github.com/k3s-io/kine/pkg/broadcaster +github.com/k3s-io/kine/pkg/client +github.com/k3s-io/kine/pkg/drivers/dqlite +github.com/k3s-io/kine/pkg/drivers/generic +github.com/k3s-io/kine/pkg/drivers/mysql +github.com/k3s-io/kine/pkg/drivers/pgsql +github.com/k3s-io/kine/pkg/drivers/sqlite +github.com/k3s-io/kine/pkg/endpoint +github.com/k3s-io/kine/pkg/logstructured +github.com/k3s-io/kine/pkg/logstructured/sqllog +github.com/k3s-io/kine/pkg/server +github.com/k3s-io/kine/pkg/tls # github.com/karrick/godirwalk v1.7.5 github.com/karrick/godirwalk # github.com/klauspost/cpuid v1.3.1 @@ -852,20 +866,6 @@ github.com/rancher/dynamiclistener/storage/memory # github.com/rancher/go-powershell v0.0.0-20200701182037-6845e6fcfa79 github.com/rancher/go-powershell/backend github.com/rancher/go-powershell/utils -# github.com/rancher/kine v0.5.1 -## explicit -github.com/rancher/kine/pkg/broadcaster -github.com/rancher/kine/pkg/client -github.com/rancher/kine/pkg/drivers/dqlite -github.com/rancher/kine/pkg/drivers/generic -github.com/rancher/kine/pkg/drivers/mysql -github.com/rancher/kine/pkg/drivers/pgsql -github.com/rancher/kine/pkg/drivers/sqlite -github.com/rancher/kine/pkg/endpoint -github.com/rancher/kine/pkg/logstructured -github.com/rancher/kine/pkg/logstructured/sqllog -github.com/rancher/kine/pkg/server -github.com/rancher/kine/pkg/tls # github.com/rancher/remotedialer v0.2.0 ## explicit github.com/rancher/remotedialer