Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to klog #11

Merged
merged 4 commits into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions cmd/virtual-kubelet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import (
"context"
"strings"

"github.com/elotl/cloud-instance-provider/pkg/glog"
"github.com/elotl/cloud-instance-provider/pkg/klog"
"github.com/elotl/cloud-instance-provider/pkg/server"
"github.com/elotl/cloud-instance-provider/pkg/util/habitat"
cli "github.com/virtual-kubelet/node-cli"
opencensuscli "github.com/virtual-kubelet/node-cli/opencensus"
"github.com/virtual-kubelet/node-cli/opts"
Expand All @@ -39,7 +40,7 @@ var (
func main() {
ctx := cli.ContextWithCancelOnSignal(context.Background())

log.L = glog.NewGlogAdapter()
log.L = klog.NewKlogAdapter()

trace.T = opencensus.Adapter{}
traceConfig := opencensuscli.Config{
Expand All @@ -63,10 +64,21 @@ func main() {
cli.WithCLIVersion(buildVersion, buildTime),
cli.WithProvider("cloud-instance-provider",
func(cfg provider.InitConfig) (provider.Provider, error) {
internalIP := cfg.InternalIP
if internalIP == "" {
internalIP = habitat.GetMyIP()
if internalIP == "" {
ips := habitat.GetIPAddresses()
if len(ips) > 0 {
internalIP = ips[0]
}
}
}
log.G(ctx).Infof("node internal IP address: %q", internalIP)
return server.NewInstanceProvider(
cfg.ConfigPath,
cfg.NodeName,
cfg.InternalIP,
internalIP,
cfg.DaemonPort,
serverConfig.DebugServer,
cfg.ResourceManager,
Expand Down
2 changes: 2 additions & 0 deletions deploy/virtual-kubelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ spec:
- cloud-instance-provider
- --provider-config
- /etc/virtual-kubelet/server.yml
- --klog.logtostderr
- --klog.v=5
image: elotl/virtual-kubelet:dev
imagePullPolicy: Always
name: virtual-kubelet
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package api
import (
"github.com/json-iterator/go"

"github.com/golang/glog"
"k8s.io/klog"
)

var json = jsoniter.ConfigCompatibleWithStandardLibrary
Expand Down Expand Up @@ -37,7 +37,7 @@ func (c JsonCodec) Marshal(i interface{}) ([]byte, error) {
func warnIfUnversioned(t TypeVersioner) {
version := t.GetAPIVersion()
if version == "" {
glog.Warningf("Found empty API version in registry for %v", t)
klog.Warningf("Found empty API version in registry for %v", t)
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/certs/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/docker/libkv/store"
"github.com/elotl/cloud-instance-provider/pkg/etcd"
"github.com/elotl/cloud-instance-provider/pkg/util"
"github.com/golang/glog"
"k8s.io/klog"
)

const (
Expand All @@ -33,7 +33,7 @@ func New(kvstore etcd.Storer) (*CertificateFactory, error) {
certFactory.kvstore.Put(CertificateDirectoryPlaceholder, []byte("."), nil)
err := certFactory.GetRootFromStore()
if err == store.ErrKeyNotFound {
glog.Infof("Initializing Milpa root certificate")
klog.V(2).Infof("Initializing Milpa root certificate")
certFactory.InitRootCert()
} else if err != nil {
return nil, util.WrapError(err, "Error creating Milpa PKI")
Expand Down
12 changes: 6 additions & 6 deletions pkg/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"github.com/coreos/etcd/pkg/transport"
"github.com/docker/libkv/store"
"github.com/elotl/cloud-instance-provider/pkg/util"
"github.com/golang/glog"
"golang.org/x/sys/unix"
"k8s.io/klog"
)

var (
Expand All @@ -37,7 +37,7 @@ func ensureEtcdDataDir(dataDir string) error {
errMsg := fmt.Sprintf("Could not create milpa storage directory at %s, please verify the directory exists and is writable by milpa. The error was", dataDir)
_, err := os.Stat(dataDir)
if os.IsNotExist(err) {
glog.Infof("Creating milpa data directory at %s", dataDir)
klog.V(2).Infof("Creating milpa data directory at %s", dataDir)
err := os.MkdirAll(dataDir, 0750)
if err != nil {
return util.WrapError(err, errMsg)
Expand Down Expand Up @@ -86,13 +86,13 @@ func (s *EtcdServer) Start(quit <-chan struct{}, wg *sync.WaitGroup) error {
cfg.LCUrls = []url.URL{}
}
if cfg.AutoCompactionMode == "" {
glog.Info("Setting etcd compaction mode to periodic")
klog.V(2).Info("Setting etcd compaction mode to periodic")
cfg.AutoCompactionMode = compactor.ModePeriodic
}
if cfg.AutoCompactionMode == compactor.ModePeriodic &&
cfg.AutoCompactionRetention == "" {
cfg.AutoCompactionRetention = "1"
glog.Info("Setting etcd compaction interval to 1 hour")
klog.V(2).Info("Setting etcd compaction interval to 1 hour")
}

err = s.reconcileDataDirectoryValues(cfg)
Expand All @@ -110,7 +110,7 @@ func (s *EtcdServer) Start(quit <-chan struct{}, wg *sync.WaitGroup) error {
}
select {
case <-s.Proc.Server.ReadyNotify():
glog.Info("Etcd server is ready to serve requests")
klog.V(2).Info("Etcd server is ready to serve requests")
case <-time.After(60 * time.Second):
s.Proc.Server.Stop()
s.Proc.Close()
Expand All @@ -127,7 +127,7 @@ func (s *EtcdServer) Start(quit <-chan struct{}, wg *sync.WaitGroup) error {
<-quit
// if we don't pause, clients will crash, it's a bad look.
pause := 2 * time.Second
glog.Infof("Pausing for %ds before shutting down etcd...", int(pause.Seconds()))
klog.V(2).Infof("Pausing for %ds before shutting down etcd...", int(pause.Seconds()))
time.Sleep(pause)
s.Proc.Server.Stop()
s.Proc.Close()
Expand Down
4 changes: 2 additions & 2 deletions pkg/etcd/etcd_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"
"sync"

"github.com/golang/glog"
"k8s.io/klog"
)

func SetupEmbeddedEtcdTest() (*SimpleEtcd, func(), error) {
Expand All @@ -18,7 +18,7 @@ func SetupEmbeddedEtcdTest() (*SimpleEtcd, func(), error) {
closer := func() {
quit <- struct{}{}
if err := os.RemoveAll(dataDir); err != nil {
glog.Fatal("Error removing etcd data directory")
klog.Fatal("Error removing etcd data directory")
}
}
db := EtcdServer{
Expand Down
129 changes: 0 additions & 129 deletions pkg/glog/adapter.go

This file was deleted.

Loading