mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 13:45:06 +00:00
Add more verbose logs
This commit is contained in:
@@ -160,11 +160,13 @@ func (ss *scaleSet) updateCache() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// getCachedVirtualMachine gets virtualMachine by nodeName from cache.
|
// getCachedVirtualMachine gets virtualMachine by nodeName from cache.
|
||||||
|
// It returns cloudprovider.InstanceNotFound if node does not belong to any scale sets.
|
||||||
func (ss *scaleSet) getCachedVirtualMachine(nodeName string) (scaleSetVMInfo, error) {
|
func (ss *scaleSet) getCachedVirtualMachine(nodeName string) (scaleSetVMInfo, error) {
|
||||||
ss.cacheMutex.Lock()
|
ss.cacheMutex.Lock()
|
||||||
defer ss.cacheMutex.Unlock()
|
defer ss.cacheMutex.Unlock()
|
||||||
|
|
||||||
getVMFromCache := func(nodeName string) (scaleSetVMInfo, bool) {
|
getVMFromCache := func(nodeName string) (scaleSetVMInfo, bool) {
|
||||||
|
glog.V(8).Infof("Getting scaleSetVMInfo for %q from cache %v", nodeName, ss.cache)
|
||||||
for scaleSetName := range ss.cache {
|
for scaleSetName := range ss.cache {
|
||||||
for _, vm := range ss.cache[scaleSetName] {
|
for _, vm := range ss.cache[scaleSetName] {
|
||||||
if vm.NodeName == nodeName {
|
if vm.NodeName == nodeName {
|
||||||
@@ -183,11 +185,13 @@ func (ss *scaleSet) getCachedVirtualMachine(nodeName string) (scaleSetVMInfo, er
|
|||||||
|
|
||||||
// Known node not managed by scale sets.
|
// Known node not managed by scale sets.
|
||||||
if ss.availabilitySetNodesCache.Has(nodeName) {
|
if ss.availabilitySetNodesCache.Has(nodeName) {
|
||||||
|
glog.V(10).Infof("Found node %q in availabilitySetNodesCache", nodeName)
|
||||||
return scaleSetVMInfo{}, cloudprovider.InstanceNotFound
|
return scaleSetVMInfo{}, cloudprovider.InstanceNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update cache and try again.
|
// Update cache and try again.
|
||||||
if err := ss.updateCache(); err != nil {
|
if err := ss.updateCache(); err != nil {
|
||||||
|
glog.Errorf("updateCache failed with error: %v", err)
|
||||||
return scaleSetVMInfo{}, err
|
return scaleSetVMInfo{}, err
|
||||||
}
|
}
|
||||||
vm, found = getVMFromCache(nodeName)
|
vm, found = getVMFromCache(nodeName)
|
||||||
@@ -196,15 +200,19 @@ func (ss *scaleSet) getCachedVirtualMachine(nodeName string) (scaleSetVMInfo, er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Node still not found, assuming it is not managed by scale sets.
|
// Node still not found, assuming it is not managed by scale sets.
|
||||||
|
glog.V(8).Infof("Node %q doesn't belong to any scale sets, adding it to availabilitySetNodesCache", nodeName)
|
||||||
ss.availabilitySetNodesCache.Insert(nodeName)
|
ss.availabilitySetNodesCache.Insert(nodeName)
|
||||||
return scaleSetVMInfo{}, cloudprovider.InstanceNotFound
|
return scaleSetVMInfo{}, cloudprovider.InstanceNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getCachedVirtualMachineByInstanceID gets scaleSetVMInfo from cache.
|
||||||
|
// The node must belong to one of scale sets.
|
||||||
func (ss *scaleSet) getCachedVirtualMachineByInstanceID(scaleSetName, instanceID string) (scaleSetVMInfo, error) {
|
func (ss *scaleSet) getCachedVirtualMachineByInstanceID(scaleSetName, instanceID string) (scaleSetVMInfo, error) {
|
||||||
ss.cacheMutex.Lock()
|
ss.cacheMutex.Lock()
|
||||||
defer ss.cacheMutex.Unlock()
|
defer ss.cacheMutex.Unlock()
|
||||||
|
|
||||||
getVMByID := func(scaleSetName, instanceID string) (scaleSetVMInfo, bool) {
|
getVMByID := func(scaleSetName, instanceID string) (scaleSetVMInfo, bool) {
|
||||||
|
glog.V(8).Infof("Getting scaleSetVMInfo with scaleSetName: %q and instanceID %q from cache %v", scaleSetName, instanceID, ss.cache)
|
||||||
vms, ok := ss.cache[scaleSetName]
|
vms, ok := ss.cache[scaleSetName]
|
||||||
if !ok {
|
if !ok {
|
||||||
glog.V(4).Infof("scale set (%s) not found", scaleSetName)
|
glog.V(4).Infof("scale set (%s) not found", scaleSetName)
|
||||||
@@ -229,6 +237,7 @@ func (ss *scaleSet) getCachedVirtualMachineByInstanceID(scaleSetName, instanceID
|
|||||||
|
|
||||||
// Update cache and try again.
|
// Update cache and try again.
|
||||||
if err := ss.updateCache(); err != nil {
|
if err := ss.updateCache(); err != nil {
|
||||||
|
glog.Errorf("updateCache failed with error: %v", err)
|
||||||
return scaleSetVMInfo{}, err
|
return scaleSetVMInfo{}, err
|
||||||
}
|
}
|
||||||
vm, found = getVMByID(scaleSetName, instanceID)
|
vm, found = getVMByID(scaleSetName, instanceID)
|
||||||
|
Reference in New Issue
Block a user