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

Restic controller improvements #570

Merged
merged 1 commit into from
Jun 27, 2018

Conversation

skriss
Copy link
Contributor

@skriss skriss commented Jun 21, 2018

  • 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)

@skriss skriss requested review from ncdc and nrb June 21, 2018 23:41
@skriss skriss force-pushed the restic-controller-improvements branch 2 times, most recently from 771d82c to e105210 Compare June 22, 2018 22:56
"namespace": req.Namespace,
"name": req.Name,
})

if len(req.OwnerReferences) == 1 {
log = log.WithField("arkBackup", req.OwnerReferences[0].Name)
Copy link
Contributor

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 {
Copy link
Contributor

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 {
Copy link
Contributor

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) {
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use restore=namespace/name?

@skriss
Copy link
Contributor Author

skriss commented Jun 26, 2018

addressed comments & added a buncha unit tests.

@skriss
Copy link
Contributor Author

skriss commented Jun 27, 2018

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()
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed.

},
},
expected: true,
},
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added.

@skriss skriss force-pushed the restic-controller-improvements branch from bd54321 to 4c74b20 Compare June 27, 2018 20:26
@ncdc
Copy link
Contributor

ncdc commented Jun 27, 2018

lgtm

Signed-off-by: Steve Kriss <steve@heptio.com>
@skriss skriss force-pushed the restic-controller-improvements branch from 4c74b20 to a697ad1 Compare June 27, 2018 20:31
@skriss
Copy link
Contributor Author

skriss commented Jun 27, 2018

squashed.

@ncdc ncdc merged commit e015238 into vmware-tanzu:master Jun 27, 2018
@skriss skriss deleted the restic-controller-improvements branch June 27, 2018 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants