Skip to content

Commit

Permalink
Merge pull request #633 from freehan/release-1.4
Browse files Browse the repository at this point in the history
Cherrypick #582 into release-1.4 branch
  • Loading branch information
k8s-ci-robot committed Feb 11, 2019
2 parents a7199af + 4bc3a0c commit 25a9bf9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
8 changes: 7 additions & 1 deletion pkg/controller/translator/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,15 @@ OuterLoop:
service = *as.(*api_v1.Service)
for _, sp := range service.Spec.Ports {
svcPort = sp
// If service is NEG enabled, compare the service name and namespace instead
// This is because NEG enabled service is not required to have nodePort
if port.NEGEnabled && port.ID.Service.Namespace == service.Namespace && port.ID.Service.Name == service.Name && port.Port == sp.Port {
found = true
break OuterLoop
}
// only one Service can match this nodePort, try and look up
// the readiness probe of the pods behind it
if int32(port.NodePort) == sp.NodePort {
if port.NodePort != 0 && int32(port.NodePort) == sp.NodePort {
found = true
break OuterLoop
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/controller/translator/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ func TestGetProbe(t *testing.T) {
{NodePort: 3001, Protocol: annotations.ProtocolHTTP}: "/healthz",
{NodePort: 3002, Protocol: annotations.ProtocolHTTPS}: "/foo",
{NodePort: 3003, Protocol: annotations.ProtocolHTTP2}: "/http2-check",
{NodePort: 0, Protocol: annotations.ProtocolHTTPS, NEGEnabled: true,
ID: utils.ServicePortID{Service: types.NamespacedName{Name: "svc0", Namespace: apiv1.NamespaceDefault}}}: "/bar",
}
for _, svc := range makeServices(nodePortToHealthCheck, apiv1.NamespaceDefault) {
translator.ctx.ServiceInformer.GetIndexer().Add(svc)
Expand Down Expand Up @@ -431,7 +433,7 @@ func makePods(nodePortToHealthCheck map[utils.ServicePort]string, ns string) []*
pod := &apiv1.Pod{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{fmt.Sprintf("app-%d", np.NodePort): "test"},
Name: fmt.Sprintf("%d", np.NodePort),
Name: fmt.Sprintf("pod%d", np.NodePort),
Namespace: ns,
CreationTimestamp: metav1.NewTime(firstPodCreationTime.Add(delay)),
},
Expand Down Expand Up @@ -466,7 +468,7 @@ func makeServices(nodePortToHealthCheck map[utils.ServicePort]string, ns string)
for np := range nodePortToHealthCheck {
svc := &apiv1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%d", np.NodePort),
Name: fmt.Sprintf("svc%d", np.NodePort),
Namespace: ns,
},
Spec: apiv1.ServiceSpec{
Expand Down
2 changes: 1 addition & 1 deletion pkg/neg/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ func (c *Controller) syncNegStatusAnnotation(namespace, name string, portMap neg
if _, ok := service.Annotations[annotations.NEGStatusKey]; ok {
// TODO: use PATCH to remove annotation
delete(service.Annotations, annotations.NEGStatusKey)
glog.V(2).Infof("Removing expose NEG annotation from service: %s/%s", namespace, name)
glog.V(2).Infof("Removing NEG status annotation from service: %s/%s", namespace, name)
_, err = svcClient.Update(service)
return err
}
Expand Down

0 comments on commit 25a9bf9

Please sign in to comment.