-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Restic controller improvements #570
Restic controller improvements #570
Conversation
skriss
commented
Jun 21, 2018
•
edited
Loading
edited
- various logging improvements - helpful fields, adjusting levels, removing noise
- for the PVB/PVR controllers, filter out items in the informer event handlers before adding them to the queue, to reduce noise
- refactor/simplify the code in the PVR controller that determines which PVRs are ready to process (based on the status of them and their associated pod)
771d82c
to
e105210
Compare
"namespace": req.Namespace, | ||
"name": req.Name, | ||
}) | ||
|
||
if len(req.OwnerReferences) == 1 { | ||
log = log.WithField("arkBackup", req.OwnerReferences[0].Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've used backup
as the key with namespace/name
as the value before - let's be consistent?
for _, pvr := range pvrsToEnqueueForPod(pod, c.podVolumeRestoreLister, c.nodeName, log) { | ||
c.enqueue(pvr) | ||
pod, err := c.podLister.Pods(pvr.Spec.Pod.Namespace).Get(pvr.Spec.Pod.Name) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should log not-found errors at debug level, and all other errors at error level. WDYT?
return nil | ||
// the pod should always be for this node since the podInformer is filtered | ||
// based on node, so this is just a failsafe. | ||
if pod.Spec.NodeName != c.nodeName { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use isPodOnNode
?
func shouldEnqueuePVR(pvr *arkv1api.PodVolumeRestore, podLister corev1listers.PodLister, nodeName string, log logrus.FieldLogger) bool { | ||
if !shouldProcessPVR(pvr, log) { | ||
return false | ||
if !isResticInitContainerRunning(pod) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this check up before the lister call (it's less expensive)?
"namespace": req.Namespace, | ||
"name": req.Name, | ||
}) | ||
|
||
if len(req.OwnerReferences) == 1 { | ||
log = log.WithField("arkRestore", req.OwnerReferences[0].Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use restore=namespace/name
?
addressed comments & added a buncha unit tests. |
Will squash once you get a chance to look at updates. |
var ( | ||
client = kubefake.NewSimpleClientset() | ||
informers = kubeinformers.NewSharedInformerFactory(client, 0) | ||
podInformer = informers.Core().V1().Pods() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could construct the podInformer by hand instead of having the factory do it. Then you don't need the fake kube clientset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed.
}, | ||
}, | ||
expected: true, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a test case for first initContainer is our restic, but container state != running?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added.
bd54321
to
4c74b20
Compare
lgtm |
Signed-off-by: Steve Kriss <steve@heptio.com>
4c74b20
to
a697ad1
Compare
squashed. |