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:
Davanum Srinivas
2018-11-09 13:49:10 -05:00
parent 97baad34a7
commit 954996e231
1263 changed files with 10023 additions and 10076 deletions

View File

@@ -27,7 +27,7 @@ import (
"testing"
"time"
"github.com/golang/glog"
"k8s.io/klog"
"k8s.io/api/core/v1"
storage "k8s.io/api/storage/v1"
@@ -159,7 +159,7 @@ func (r *volumeReactor) React(action core.Action) (handled bool, ret runtime.Obj
r.lock.Lock()
defer r.lock.Unlock()
glog.V(4).Infof("reactor got operation %q on %q", action.GetVerb(), action.GetResource())
klog.V(4).Infof("reactor got operation %q on %q", action.GetVerb(), action.GetResource())
// Inject error when requested
err = r.injectReactError(action)
@@ -183,7 +183,7 @@ func (r *volumeReactor) React(action core.Action) (handled bool, ret runtime.Obj
r.volumes[volume.Name] = volume
r.changedObjects = append(r.changedObjects, volume)
r.changedSinceLastSync++
glog.V(4).Infof("created volume %s", volume.Name)
klog.V(4).Infof("created volume %s", volume.Name)
return true, volume, nil
case action.Matches("update", "persistentvolumes"):
@@ -209,7 +209,7 @@ func (r *volumeReactor) React(action core.Action) (handled bool, ret runtime.Obj
r.volumes[volume.Name] = volume
r.changedObjects = append(r.changedObjects, volume)
r.changedSinceLastSync++
glog.V(4).Infof("saved updated volume %s", volume.Name)
klog.V(4).Infof("saved updated volume %s", volume.Name)
return true, volume, nil
case action.Matches("update", "persistentvolumeclaims"):
@@ -235,23 +235,23 @@ func (r *volumeReactor) React(action core.Action) (handled bool, ret runtime.Obj
r.claims[claim.Name] = claim
r.changedObjects = append(r.changedObjects, claim)
r.changedSinceLastSync++
glog.V(4).Infof("saved updated claim %s", claim.Name)
klog.V(4).Infof("saved updated claim %s", claim.Name)
return true, claim, nil
case action.Matches("get", "persistentvolumes"):
name := action.(core.GetAction).GetName()
volume, found := r.volumes[name]
if found {
glog.V(4).Infof("GetVolume: found %s", volume.Name)
klog.V(4).Infof("GetVolume: found %s", volume.Name)
return true, volume, nil
} else {
glog.V(4).Infof("GetVolume: volume %s not found", name)
klog.V(4).Infof("GetVolume: volume %s not found", name)
return true, nil, fmt.Errorf("Cannot find volume %s", name)
}
case action.Matches("delete", "persistentvolumes"):
name := action.(core.DeleteAction).GetName()
glog.V(4).Infof("deleted volume %s", name)
klog.V(4).Infof("deleted volume %s", name)
_, found := r.volumes[name]
if found {
delete(r.volumes, name)
@@ -263,7 +263,7 @@ func (r *volumeReactor) React(action core.Action) (handled bool, ret runtime.Obj
case action.Matches("delete", "persistentvolumeclaims"):
name := action.(core.DeleteAction).GetName()
glog.V(4).Infof("deleted claim %s", name)
klog.V(4).Infof("deleted claim %s", name)
_, found := r.volumes[name]
if found {
delete(r.claims, name)
@@ -286,11 +286,11 @@ func (r *volumeReactor) injectReactError(action core.Action) error {
}
for i, expected := range r.errors {
glog.V(4).Infof("trying to match %q %q with %q %q", expected.verb, expected.resource, action.GetVerb(), action.GetResource())
klog.V(4).Infof("trying to match %q %q with %q %q", expected.verb, expected.resource, action.GetVerb(), action.GetResource())
if action.Matches(expected.verb, expected.resource) {
// That's the action we're waiting for, remove it from injectedErrors
r.errors = append(r.errors[:i], r.errors[i+1:]...)
glog.V(4).Infof("reactor found matching error at index %d: %q %q, returning %v", i, expected.verb, expected.resource, expected.error)
klog.V(4).Infof("reactor found matching error at index %d: %q %q, returning %v", i, expected.verb, expected.resource, expected.error)
return expected.error
}
}
@@ -379,14 +379,14 @@ func checkEvents(t *testing.T, expectedEvents []string, ctrl *PersistentVolumeCo
select {
case event, ok := <-fakeRecorder.Events:
if ok {
glog.V(5).Infof("event recorder got event %s", event)
klog.V(5).Infof("event recorder got event %s", event)
gotEvents = append(gotEvents, event)
} else {
glog.V(5).Infof("event recorder finished")
klog.V(5).Infof("event recorder finished")
finished = true
}
case _, _ = <-timer.C:
glog.V(5).Infof("event recorder timeout")
klog.V(5).Infof("event recorder timeout")
finished = true
}
}
@@ -426,10 +426,10 @@ func (r *volumeReactor) popChange() interface{} {
switch obj.(type) {
case *v1.PersistentVolume:
vol, _ := obj.(*v1.PersistentVolume)
glog.V(4).Infof("reactor queue: %s", vol.Name)
klog.V(4).Infof("reactor queue: %s", vol.Name)
case *v1.PersistentVolumeClaim:
claim, _ := obj.(*v1.PersistentVolumeClaim)
glog.V(4).Infof("reactor queue: %s", claim.Name)
klog.V(4).Infof("reactor queue: %s", claim.Name)
}
}
@@ -898,7 +898,7 @@ func wrapTestWithInjectedOperation(toWrap testCall, injectBeforeOperation func(c
// Inject a hook before async operation starts
ctrl.preOperationHook = func(operationName string) {
// Inside the hook, run the function to inject
glog.V(4).Infof("reactor: scheduleOperation reached, injecting call")
klog.V(4).Infof("reactor: scheduleOperation reached, injecting call")
injectBeforeOperation(ctrl, reactor)
}
@@ -945,7 +945,7 @@ func evaluateTestResults(ctrl *PersistentVolumeController, reactor *volumeReacto
// 3. Compare resulting volumes and claims with expected volumes and claims.
func runSyncTests(t *testing.T, tests []controllerTest, storageClasses []*storage.StorageClass, pods []*v1.Pod) {
for _, test := range tests {
glog.V(4).Infof("starting test %q", test.name)
klog.V(4).Infof("starting test %q", test.name)
// Initialize the controller
client := &fake.Clientset{}
@@ -1008,7 +1008,7 @@ func runSyncTests(t *testing.T, tests []controllerTest, storageClasses []*storag
// Some limit of calls in enforced to prevent endless loops.
func runMultisyncTests(t *testing.T, tests []controllerTest, storageClasses []*storage.StorageClass, defaultStorageClass string) {
for _, test := range tests {
glog.V(4).Infof("starting multisync test %q", test.name)
klog.V(4).Infof("starting multisync test %q", test.name)
// Initialize the controller
client := &fake.Clientset{}
@@ -1046,7 +1046,7 @@ func runMultisyncTests(t *testing.T, tests []controllerTest, storageClasses []*s
counter := 0
for {
counter++
glog.V(4).Infof("test %q: iteration %d", test.name, counter)
klog.V(4).Infof("test %q: iteration %d", test.name, counter)
if counter > 100 {
t.Errorf("Test %q failed: too many iterations", test.name)
@@ -1064,7 +1064,7 @@ func runMultisyncTests(t *testing.T, tests []controllerTest, storageClasses []*s
// Simulate "periodic sync" of everything (until it produces
// no changes).
firstSync = false
glog.V(4).Infof("test %q: simulating periodical sync of all claims and volumes", test.name)
klog.V(4).Infof("test %q: simulating periodical sync of all claims and volumes", test.name)
reactor.syncAll()
} else {
// Last sync did not produce any updates, the test reached
@@ -1085,7 +1085,7 @@ func runMultisyncTests(t *testing.T, tests []controllerTest, storageClasses []*s
if err != nil {
if err == versionConflictError {
// Ignore version errors
glog.V(4).Infof("test intentionaly ignores version error.")
klog.V(4).Infof("test intentionaly ignores version error.")
} else {
t.Errorf("Error calling syncClaim: %v", err)
// Finish the loop on the first error
@@ -1102,7 +1102,7 @@ func runMultisyncTests(t *testing.T, tests []controllerTest, storageClasses []*s
if err != nil {
if err == versionConflictError {
// Ignore version errors
glog.V(4).Infof("test intentionaly ignores version error.")
klog.V(4).Infof("test intentionaly ignores version error.")
} else {
t.Errorf("Error calling syncVolume: %v", err)
// Finish the loop on the first error
@@ -1114,7 +1114,7 @@ func runMultisyncTests(t *testing.T, tests []controllerTest, storageClasses []*s
}
}
evaluateTestResults(ctrl, reactor, test, t)
glog.V(4).Infof("test %q finished after %d iterations", test.name, counter)
klog.V(4).Infof("test %q finished after %d iterations", test.name, counter)
}
}
@@ -1185,7 +1185,7 @@ func (plugin *mockVolumePlugin) NewUnmounter(name string, podUID types.UID) (vol
func (plugin *mockVolumePlugin) NewProvisioner(options vol.VolumeOptions) (vol.Provisioner, error) {
if len(plugin.provisionCalls) > 0 {
// mockVolumePlugin directly implements Provisioner interface
glog.V(4).Infof("mock plugin NewProvisioner called, returning mock provisioner")
klog.V(4).Infof("mock plugin NewProvisioner called, returning mock provisioner")
plugin.provisionOptions = options
return plugin, nil
} else {
@@ -1201,7 +1201,7 @@ func (plugin *mockVolumePlugin) Provision(selectedNode *v1.Node, allowedTopologi
var pv *v1.PersistentVolume
call := plugin.provisionCalls[plugin.provisionCallCounter]
if !reflect.DeepEqual(call.expectedParameters, plugin.provisionOptions.Parameters) {
glog.Errorf("invalid provisioner call, expected options: %+v, got: %+v", call.expectedParameters, plugin.provisionOptions.Parameters)
klog.Errorf("invalid provisioner call, expected options: %+v, got: %+v", call.expectedParameters, plugin.provisionOptions.Parameters)
return nil, fmt.Errorf("Mock plugin error: invalid provisioner call")
}
if call.ret == nil {
@@ -1229,7 +1229,7 @@ func (plugin *mockVolumePlugin) Provision(selectedNode *v1.Node, allowedTopologi
}
plugin.provisionCallCounter++
glog.V(4).Infof("mock plugin Provision call nr. %d, returning %v: %v", plugin.provisionCallCounter, pv, call.ret)
klog.V(4).Infof("mock plugin Provision call nr. %d, returning %v: %v", plugin.provisionCallCounter, pv, call.ret)
return pv, call.ret
}
@@ -1238,7 +1238,7 @@ func (plugin *mockVolumePlugin) Provision(selectedNode *v1.Node, allowedTopologi
func (plugin *mockVolumePlugin) NewDeleter(spec *vol.Spec) (vol.Deleter, error) {
if len(plugin.deleteCalls) > 0 {
// mockVolumePlugin directly implements Deleter interface
glog.V(4).Infof("mock plugin NewDeleter called, returning mock deleter")
klog.V(4).Infof("mock plugin NewDeleter called, returning mock deleter")
return plugin, nil
} else {
return nil, fmt.Errorf("Mock plugin error: no deleteCalls configured")
@@ -1251,7 +1251,7 @@ func (plugin *mockVolumePlugin) Delete() error {
}
ret := plugin.deleteCalls[plugin.deleteCallCounter]
plugin.deleteCallCounter++
glog.V(4).Infof("mock plugin Delete call nr. %d, returning %v", plugin.deleteCallCounter, ret)
klog.V(4).Infof("mock plugin Delete call nr. %d, returning %v", plugin.deleteCallCounter, ret)
return ret
}
@@ -1277,6 +1277,6 @@ func (plugin *mockVolumePlugin) Recycle(pvName string, spec *vol.Spec, eventReco
}
ret := plugin.recycleCalls[plugin.recycleCallCounter]
plugin.recycleCallCounter++
glog.V(4).Infof("mock plugin Recycle call nr. %d, returning %v", plugin.recycleCallCounter, ret)
klog.V(4).Infof("mock plugin Recycle call nr. %d, returning %v", plugin.recycleCallCounter, ret)
return ret
}