Skip to content

Commit

Permalink
Remove support for ingress.appscode.com/egress-points annotations (#615)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha committed Oct 12, 2017
1 parent 0c687e7 commit 0544618
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 160 deletions.
2 changes: 0 additions & 2 deletions apis/voyager/v1beta1/annotations.go
Expand Up @@ -86,8 +86,6 @@ const (
OriginAPISchema = EngressKey + "/" + "origin-api-schema" // APISchema = {APIGroup}/{APIVersion}
OriginName = EngressKey + "/" + "origin-name"

EgressPoints = EngressKey + "/" + "egress-points"

// https://github.com/appscode/voyager/issues/280
// Supports all valid timeout option for defaults section of HAProxy
// https://cbonte.github.io/haproxy-dconv/1.7/configuration.html#4.2-timeout%20check
Expand Down
23 changes: 0 additions & 23 deletions pkg/operator/ingress_crds.go
Expand Up @@ -110,14 +110,6 @@ func (op *Operator) AddEngress(ctx context.Context, engress *tapi.Ingress) {
} else {
ctrl.Create()
}

for _, meta := range engress.BackendServices() {
svc, err := op.KubeClient.CoreV1().Services(meta.Namespace).Get(meta.Name, metav1.GetOptions{})
if err != nil {
continue
}
op.ensureEgressAnnotations(engress, svc)
}
}

func (op *Operator) UpdateEngress(ctx context.Context, oldEngress, newEngress *tapi.Ingress) {
Expand Down Expand Up @@ -167,24 +159,9 @@ func (op *Operator) UpdateEngress(ctx context.Context, oldEngress, newEngress *t
for k, v := range newEngress.BackendServices() {
backends[k] = v
}
for _, meta := range backends {
svc, err := op.KubeClient.CoreV1().Services(meta.Namespace).Get(meta.Name, metav1.GetOptions{})
if err != nil {
continue
}
op.ensureEgressAnnotations(newEngress, svc)
}
}

func (op *Operator) DeleteEngress(ctx context.Context, engress *tapi.Ingress) {
ctrl := ingress.NewController(ctx, op.KubeClient, op.CRDClient, op.VoyagerClient, op.PromClient, op.ServiceLister, op.EndpointsLister, op.Opt, engress)
ctrl.Delete()

for _, meta := range engress.BackendServices() {
svc, err := op.KubeClient.CoreV1().Services(meta.Namespace).Get(meta.Name, metav1.GetOptions{})
if err != nil {
continue
}
op.ensureEgressAnnotations(engress, svc)
}
}
63 changes: 0 additions & 63 deletions pkg/operator/services.go
Expand Up @@ -2,7 +2,6 @@ package operator

import (
"context"
"encoding/json"
"fmt"

etx "github.com/appscode/go/context"
Expand Down Expand Up @@ -139,70 +138,8 @@ func (op *Operator) updateHAProxyConfig(ctx context.Context, svc *apiv1.Service)
logger.Infof("One or more offshoots of %s Ingress %s/%s is missing, trying to create", engress.APISchema(), engress.Namespace, engress.Name)
ctrl.Create()
}
op.ensureEgressAnnotations(engress, svc)
}
}
}
return nil
}

func (op *Operator) ensureEgressAnnotations(r *tapi.Ingress, svc *apiv1.Service) {
if svc.Annotations == nil {
svc.Annotations = make(map[string]string)
}
if r.HasBackendService(svc.Name, svc.Namespace) {
list := make([]tapi.IngressRef, 0)
val, ok := svc.Annotations[tapi.EgressPoints]
if ok {
err := json.Unmarshal([]byte(val), list)
if err == nil {
found := false
for _, engs := range list {
if engs.APISchema == r.APISchema() && engs.Name == r.Name && engs.Namespace == r.Namespace {
found = true
break
}
}
if !found {
list = append(list, tapi.IngressRef{
APISchema: r.APISchema(),
Name: r.Name,
Namespace: r.Namespace,
})
}
}
} else {
list = append(list, tapi.IngressRef{
APISchema: r.APISchema(),
Name: r.Name,
Namespace: r.Namespace,
})
}

data, err := json.Marshal(list)
if err == nil {
svc.Annotations[tapi.EgressPoints] = string(data)
}
op.KubeClient.CoreV1().Services(svc.Namespace).Update(svc)
return
}
// Lets check if service still have the annotation for this ingress.
val, ok := svc.Annotations[tapi.EgressPoints]
if ok {
list := make([]tapi.IngressRef, 0)
err := json.Unmarshal([]byte(val), list)
if err == nil {
for i, engs := range list {
if engs.APISchema == r.APISchema() && engs.Name == r.Name && engs.Namespace == r.Namespace {
// remove the annotation key
list = append(list[:i], list[i+1:]...)
}
}
data, err := json.Marshal(list)
if err == nil {
svc.Annotations[tapi.EgressPoints] = string(data)
}
}
op.KubeClient.CoreV1().Services(svc.Namespace).Update(svc)
}
}
72 changes: 0 additions & 72 deletions pkg/operator/services_test.go

This file was deleted.

0 comments on commit 0544618

Please sign in to comment.