Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support only tls in virtual services #2502

Merged
merged 10 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion rollout/trafficrouting/istio/istio.go
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,9 @@ func (r *Reconciler) RemoveManagedRoutes() error {
return fmt.Errorf("[RemoveManagedRoutes] failed to get http routes from virtual service: %w", err)
}
if !found {
return fmt.Errorf("[RemoveManagedRoutes] %s: %w", SpecHttpNotFound, err)
// Nothing to do here so return early this can be hit when only tls routes are defined
zachaller marked this conversation as resolved.
Show resolved Hide resolved
zachaller marked this conversation as resolved.
Show resolved Hide resolved
log.Debugf("[RemoveManagedRoutes] %s: not removing any routes\n", SpecHttpNotFound)
zachaller marked this conversation as resolved.
Show resolved Hide resolved
return nil
}

managedRoutes := r.rollout.Spec.Strategy.Canary.TrafficRouting.ManagedRoutes
Expand Down
90 changes: 90 additions & 0 deletions test/e2e/istio/istio-host-only-tls-split.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
apiVersion: v1
kind: Service
metadata:
name: istio-host-split-tls-canary
spec:
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: istio-host-split-tls

---
apiVersion: v1
kind: Service
metadata:
name: istio-host-split-tls-stable
spec:
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
selector:
app: istio-host-split-tls

---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: istio-host-split-tls-vsvc
spec:
hosts:
- istio-host-split-tls
tls:
- match:
- port: 3000
sniHosts:
- istio-host-split-tls
route:
- destination:
host: istio-host-split-tls-stable
weight: 100
- destination:
host: istio-host-split-tls-canary
weight: 0

---
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: istio-host-split-tls
spec:
strategy:
canary:
canaryService: istio-host-split-tls-canary
stableService: istio-host-split-tls-stable
trafficRouting:
istio:
virtualService:
name: istio-host-split-tls-vsvc
routes:
- primary
tlsRoutes:
- port: 3000
sniHosts:
- istio-host-split-tls
steps:
- setWeight: 10
- pause: {}
selector:
matchLabels:
app: istio-host-split-tls
template:
metadata:
labels:
app: istio-host-split-tls
spec:
containers:
- name: istio-host-split-tls
image: nginx:1.19-alpine
ports:
- name: http
containerPort: 80
protocol: TCP
resources:
requests:
memory: 16Mi
cpu: 5m
65 changes: 65 additions & 0 deletions test/e2e/istio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,71 @@ func (s *IstioSuite) TestIstioHostSplit() {
}
}

func (s *IstioSuite) TestIstioHostSplitOnlyTls() {

tests := []struct {
filename string
hasTls bool
}{
{
"@istio/istio-host-only-tls-split.yaml",
true,
},
}

for _, tc := range tests {

s.Given().
RolloutObjects(tc.filename).
When().
ApplyManifests().
WaitForRolloutStatus("Healthy").
Then().
Assert(func(t *fixtures.Then) {
vsvc := t.GetVirtualService()
assert.Equal(s.T(), int64(100), vsvc.Spec.TLS[0].Route[0].Weight)
assert.Equal(s.T(), int64(0), vsvc.Spec.TLS[0].Route[1].Weight)
desired, stable := t.GetServices()
rs1 := t.GetReplicaSetByRevision("1")
assert.Equal(s.T(), rs1.Spec.Template.Labels[v1alpha1.DefaultRolloutUniqueLabelKey], desired.Spec.Selector[v1alpha1.DefaultRolloutUniqueLabelKey])
assert.Equal(s.T(), rs1.Spec.Template.Labels[v1alpha1.DefaultRolloutUniqueLabelKey], stable.Spec.Selector[v1alpha1.DefaultRolloutUniqueLabelKey])
}).
When().
UpdateSpec().
WaitForRolloutStatus("Paused").
Then().
Assert(func(t *fixtures.Then) {
vsvc := t.GetVirtualService()
assert.Equal(s.T(), int64(90), vsvc.Spec.TLS[0].Route[0].Weight)
assert.Equal(s.T(), int64(10), vsvc.Spec.TLS[0].Route[1].Weight)

desired, stable := t.GetServices()
rs1 := t.GetReplicaSetByRevision("1")
rs2 := t.GetReplicaSetByRevision("2")
assert.Equal(s.T(), rs2.Spec.Template.Labels[v1alpha1.DefaultRolloutUniqueLabelKey], desired.Spec.Selector[v1alpha1.DefaultRolloutUniqueLabelKey])
assert.Equal(s.T(), rs1.Spec.Template.Labels[v1alpha1.DefaultRolloutUniqueLabelKey], stable.Spec.Selector[v1alpha1.DefaultRolloutUniqueLabelKey])
}).
When().
PromoteRollout().
WaitForRolloutStatus("Healthy").
Sleep(1*time.Second). // stable is currently set first, and then changes made to VirtualServices/DestinationRules
Then().
Assert(func(t *fixtures.Then) {
vsvc := t.GetVirtualService()
assert.Equal(s.T(), int64(100), vsvc.Spec.TLS[0].Route[0].Weight)
assert.Equal(s.T(), int64(0), vsvc.Spec.TLS[0].Route[1].Weight)

desired, stable := t.GetServices()
rs2 := t.GetReplicaSetByRevision("2")
assert.Equal(s.T(), rs2.Spec.Template.Labels[v1alpha1.DefaultRolloutUniqueLabelKey], desired.Spec.Selector[v1alpha1.DefaultRolloutUniqueLabelKey])
assert.Equal(s.T(), rs2.Spec.Template.Labels[v1alpha1.DefaultRolloutUniqueLabelKey], stable.Spec.Selector[v1alpha1.DefaultRolloutUniqueLabelKey])
}).
ExpectRevisionPodCount("1", 1) // don't scale down old replicaset since it will be within scaleDownDelay

s.TearDownSuite()
}
}

func (s *IstioSuite) TestIstioSubsetSplit() {
s.Given().
RolloutObjects("@istio/istio-subset-split.yaml").
Expand Down