Skip to content

Commit

Permalink
add host and trafficpolicy to .spec
Browse files Browse the repository at this point in the history
Signed-off-by: Hui Kang <[email protected]>
  • Loading branch information
Hui Kang committed Jun 10, 2021
1 parent 81d600f commit 574e402
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rollout/trafficrouting/istio/istio.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func updateDestinationRule(ctx context.Context, client dynamic.ResourceInterface
if err != nil {
return false, err
}
log.Infof("updated destinationrule: %s", string(patch))
log.Infof("updating destinationrule: %s", string(patch))
return true, nil
}

Expand Down
10 changes: 10 additions & 0 deletions rollout/trafficrouting/istio/istio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ metadata:
name: istio-destrule
namespace: default
spec:
host: ratings.prod.svc.cluster.local
trafficPolicy:
loadBalancer:
simple: LEAST_CONN
subsets:
- name: stable
labels:
Expand All @@ -424,6 +428,12 @@ spec:

dRuleUn, err := client.Resource(istioutil.GetIstioDestinationRuleGVR()).Namespace(r.rollout.Namespace).Get(context.TODO(), "istio-destrule", metav1.GetOptions{})
assert.NoError(t, err)

dRuleUnBytes, err := json.Marshal(dRuleUn)
assert.NoError(t, err)
assert.Equal(t, `{"apiVersion":"networking.istio.io/v1alpha3","kind":"DestinationRule","metadata":{"annotations":{"argo-rollouts.argoproj.io/managed-by-rollouts":"rollout"},"name":"istio-destrule","namespace":"default"},"spec":{"host":"ratings.prod.svc.cluster.local","subsets":[{"labels":{"rollouts-pod-template-hash":"def456","version":"v3"},"name":"stable"},{"labels":{"rollouts-pod-template-hash":"abc123"},"name":"canary","trafficPolicy":{"loadBalancer":{"simple":"ROUND_ROBIN"}}}],"trafficPolicy":{"loadBalancer":{"simple":"LEAST_CONN"}}}}`,
string(dRuleUnBytes))

_, dRule, _, err := unstructuredToDestinationRules(dRuleUn)
assert.NoError(t, err)
assert.Equal(t, dRule.Annotations[v1alpha1.ManagedByRolloutsKey], "rollout")
Expand Down

0 comments on commit 574e402

Please sign in to comment.