Merge pull request #876 from sargun/fix-lease-logs
Fix logging when leases are mis-set
This commit is contained in:
18
node/node.go
18
node/node.go
@@ -683,19 +683,25 @@ func newLease(ctx context.Context, base *coord.Lease, node *corev1.Node, leaseRe
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
} else if l > 0 {
|
} else if l > 0 {
|
||||||
var foundThisNode, foundNode bool
|
var foundAnyNode bool
|
||||||
for _, ref := range lease.OwnerReferences {
|
for _, ref := range lease.OwnerReferences {
|
||||||
if ref.APIVersion == corev1.SchemeGroupVersion.WithKind("Node").Version && ref.Kind == corev1.SchemeGroupVersion.WithKind("Node").Kind {
|
if ref.APIVersion == corev1.SchemeGroupVersion.WithKind("Node").Version && ref.Kind == corev1.SchemeGroupVersion.WithKind("Node").Kind {
|
||||||
foundNode = true
|
foundAnyNode = true
|
||||||
if node.UID == ref.UID && node.Name == ref.Name {
|
if node.UID == ref.UID && node.Name == ref.Name {
|
||||||
foundThisNode = true
|
return lease
|
||||||
|
} else {
|
||||||
|
log.G(ctx).WithFields(map[string]interface{}{
|
||||||
|
"node.UID": node.UID,
|
||||||
|
"ref.UID": ref.UID,
|
||||||
|
"node.Name": node.Name,
|
||||||
|
"ref.Name": ref.Name,
|
||||||
|
}).Warn("Found that lease had node in owner references that is not this node")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !foundThisNode && !foundNode {
|
if !foundAnyNode {
|
||||||
log.G(ctx).Warn("Found that lease had owner references, but no nodes in owner references")
|
log.G(ctx).Warn("Found that lease had owner references, but no nodes in owner references")
|
||||||
} else if foundNode {
|
|
||||||
log.G(ctx).Warn("Found that lease had owner references, but nodes in owner references that is not this node")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user