Add events for NGINX reloads
This commit is contained in:
parent
c7b041fb9e
commit
29ea30a4e8
26 changed files with 319 additions and 326 deletions
|
|
@ -220,8 +220,6 @@ type k8sStore struct {
|
|||
backendConfigMu *sync.RWMutex
|
||||
|
||||
defaultSSLCertificate string
|
||||
|
||||
pod *k8s.PodInfo
|
||||
}
|
||||
|
||||
// New creates a new object store to be used in the ingress controller
|
||||
|
|
@ -230,7 +228,6 @@ func New(
|
|||
resyncPeriod time.Duration,
|
||||
client clientset.Interface,
|
||||
updateCh *channels.RingChannel,
|
||||
pod *k8s.PodInfo,
|
||||
disableCatchAll bool) Storer {
|
||||
|
||||
store := &k8sStore{
|
||||
|
|
@ -243,7 +240,6 @@ func New(
|
|||
backendConfigMu: &sync.RWMutex{},
|
||||
secretIngressMap: NewObjectRefMap(),
|
||||
defaultSSLCertificate: defaultSSLCertificate,
|
||||
pod: pod,
|
||||
}
|
||||
|
||||
eventBroadcaster := record.NewBroadcaster()
|
||||
|
|
@ -294,16 +290,17 @@ func New(
|
|||
store.informers.Service = infFactory.Core().V1().Services().Informer()
|
||||
store.listers.Service.Store = store.informers.Service.GetStore()
|
||||
|
||||
labelSelector := labels.SelectorFromSet(store.pod.Labels)
|
||||
ingressPodInfo, _ := k8s.GetPodDetails()
|
||||
labelSelector := labels.SelectorFromSet(ingressPodInfo.Labels)
|
||||
store.informers.Pod = cache.NewSharedIndexInformer(
|
||||
&cache.ListWatch{
|
||||
ListFunc: func(options metav1.ListOptions) (k8sruntime.Object, error) {
|
||||
options.LabelSelector = labelSelector.String()
|
||||
return client.CoreV1().Pods(store.pod.Namespace).List(context.TODO(), options)
|
||||
return client.CoreV1().Pods(ingressPodInfo.Namespace).List(context.TODO(), options)
|
||||
},
|
||||
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
|
||||
options.LabelSelector = labelSelector.String()
|
||||
return client.CoreV1().Pods(store.pod.Namespace).Watch(context.TODO(), options)
|
||||
return client.CoreV1().Pods(ingressPodInfo.Namespace).Watch(context.TODO(), options)
|
||||
},
|
||||
},
|
||||
&corev1.Pod{},
|
||||
|
|
|
|||
|
|
@ -47,11 +47,13 @@ import (
|
|||
func TestStore(t *testing.T) {
|
||||
k8s.IsNetworkingIngressAvailable = true
|
||||
|
||||
pod := &k8s.PodInfo{
|
||||
Name: "testpod",
|
||||
Namespace: v1.NamespaceDefault,
|
||||
Labels: map[string]string{
|
||||
"pod-template-hash": "1234",
|
||||
k8s.IngressNGINXPod = &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "testpod",
|
||||
Namespace: v1.NamespaceDefault,
|
||||
Labels: map[string]string{
|
||||
"pod-template-hash": "1234",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +96,6 @@ func TestStore(t *testing.T) {
|
|||
10*time.Minute,
|
||||
clientSet,
|
||||
updateCh,
|
||||
pod,
|
||||
false)
|
||||
|
||||
storer.Run(stopCh)
|
||||
|
|
@ -172,7 +173,6 @@ func TestStore(t *testing.T) {
|
|||
10*time.Minute,
|
||||
clientSet,
|
||||
updateCh,
|
||||
pod,
|
||||
false)
|
||||
|
||||
storer.Run(stopCh)
|
||||
|
|
@ -320,7 +320,6 @@ func TestStore(t *testing.T) {
|
|||
10*time.Minute,
|
||||
clientSet,
|
||||
updateCh,
|
||||
pod,
|
||||
false)
|
||||
|
||||
storer.Run(stopCh)
|
||||
|
|
@ -424,7 +423,6 @@ func TestStore(t *testing.T) {
|
|||
10*time.Minute,
|
||||
clientSet,
|
||||
updateCh,
|
||||
pod,
|
||||
false)
|
||||
|
||||
storer.Run(stopCh)
|
||||
|
|
@ -511,7 +509,6 @@ func TestStore(t *testing.T) {
|
|||
10*time.Minute,
|
||||
clientSet,
|
||||
updateCh,
|
||||
pod,
|
||||
false)
|
||||
|
||||
storer.Run(stopCh)
|
||||
|
|
@ -620,7 +617,6 @@ func TestStore(t *testing.T) {
|
|||
10*time.Minute,
|
||||
clientSet,
|
||||
updateCh,
|
||||
pod,
|
||||
false)
|
||||
|
||||
storer.Run(stopCh)
|
||||
|
|
@ -777,11 +773,13 @@ func deleteIngress(ingress *networking.Ingress, clientSet kubernetes.Interface,
|
|||
// newStore creates a new mock object store for tests which do not require the
|
||||
// use of Informers.
|
||||
func newStore(t *testing.T) *k8sStore {
|
||||
pod := &k8s.PodInfo{
|
||||
Name: "ingress-1",
|
||||
Namespace: v1.NamespaceDefault,
|
||||
Labels: map[string]string{
|
||||
"pod-template-hash": "1234",
|
||||
k8s.IngressNGINXPod = &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "ingress-1",
|
||||
Namespace: v1.NamespaceDefault,
|
||||
Labels: map[string]string{
|
||||
"pod-template-hash": "1234",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -797,7 +795,6 @@ func newStore(t *testing.T) *k8sStore {
|
|||
syncSecretMu: new(sync.Mutex),
|
||||
backendConfigMu: new(sync.RWMutex),
|
||||
secretIngressMap: NewObjectRefMap(),
|
||||
pod: pod,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1011,15 +1008,18 @@ func TestGetRunningControllerPodsCount(t *testing.T) {
|
|||
os.Setenv("POD_NAMESPACE", "testns")
|
||||
os.Setenv("POD_NAME", "ingress-1")
|
||||
|
||||
s := newStore(t)
|
||||
s.pod = &k8s.PodInfo{
|
||||
Name: "ingress-1",
|
||||
Namespace: "testns",
|
||||
Labels: map[string]string{
|
||||
"pod-template-hash": "1234",
|
||||
k8s.IngressNGINXPod = &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "ingress-1",
|
||||
Namespace: "testns",
|
||||
Labels: map[string]string{
|
||||
"pod-template-hash": "1234",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
s := newStore(t)
|
||||
|
||||
pod := &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "ingress-1",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue