Skip to content

Commit 3e5b6ad

Browse files
authored
Merge pull request #49 from AdlerFleurant/Fix_Issue_44
Fix issue 44: Explicitly set passthrough route to failed
2 parents 1b1f4cc + 9a1fa27 commit 3e5b6ad

2 files changed

Lines changed: 53 additions & 1 deletion

File tree

pkg/controller/route/route_controller.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,15 @@ func (r *ReconcileRoute) Reconcile(request reconcile.Request) (reconcile.Result,
135135
if route.ObjectMeta.Annotations[r.config.General.Annotations.Status] == r.config.General.Annotations.NeedCertValue {
136136
reqLogger.Info("Reconciling Route")
137137

138-
// Retreive cert from provider
138+
if route.Spec.TLS.Termination == v1.TLSTerminationPassthrough {
139+
route.ObjectMeta.Annotations[r.config.General.Annotations.Status] = "failed"
140+
route.ObjectMeta.Annotations[r.config.General.Annotations.StatusReason] = "Certificate and key cannot be set on Passthrough route"
141+
142+
err = helpers.Apply(r.client, route)
143+
return reconcile.Result{}, err
144+
}
145+
146+
// Retrieve cert from provider
139147
keyPair, err := helpers.GetCert(route.Spec.Host, r.provider, r.config.Provider.Ssl)
140148
if err != nil {
141149
route.ObjectMeta.Annotations[r.config.General.Annotations.Status] = "failed"

test/e2e/cert_test.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,47 @@ func routeBasicTest(t *testing.T, f *framework.Framework, ctx *framework.TestCtx
8585
return nil
8686
}
8787

88+
func routePassthroughTest(t *testing.T, f *framework.Framework, ctx *framework.TestCtx) error {
89+
namespace, err := ctx.GetNamespace()
90+
if err != nil {
91+
return fmt.Errorf("could not get namespace: %v", err)
92+
}
93+
94+
exampleRoute := &routev1.Route{
95+
TypeMeta: metav1.TypeMeta{
96+
Kind: "Route",
97+
APIVersion: "route.openshift.io/v1",
98+
},
99+
ObjectMeta: metav1.ObjectMeta{
100+
Name: "route-passthrough",
101+
Namespace: namespace,
102+
Annotations: map[string]string{
103+
"openshift.io/cert-ctl-status": "new",
104+
},
105+
},
106+
Spec: routev1.RouteSpec{
107+
Host: fmt.Sprintf("route-passthrough.%s.example.com", namespace),
108+
TLS: &routev1.TLSConfig{
109+
Termination: routev1.TLSTerminationPassthrough,
110+
},
111+
To: routev1.RouteTargetReference{
112+
Kind: "Service",
113+
Name: "myservice",
114+
},
115+
},
116+
}
117+
118+
// use TestCtx's create helper to create the object and add a cleanup function for the new object
119+
err = f.Client.Create(goctx.TODO(), exampleRoute, &framework.CleanupOptions{TestContext: ctx, Timeout: cleanupTimeout, RetryInterval: cleanupRetryInterval})
120+
if err != nil {
121+
return err
122+
}
123+
124+
assert.Nil(t, waitForAnnotation(t, f, exampleRoute, "openshift.io/cert-ctl-status", "failed"))
125+
126+
return nil
127+
}
128+
88129
func serviceP12Test(t *testing.T, f *framework.Framework, ctx *framework.TestCtx) error {
89130
namespace, err := ctx.GetNamespace()
90131
if err != nil {
@@ -245,6 +286,9 @@ func SetupCluster(t *testing.T) {
245286
if err = routeBasicTest(t, f, ctx); err != nil {
246287
t.Fatal(err)
247288
}
289+
if err = routePassthroughTest(t, f, ctx); err != nil {
290+
t.Fatal(err)
291+
}
248292
if err = serviceBasicTest(t, f, ctx); err != nil {
249293
t.Fatal("PEM Service", err)
250294
}

0 commit comments

Comments
 (0)