Commit be7b7da7 authored by Claudio Gonçalves's avatar Claudio Gonçalves Committed by Claudio Netto

controller: refresh the nginx's status field for each pod change

parent 830fe7f3
Pipeline #64126772 failed with stages
in 7 minutes and 44 seconds
......@@ -50,7 +50,24 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
return err
}
return nil
// HACK(nettoclaudio): Since the Nginx needs store all its pods' info into
// the status field, we need watching every pod changes and enqueue a new
// reconcile request to its Nginx owner, if any.
return c.Watch(&source.Kind{Type: &corev1.Pod{}},
&handler.EnqueueRequestsFromMapFunc{
ToRequests: handler.ToRequestsFunc(func(o handler.MapObject) []reconcile.Request {
if nginxCR, ok := o.Meta.GetLabels()["nginx_cr"]; ok {
return []reconcile.Request{
{NamespacedName: types.NamespacedName{
Name: nginxCR,
Namespace: o.Meta.GetNamespace(),
}},
}
}
return []reconcile.Request{}
}),
},
)
}
var _ reconcile.Reconciler = &ReconcileNginx{}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment