Move from glog to klog
- Move from the old github.com/golang/glog to k8s.io/klog - klog as explicit InitFlags() so we add them as necessary - we update the other repositories that we vendor that made a similar change from glog to klog * github.com/kubernetes/repo-infra * k8s.io/gengo/ * k8s.io/kube-openapi/ * github.com/google/cadvisor - Entirely remove all references to glog - Fix some tests by explicit InitFlags in their init() methods Change-Id: I92db545ff36fcec83afe98f550c9e630098b3135
This commit is contained in:
@@ -22,7 +22,7 @@ go_library(
|
||||
"//staging/src/k8s.io/client-go/rest:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/tools/clientcmd:go_default_library",
|
||||
"//staging/src/k8s.io/client-go/tools/clientcmd/api:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/klog:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
@@ -24,11 +24,11 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
clientapi "k8s.io/client-go/tools/clientcmd/api"
|
||||
"k8s.io/klog"
|
||||
api "k8s.io/kubernetes/pkg/apis/core"
|
||||
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
|
||||
)
|
||||
@@ -61,22 +61,22 @@ func flattenSubsets(subsets []api.EndpointSubset) []string {
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
glog.Info("Kubernetes Elasticsearch logging discovery")
|
||||
klog.Info("Kubernetes Elasticsearch logging discovery")
|
||||
|
||||
cc, err := buildConfigFromEnvs(os.Getenv("APISERVER_HOST"), os.Getenv("KUBE_CONFIG_FILE"))
|
||||
if err != nil {
|
||||
glog.Fatalf("Failed to make client: %v", err)
|
||||
klog.Fatalf("Failed to make client: %v", err)
|
||||
}
|
||||
client, err := clientset.NewForConfig(cc)
|
||||
|
||||
if err != nil {
|
||||
glog.Fatalf("Failed to make client: %v", err)
|
||||
klog.Fatalf("Failed to make client: %v", err)
|
||||
}
|
||||
namespace := metav1.NamespaceSystem
|
||||
envNamespace := os.Getenv("NAMESPACE")
|
||||
if envNamespace != "" {
|
||||
if _, err := client.Core().Namespaces().Get(envNamespace, metav1.GetOptions{}); err != nil {
|
||||
glog.Fatalf("%s namespace doesn't exist: %v", envNamespace, err)
|
||||
klog.Fatalf("%s namespace doesn't exist: %v", envNamespace, err)
|
||||
}
|
||||
namespace = envNamespace
|
||||
}
|
||||
@@ -98,7 +98,7 @@ func main() {
|
||||
// If we did not find an elasticsearch logging service then log a warning
|
||||
// and return without adding any unicast hosts.
|
||||
if elasticsearch == nil {
|
||||
glog.Warningf("Failed to find the elasticsearch-logging service: %v", err)
|
||||
klog.Warningf("Failed to find the elasticsearch-logging service: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -112,17 +112,17 @@ func main() {
|
||||
continue
|
||||
}
|
||||
addrs = flattenSubsets(endpoints.Subsets)
|
||||
glog.Infof("Found %s", addrs)
|
||||
klog.Infof("Found %s", addrs)
|
||||
if len(addrs) > 0 && len(addrs) >= count {
|
||||
break
|
||||
}
|
||||
}
|
||||
// If there was an error finding endpoints then log a warning and quit.
|
||||
if err != nil {
|
||||
glog.Warningf("Error finding endpoints: %v", err)
|
||||
klog.Warningf("Error finding endpoints: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
glog.Infof("Endpoints = %s", addrs)
|
||||
klog.Infof("Endpoints = %s", addrs)
|
||||
fmt.Printf("discovery.zen.ping.unicast.hosts: [%s]\n", strings.Join(addrs, ", "))
|
||||
}
|
||||
|
@@ -17,12 +17,12 @@ go_library(
|
||||
importpath = "k8s.io/kubernetes/cluster/images/etcd-version-monitor",
|
||||
deps = [
|
||||
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
|
||||
"//vendor/github.com/prometheus/client_golang/prometheus/promhttp:go_default_library",
|
||||
"//vendor/github.com/prometheus/client_model/go:go_default_library",
|
||||
"//vendor/github.com/prometheus/common/expfmt:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
"//vendor/k8s.io/klog:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
@@ -25,12 +25,12 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/golang/glog"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
dto "github.com/prometheus/client_model/go"
|
||||
"github.com/prometheus/common/expfmt"
|
||||
"github.com/spf13/pflag"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
// Initialize the prometheus instrumentation and client related flags.
|
||||
@@ -245,7 +245,7 @@ func getVersionPeriodically(stopCh <-chan struct{}) {
|
||||
lastSeenBinaryVersion := ""
|
||||
for {
|
||||
if err := getVersion(&lastSeenBinaryVersion); err != nil {
|
||||
glog.Errorf("Failed to fetch etcd version: %v", err)
|
||||
klog.Errorf("Failed to fetch etcd version: %v", err)
|
||||
}
|
||||
select {
|
||||
case <-stopCh:
|
||||
@@ -399,7 +399,7 @@ func main() {
|
||||
go getVersionPeriodically(stopCh)
|
||||
|
||||
// Serve our metrics on listenAddress/metricsPath.
|
||||
glog.Infof("Listening on: %v", listenAddress)
|
||||
klog.Infof("Listening on: %v", listenAddress)
|
||||
http.Handle(metricsPath, promhttp.HandlerFor(gatherer, promhttp.HandlerOpts{}))
|
||||
glog.Errorf("Stopped listening/serving metrics: %v", http.ListenAndServe(listenAddress, nil))
|
||||
klog.Errorf("Stopped listening/serving metrics: %v", http.ListenAndServe(listenAddress, nil))
|
||||
}
|
||||
|
@@ -42,8 +42,8 @@ go_library(
|
||||
"//vendor/github.com/coreos/etcd/wal:go_default_library",
|
||||
"//vendor/github.com/coreos/etcd/wal/walpb:go_default_library",
|
||||
"//vendor/github.com/coreos/go-semver/semver:go_default_library",
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/github.com/spf13/cobra:go_default_library",
|
||||
"//vendor/k8s.io/klog:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
@@ -25,7 +25,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
// DataDirectory provides utilities for initializing and backing up an
|
||||
@@ -45,7 +45,7 @@ func OpenOrCreateDataDirectory(path string) (*DataDirectory, error) {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
glog.Infof("data directory '%s' does not exist, creating it", path)
|
||||
klog.Infof("data directory '%s' does not exist, creating it", path)
|
||||
err := os.MkdirAll(path, 0777)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create data directory %s: %v", path, err)
|
||||
@@ -67,7 +67,7 @@ func (d *DataDirectory) Initialize(target *EtcdVersionPair) error {
|
||||
return err
|
||||
}
|
||||
if isEmpty {
|
||||
glog.Infof("data directory '%s' is empty, writing target version '%s' to version.txt", d.path, target)
|
||||
klog.Infof("data directory '%s' is empty, writing target version '%s' to version.txt", d.path, target)
|
||||
err = d.versionFile.Write(target)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to write version.txt to '%s': %v", d.path, err)
|
||||
|
@@ -21,8 +21,8 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/cobra"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -85,7 +85,7 @@ func runMigrate() {
|
||||
if opts.name == "" {
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
glog.Errorf("Error while getting hostname to supply default --name: %v", err)
|
||||
klog.Errorf("Error while getting hostname to supply default --name: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
opts.name = fmt.Sprintf("etcd-%s", hostname)
|
||||
@@ -98,29 +98,29 @@ func runMigrate() {
|
||||
opts.initialCluster = fmt.Sprintf("%s=http://localhost:2380", opts.name)
|
||||
}
|
||||
if opts.targetStorage == "" {
|
||||
glog.Errorf("--target-storage is required")
|
||||
klog.Errorf("--target-storage is required")
|
||||
os.Exit(1)
|
||||
}
|
||||
if opts.targetVersion == "" {
|
||||
glog.Errorf("--target-version is required")
|
||||
klog.Errorf("--target-version is required")
|
||||
os.Exit(1)
|
||||
}
|
||||
if opts.dataDir == "" {
|
||||
glog.Errorf("--data-dir is required")
|
||||
klog.Errorf("--data-dir is required")
|
||||
os.Exit(1)
|
||||
}
|
||||
if opts.bundledVersionString == "" {
|
||||
glog.Errorf("--bundled-versions is required")
|
||||
klog.Errorf("--bundled-versions is required")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
bundledVersions, err := ParseSupportedVersions(opts.bundledVersionString)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to parse --supported-versions: %v", err)
|
||||
klog.Errorf("Failed to parse --supported-versions: %v", err)
|
||||
}
|
||||
err = validateBundledVersions(bundledVersions, opts.binDir)
|
||||
if err != nil {
|
||||
glog.Errorf("Failed to validate that 'etcd-<version>' and 'etcdctl-<version>' binaries exist in --bin-dir '%s' for all --bundled-verions '%s': %v",
|
||||
klog.Errorf("Failed to validate that 'etcd-<version>' and 'etcdctl-<version>' binaries exist in --bin-dir '%s' for all --bundled-verions '%s': %v",
|
||||
opts.binDir, opts.bundledVersionString, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
@@ -139,7 +139,7 @@ func migrate(name string, port uint64, peerListenUrls string, peerAdvertiseUrls
|
||||
|
||||
dataDir, err := OpenOrCreateDataDirectory(dataDirPath)
|
||||
if err != nil {
|
||||
glog.Errorf("Error opening or creating data directory %s: %v", dataDirPath, err)
|
||||
klog.Errorf("Error opening or creating data directory %s: %v", dataDirPath, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ func migrate(name string, port uint64, peerListenUrls string, peerAdvertiseUrls
|
||||
}
|
||||
client, err := NewEtcdMigrateClient(cfg)
|
||||
if err != nil {
|
||||
glog.Errorf("Migration failed: %v", err)
|
||||
klog.Errorf("Migration failed: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer client.Close()
|
||||
@@ -167,7 +167,7 @@ func migrate(name string, port uint64, peerListenUrls string, peerAdvertiseUrls
|
||||
|
||||
err = migrator.MigrateIfNeeded(target)
|
||||
if err != nil {
|
||||
glog.Errorf("Migration failed: %v", err)
|
||||
klog.Errorf("Migration failed: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ import (
|
||||
|
||||
clientv2 "github.com/coreos/etcd/client"
|
||||
"github.com/coreos/etcd/clientv3"
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
// CombinedEtcdClient provides an implementation of EtcdMigrateClient using a combination of the etcd v2 client, v3 client
|
||||
@@ -202,13 +202,13 @@ func (e *CombinedEtcdClient) AttachLease(leaseDuration time.Duration) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error while creating lease: %v", err)
|
||||
}
|
||||
glog.Infof("Lease with TTL: %v created", lease.TTL)
|
||||
klog.Infof("Lease with TTL: %v created", lease.TTL)
|
||||
|
||||
glog.Infof("Attaching lease to %d entries", len(objectsResp.Kvs))
|
||||
klog.Infof("Attaching lease to %d entries", len(objectsResp.Kvs))
|
||||
for _, kv := range objectsResp.Kvs {
|
||||
putResp, err := v3client.KV.Put(ctx, string(kv.Key), string(kv.Value), clientv3.WithLease(lease.ID), clientv3.WithPrevKV())
|
||||
if err != nil {
|
||||
glog.Errorf("Error while attaching lease to: %s", string(kv.Key))
|
||||
klog.Errorf("Error while attaching lease to: %s", string(kv.Key))
|
||||
}
|
||||
if bytes.Compare(putResp.PrevKv.Value, kv.Value) != 0 {
|
||||
return fmt.Errorf("concurrent access to key detected when setting lease on %s, expected previous value of %s but got %s",
|
||||
|
@@ -23,7 +23,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
// EtcdMigrateServer manages starting and stopping a versioned etcd server binary.
|
||||
@@ -75,10 +75,10 @@ func (r *EtcdMigrateServer) Start(version *EtcdVersion) error {
|
||||
case <-interval.C:
|
||||
err := r.client.SetEtcdVersionKeyValue(version)
|
||||
if err != nil {
|
||||
glog.Infof("Still waiting for etcd to start, current error: %v", err)
|
||||
klog.Infof("Still waiting for etcd to start, current error: %v", err)
|
||||
// keep waiting
|
||||
} else {
|
||||
glog.Infof("Etcd on port %d is up.", r.cfg.port)
|
||||
klog.Infof("Etcd on port %d is up.", r.cfg.port)
|
||||
r.cmd = etcdCmd
|
||||
return nil
|
||||
}
|
||||
@@ -114,7 +114,7 @@ func (r *EtcdMigrateServer) Stop() error {
|
||||
case <-stopped:
|
||||
return
|
||||
case <-timedout:
|
||||
glog.Infof("etcd server has not terminated gracefully after %s, killing it.", gracefulWait)
|
||||
klog.Infof("etcd server has not terminated gracefully after %s, killing it.", gracefulWait)
|
||||
r.cmd.Process.Kill()
|
||||
return
|
||||
}
|
||||
@@ -122,11 +122,11 @@ func (r *EtcdMigrateServer) Stop() error {
|
||||
err = r.cmd.Wait()
|
||||
stopped <- true
|
||||
if exiterr, ok := err.(*exec.ExitError); ok {
|
||||
glog.Infof("etcd server stopped (signal: %s)", exiterr.Error())
|
||||
klog.Infof("etcd server stopped (signal: %s)", exiterr.Error())
|
||||
// stopped
|
||||
} else if err != nil {
|
||||
return fmt.Errorf("error waiting for etcd to stop: %v", err)
|
||||
}
|
||||
glog.Infof("Stopped etcd server %s", r.cfg.name)
|
||||
klog.Infof("Stopped etcd server %s", r.cfg.name)
|
||||
return nil
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/blang/semver"
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
// EtcdMigrateCfg provides all configuration required to perform etcd data upgrade/downgrade migrations.
|
||||
@@ -63,7 +63,7 @@ type Migrator struct {
|
||||
|
||||
// MigrateIfNeeded upgrades or downgrades the etcd data directory to the given target version.
|
||||
func (m *Migrator) MigrateIfNeeded(target *EtcdVersionPair) error {
|
||||
glog.Infof("Starting migration to %s", target)
|
||||
klog.Infof("Starting migration to %s", target)
|
||||
err := m.dataDirectory.Initialize(target)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to initialize data directory %s: %v", m.dataDirectory.path, err)
|
||||
@@ -84,28 +84,28 @@ func (m *Migrator) MigrateIfNeeded(target *EtcdVersionPair) error {
|
||||
}
|
||||
|
||||
for {
|
||||
glog.Infof("Converging current version '%s' to target version '%s'", current, target)
|
||||
klog.Infof("Converging current version '%s' to target version '%s'", current, target)
|
||||
currentNextMinorVersion := &EtcdVersion{Version: semver.Version{Major: current.version.Major, Minor: current.version.Minor + 1}}
|
||||
switch {
|
||||
case current.version.MajorMinorEquals(target.version) || currentNextMinorVersion.MajorMinorEquals(target.version):
|
||||
glog.Infof("current version '%s' equals or is one minor version previous of target version '%s' - migration complete", current, target)
|
||||
klog.Infof("current version '%s' equals or is one minor version previous of target version '%s' - migration complete", current, target)
|
||||
err = m.dataDirectory.versionFile.Write(target)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to write version.txt to '%s': %v", m.dataDirectory.path, err)
|
||||
}
|
||||
return nil
|
||||
case current.storageVersion == storageEtcd2 && target.storageVersion == storageEtcd3:
|
||||
glog.Infof("upgrading from etcd2 storage to etcd3 storage")
|
||||
klog.Infof("upgrading from etcd2 storage to etcd3 storage")
|
||||
current, err = m.etcd2ToEtcd3Upgrade(current, target)
|
||||
case current.version.Major == 3 && target.version.Major == 2:
|
||||
glog.Infof("downgrading from etcd 3.x to 2.x")
|
||||
klog.Infof("downgrading from etcd 3.x to 2.x")
|
||||
current, err = m.rollbackToEtcd2(current, target)
|
||||
case current.version.Major == target.version.Major && current.version.Minor < target.version.Minor:
|
||||
stepVersion := m.cfg.supportedVersions.NextVersionPair(current)
|
||||
glog.Infof("upgrading etcd from %s to %s", current, stepVersion)
|
||||
klog.Infof("upgrading etcd from %s to %s", current, stepVersion)
|
||||
current, err = m.minorVersionUpgrade(current, stepVersion)
|
||||
case current.version.Major == 3 && target.version.Major == 3 && current.version.Minor > target.version.Minor:
|
||||
glog.Infof("rolling etcd back from %s to %s", current, target)
|
||||
klog.Infof("rolling etcd back from %s to %s", current, target)
|
||||
current, err = m.rollbackEtcd3MinorVersion(current, target)
|
||||
}
|
||||
if err != nil {
|
||||
@@ -116,13 +116,13 @@ func (m *Migrator) MigrateIfNeeded(target *EtcdVersionPair) error {
|
||||
|
||||
func (m *Migrator) backupEtcd2(current *EtcdVersion) error {
|
||||
backupDir := fmt.Sprintf("%s/%s", m.dataDirectory, "migration-backup")
|
||||
glog.Infof("Backup etcd before starting migration")
|
||||
klog.Infof("Backup etcd before starting migration")
|
||||
err := os.Mkdir(backupDir, 0666)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create backup directory before starting migration: %v", err)
|
||||
}
|
||||
m.client.Backup(current, backupDir)
|
||||
glog.Infof("Backup done in %s", backupDir)
|
||||
klog.Infof("Backup done in %s", backupDir)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ func (m *Migrator) rollbackEtcd3MinorVersion(current *EtcdVersionPair, target *E
|
||||
return nil, fmt.Errorf("rollback from %s to %s not supported, only rollbacks to the previous minor version are supported", current.version, target.version)
|
||||
}
|
||||
|
||||
glog.Infof("Performing etcd %s -> %s rollback", current.version, target.version)
|
||||
klog.Infof("Performing etcd %s -> %s rollback", current.version, target.version)
|
||||
err := m.dataDirectory.Backup()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -145,14 +145,14 @@ func (m *Migrator) rollbackEtcd3MinorVersion(current *EtcdVersionPair, target *E
|
||||
|
||||
// Start current version of etcd.
|
||||
runner := m.newServer()
|
||||
glog.Infof("Starting etcd version %s to capture rollback snapshot.", current.version)
|
||||
klog.Infof("Starting etcd version %s to capture rollback snapshot.", current.version)
|
||||
err = runner.Start(current.version)
|
||||
if err != nil {
|
||||
glog.Fatalf("Unable to automatically downgrade etcd: starting etcd version %s to capture rollback snapshot failed: %v", current.version, err)
|
||||
klog.Fatalf("Unable to automatically downgrade etcd: starting etcd version %s to capture rollback snapshot failed: %v", current.version, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
glog.Infof("Snapshotting etcd %s to %s", current.version, snapshotFilename)
|
||||
klog.Infof("Snapshotting etcd %s to %s", current.version, snapshotFilename)
|
||||
err = m.client.Snapshot(current.version, snapshotFilename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -163,7 +163,7 @@ func (m *Migrator) rollbackEtcd3MinorVersion(current *EtcdVersionPair, target *E
|
||||
return nil, err
|
||||
}
|
||||
|
||||
glog.Infof("Backing up data before rolling back")
|
||||
klog.Infof("Backing up data before rolling back")
|
||||
backupDir := fmt.Sprintf("%s.bak", m.dataDirectory)
|
||||
err = os.RemoveAll(backupDir)
|
||||
if err != nil {
|
||||
@@ -178,7 +178,7 @@ func (m *Migrator) rollbackEtcd3MinorVersion(current *EtcdVersionPair, target *E
|
||||
return nil, err
|
||||
}
|
||||
|
||||
glog.Infof("Restoring etcd %s from %s", target.version, snapshotFilename)
|
||||
klog.Infof("Restoring etcd %s from %s", target.version, snapshotFilename)
|
||||
err = m.client.Restore(target.version, snapshotFilename)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -195,7 +195,7 @@ func (m *Migrator) rollbackToEtcd2(current *EtcdVersionPair, target *EtcdVersion
|
||||
if !(current.version.Major == 3 && current.version.Minor == 0 && target.version.Major == 2 && target.version.Minor == 2) {
|
||||
return nil, fmt.Errorf("etcd3 -> etcd2 downgrade is supported only between 3.0.x and 2.2.x, got current %s target %s", current, target)
|
||||
}
|
||||
glog.Infof("Backup and remove all existing v2 data")
|
||||
klog.Infof("Backup and remove all existing v2 data")
|
||||
err := m.dataDirectory.Backup()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -214,12 +214,12 @@ func (m *Migrator) etcd2ToEtcd3Upgrade(current *EtcdVersionPair, target *EtcdVer
|
||||
}
|
||||
runner := m.newServer()
|
||||
|
||||
glog.Infof("Performing etcd2 -> etcd3 migration")
|
||||
klog.Infof("Performing etcd2 -> etcd3 migration")
|
||||
err := m.client.Migrate(target.version)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
glog.Infof("Attaching leases to TTL entries")
|
||||
klog.Infof("Attaching leases to TTL entries")
|
||||
|
||||
// Now attach lease to all keys.
|
||||
// To do it, we temporarily start etcd on a random port (so that
|
||||
|
@@ -42,7 +42,7 @@ import (
|
||||
"github.com/coreos/etcd/wal"
|
||||
"github.com/coreos/etcd/wal/walpb"
|
||||
"github.com/coreos/go-semver/semver"
|
||||
"github.com/golang/glog"
|
||||
"k8s.io/klog"
|
||||
)
|
||||
|
||||
const rollbackVersion = "2.2.0"
|
||||
@@ -50,7 +50,7 @@ const rollbackVersion = "2.2.0"
|
||||
// RollbackV3ToV2 rolls back an etcd 3.0.x data directory to the 2.x.x version specified by rollbackVersion.
|
||||
func RollbackV3ToV2(migrateDatadir string, ttl time.Duration) error {
|
||||
dbpath := path.Join(migrateDatadir, "member", "snap", "db")
|
||||
glog.Infof("Rolling db file %s back to etcd 2.x", dbpath)
|
||||
klog.Infof("Rolling db file %s back to etcd 2.x", dbpath)
|
||||
|
||||
// etcd3 store backend. We will use it to parse v3 data files and extract information.
|
||||
be := backend.NewDefaultBackend(dbpath)
|
||||
@@ -139,7 +139,7 @@ func RollbackV3ToV2(migrateDatadir string, ttl time.Duration) error {
|
||||
v = rollbackVersion
|
||||
}
|
||||
if _, err := st.Set(n.Key, n.Dir, v, store.TTLOptionSet{}); err != nil {
|
||||
glog.Error(err)
|
||||
klog.Error(err)
|
||||
}
|
||||
|
||||
// update nodes
|
||||
@@ -147,7 +147,7 @@ func RollbackV3ToV2(migrateDatadir string, ttl time.Duration) error {
|
||||
if len(fields) == 4 && fields[2] == "members" {
|
||||
nodeID, err := strconv.ParseUint(fields[3], 16, 64)
|
||||
if err != nil {
|
||||
glog.Fatalf("failed to parse member ID (%s): %v", fields[3], err)
|
||||
klog.Fatalf("failed to parse member ID (%s): %v", fields[3], err)
|
||||
}
|
||||
nodes = append(nodes, nodeID)
|
||||
}
|
||||
@@ -172,7 +172,7 @@ func RollbackV3ToV2(migrateDatadir string, ttl time.Duration) error {
|
||||
if err := snapshotter.SaveSnap(raftSnap); err != nil {
|
||||
return err
|
||||
}
|
||||
glog.Infof("Finished successfully")
|
||||
klog.Infof("Finished successfully")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ func traverseAndDeleteEmptyDir(st store.Store, dir string) error {
|
||||
}
|
||||
for _, node := range e.Node.Nodes {
|
||||
if !node.Dir {
|
||||
glog.V(2).Infof("key: %s", node.Key[len(etcdserver.StoreKeysPrefix):])
|
||||
klog.V(2).Infof("key: %s", node.Key[len(etcdserver.StoreKeysPrefix):])
|
||||
} else {
|
||||
err := traverseAndDeleteEmptyDir(st, node.Key)
|
||||
if err != nil {
|
||||
@@ -344,6 +344,6 @@ func applyRequest(r *pb.Request, applyV2 etcdserver.ApplierV2) {
|
||||
case "POST", "QGET", "SYNC":
|
||||
return
|
||||
default:
|
||||
glog.Fatal("unknown command")
|
||||
klog.Fatal("unknown command")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user