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: missing fields in destinationrule #1253

Merged
merged 3 commits into from
Jun 11, 2021

Conversation

huikang
Copy link
Member

@huikang huikang commented Jun 6, 2021

  • add Extra to DestinationRule to hold any other fields from istio's
    destinationRule
  • handle any extra fields that could be introduced to the subsets
    in istio's destinationRule fields
  • unit test added

Signed-off-by: Hui Kang [email protected]

close #1238

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this is a chore.
  • The title of the PR is (a) conventional, (b) states what changed, and (c) suffixes the related issues number. E.g. "fix(controller): Updates such and such. Fixes #1234".
  • I've signed my commits with DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My builds are green. Try syncing with master if they are not.
  • My organization is added to USERS.md.

@huikang huikang force-pushed the 1238-DestinationRule-unstrctured branch 2 times, most recently from 22d64b1 to 9368587 Compare June 6, 2021 22:36
- Add Extra to DestinationRule to hold any other fields from istio's
  destinationRule
- handle any extra fields that could be introduced to the subsets
  in istio's destinationRule fields
- unit test

Signed-off-by: Hui Kang <[email protected]>
@huikang huikang force-pushed the 1238-DestinationRule-unstrctured branch from 9368587 to 24e8350 Compare June 6, 2021 22:56
@huikang
Copy link
Member Author

huikang commented Jun 7, 2021

@jessesuen , please take a look at this PR when you have time. The approach is tedious as we can not predict the key names of the additional fields in the subets. Do you have any better idea? Thanks.

rollout/trafficrouting/istio/istio.go Outdated Show resolved Hide resolved
rollout/trafficrouting/istio/istio.go Outdated Show resolved Hide resolved
Comment on lines 399 to 413
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: istio-destrule
namespace: default
spec:
subsets:
- name: stable
labels:
version: v3
- name: canary
trafficPolicy:
loadBalancer:
simple: ROUND_ROBIN
`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we improve the test to verify we also preserve fields at the .spec.XXX level? For example, this example from istio docs which has spec.host and spec.trafficPolicy:

apiVersion: networking.istio.io/v1beta1
kind: DestinationRule
metadata:
  name: bookinfo-ratings
spec:
  host: ratings.prod.svc.cluster.local
  trafficPolicy:
    loadBalancer:
      simple: LEAST_CONN
  subsets:
  - name: testversion
    labels:
      version: v3
    trafficPolicy:
      loadBalancer:
        simple: ROUND_ROBIN

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Let me update the PR to generalize the method to the .spec.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jessesuen , I think the current implement has been able to preserve the fields of .spec.XXX. Following is a snippet of a destination rule after an update to a rollout.

spec:
  host: istio-rollout                                                <--------- Preserved
  subsets:
  - labels:
      app: istio-rollout
      rollouts-pod-template-hash: 6646844db8
    name: canary
  - labels:
      app: istio-rollout
      rollouts-pod-template-hash: cf89dfb88
    name: stable
    trafficPolicy:                                                      <--------- Preserved by the PR
      loadBalancer:
        simple: ROUND_ROBIN
  trafficPolicy:                                                         <--------- Preserved
    loadBalancer:
      simple: LEAST_CONN

However, I could not find the relevant part in the code. Do you have any idea?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So to verify we preserve the fields under .spec, I added a string comparison between the expected result and the unstructured object.

Signed-off-by: Hui Kang <[email protected]>
@codecov
Copy link

codecov bot commented Jun 10, 2021

Codecov Report

Merging #1253 (574e402) into master (d9d1237) will decrease coverage by 0.03%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1253      +/-   ##
==========================================
- Coverage   81.40%   81.36%   -0.04%     
==========================================
  Files         106      106              
  Lines        9527     9599      +72     
==========================================
+ Hits         7755     7810      +55     
- Misses       1251     1260       +9     
- Partials      521      529       +8     
Impacted Files Coverage Δ
rollout/trafficrouting/istio/istio.go 78.03% <75.00%> (-0.45%) ⬇️
rollout/controller.go 78.35% <0.00%> (-0.10%) ⬇️
rollout/trafficrouting/istio/controller.go 43.41% <0.00%> (ø)
...ctl-argo-rollouts/viewcontroller/viewcontroller.go 71.84% <0.00%> (ø)
utils/controller/controller.go 82.92% <0.00%> (+0.13%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d9d1237...574e402. Read the comment docs.

@sonarcloud
Copy link

sonarcloud bot commented Jun 10, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
3.4% 3.4% Duplication

@jessesuen jessesuen merged commit fa865d3 into argoproj:master Jun 11, 2021
@jessesuen
Copy link
Member

Thank you!

caoyang001 pushed a commit to caoyang001/argo-rollouts that referenced this pull request Jun 12, 2021
perenesenko pushed a commit to perenesenko/argo-rollouts that referenced this pull request Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Istio DestinationRule subset trafficPolicy lost
2 participants