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

feat: support management of multiple Istio VirtualService objects #1381

Merged

Conversation

darshanhs09
Copy link
Contributor

@darshanhs09 darshanhs09 commented Jul 29, 2021

Fixes #1100

Currently, Argo Rollout spec only supports a single VirtualService (VS) in its Istio integrated canary.
Multiple VirtualService support is needed in Istio-based setups in which a service's routes are given in multiple VirtualService objects rather than just a single one.

Use cases:
This feature is required to enable canary/blue-green traffic shifting for services with multiple port delegate VirtualServices.
It's very common to have multiple VirtualService's pointing to a single backend service.

Signed-off-by: Darshan Hassan Shashikumar [email protected]

Note: Users are recommended to use "trafficRouting.istio.virtualServices" instead of "trafficRouting.istio.virtualService". Because it provides more flexibility in adding one or more virtualServices. I am still keeping virtualService is to provide the backward compatibility. Going forward, we can deprecate "trafficRouting.istio.virtualService".

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.

@darshanhs09 darshanhs09 force-pushed the multiple-virtual-services-support branch from d2c0b6a to 3f3462f Compare July 29, 2021 21:12
@darshanhs09 darshanhs09 changed the title feat: Multiple VirtualService objects support for canary strategy of Argo Rollouts. Fixes #1100 feat: Multiple VirtualService objects support for canary strategy of Argo Rollouts. Fixes #1100 Jul 29, 2021
@darshanhs09 darshanhs09 changed the title feat: Multiple VirtualService objects support for canary strategy of Argo Rollouts. Fixes #1100 feat: Multiple VirtualService objects support for canary strategy of Argo Rollouts Jul 29, 2021
…Argo Rollouts fixes argoproj#1100

Signed-off-by: Darshan Hassan Shashikumar <[email protected]>
@darshanhs09 darshanhs09 force-pushed the multiple-virtual-services-support branch from 810a451 to ec64953 Compare July 31, 2021 22:56
Copy link
Member

@huikang huikang left a comment

Choose a reason for hiding this comment

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

Thanks for the contributions. My review comments are added.

docs/getting-started/istio/index.md Outdated Show resolved Hide resolved
docs/getting-started/istio/index.md Outdated Show resolved Hide resolved
docs/getting-started/istio/rollout.yaml Show resolved Hide resolved
rollout/trafficrouting/istio/controller_test.go Outdated Show resolved Hide resolved
rollout/trafficrouting/istio/controller_test.go Outdated Show resolved Hide resolved
rollout/trafficrouting/istio/istio.go Outdated Show resolved Hide resolved
// GetRolloutVirtualServiceKeys gets the referenced VirtualService and its namespace from a Rollout
func GetRolloutVirtualServiceKeys(ro *v1alpha1.Rollout) []string {
var virtualServices []v1alpha1.IstioVirtualService
var virtualServiceKeys []string
Copy link
Member

Choose a reason for hiding this comment

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

Are we getting keys or just namespace+name? The variable name is kind of confusing.

Copy link
Contributor Author

@darshanhs09 darshanhs09 Aug 3, 2021

Choose a reason for hiding this comment

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

Basically, we get the list of keys. each key will be in the format of namespace / virtualService Name

Copy link
Member

Choose a reason for hiding this comment

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

so how about vsvsNamespaceName? Key seems have different meanings in k8s.

Copy link
Member

Choose a reason for hiding this comment

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

not resolved yet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only way to identify the rollout is with namespace and name. So, having the key as the variable name would make more sense.
I didn't change this in my latest update. Let me know your thoughts.

utils/istio/istio.go Outdated Show resolved Hide resolved
if namespace == "" {
namespace = ro.Namespace
if MultipleVirtualServiceConfigured(ro) {
if canary.TrafficRouting.Istio.VirtualService.Name != "" {
Copy link
Member

Choose a reason for hiding this comment

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

this should not happen, right? Because the validation logic will not allow to reach this place. If so, this is a panic.
Or we can remove line 86 - 88

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's say both virtualService and virtualServices are configured then MultipleVirtualServiceConfigured method return true. Since both are configured which is an invalid configuration. so, i am having this check.

Copy link
Member

Choose a reason for hiding this comment

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

Such scenario should be detected earlier in the validationVirtualServiceConfig, I believe this if and return empty string array may introduce a subtle bug in the future.

Copy link
Member

Choose a reason for hiding this comment

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

please resolve this comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this check is already taken care. I have removed it.
Please check, let me know if you are okay with this change then I will resolve it.

…Argo Rollouts. Addressed all the review comments fixes argoproj#1100

Signed-off-by: Darshan Hassan Shashikumar <[email protected]>
@darshanhs09 darshanhs09 force-pushed the multiple-virtual-services-support branch from 9f0125f to 415edd8 Compare August 3, 2021 20:38
@shakti-das
Copy link
Contributor

Hi @jessesuen, could you please review this PR when you find the time. We want to get Argo Rollouts to production soon and this issue is a blocker right now. Thank you.

Copy link
Member

@huikang huikang left a comment

Choose a reason for hiding this comment

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

Thanks for the update. Looks much better.

docs/getting-started/istio/index.md Outdated Show resolved Hide resolved
docs/getting-started/istio/index.md Outdated Show resolved Hide resolved
docs/getting-started/istio/index.md Outdated Show resolved Hide resolved
docs/getting-started/istio/index.md Outdated Show resolved Hide resolved
docs/getting-started/istio/index.md Outdated Show resolved Hide resolved
docs/getting-started/istio/index.md Outdated Show resolved Hide resolved
rollout/trafficrouting/istio/controller.go Outdated Show resolved Hide resolved
docs/getting-started/istio/index.md Outdated Show resolved Hide resolved
…Argo Rollouts. Addressed the minor review comments fixes argoproj#1100

Signed-off-by: Darshan Hassan Shashikumar <[email protected]>
@darshanhs09 darshanhs09 force-pushed the multiple-virtual-services-support branch from bc187bb to b355ffb Compare August 4, 2021 18:41
if namespace == "" {
namespace = ro.Namespace
if MultipleVirtualServiceConfigured(ro) {
if canary.TrafficRouting.Istio.VirtualService.Name != "" {
Copy link
Member

Choose a reason for hiding this comment

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

Such scenario should be detected earlier in the validationVirtualServiceConfig, I believe this if and return empty string array may introduce a subtle bug in the future.

rollout/trafficrouting/istio/istio_test.go Outdated Show resolved Hide resolved
@huikang
Copy link
Member

huikang commented Aug 5, 2021

Hi, @jessesuen , I almost finished reviewing this PR. Do you mind kicking off the CI flow? Thanks.

@codecov
Copy link

codecov bot commented Aug 5, 2021

Codecov Report

Merging #1381 (80bf601) into master (c72a354) will increase coverage by 0.07%.
The diff coverage is 89.10%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1381      +/-   ##
==========================================
+ Coverage   81.35%   81.43%   +0.07%     
==========================================
  Files         108      108              
  Lines       14505    14573      +68     
==========================================
+ Hits        11801    11867      +66     
  Misses       2089     2089              
- Partials      615      617       +2     
Impacted Files Coverage Δ
rollout/controller.go 75.19% <40.00%> (-0.35%) ⬇️
rollout/trafficrouting/istio/controller.go 50.81% <76.00%> (+3.38%) ⬆️
.../apis/rollouts/validation/validation_references.go 84.58% <87.09%> (+2.10%) ⬆️
rollout/trafficrouting/istio/istio.go 80.96% <100.00%> (+0.24%) ⬆️
utils/istio/istio.go 95.00% <100.00%> (+1.52%) ⬆️

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 c72a354...80bf601. Read the comment docs.

…Argo Rollouts. Addressed few minor review comments fixes argoproj#1100

Signed-off-by: Darshan Hassan Shashikumar <[email protected]>
@darshanhs09 darshanhs09 force-pushed the multiple-virtual-services-support branch from a611c0b to 58d3595 Compare August 5, 2021 21:06
@darshanhs09
Copy link
Contributor Author

darshanhs09 commented Aug 5, 2021

Hi @jessesuen , I have updated the PR.
Can you please kickoff the CI flow again?
Thanks

Copy link
Member

@huikang huikang left a comment

Choose a reason for hiding this comment

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

Please do not mark the comment resolved as you have not made any change.

rollout/trafficrouting/istio/istio_test.go Outdated Show resolved Hide resolved
// GetRolloutVirtualServiceKeys gets the referenced VirtualService and its namespace from a Rollout
func GetRolloutVirtualServiceKeys(ro *v1alpha1.Rollout) []string {
var virtualServices []v1alpha1.IstioVirtualService
var virtualServiceKeys []string
Copy link
Member

Choose a reason for hiding this comment

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

not resolved yet

if namespace == "" {
namespace = ro.Namespace
if MultipleVirtualServiceConfigured(ro) {
if canary.TrafficRouting.Istio.VirtualService.Name != "" {
Copy link
Member

Choose a reason for hiding this comment

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

please resolve this comment

@shakti-das
Copy link
Contributor

@darshanhs09 could you please address the open review comments. Thanks.

@jessesuen jessesuen changed the title feat: Multiple VirtualService objects support for canary strategy of Argo Rollouts feat: support management of multiple Istio VirtualService objects Aug 12, 2021
…Argo Rollouts. Addressed few minor review comments fixes argoproj#1100

Signed-off-by: Darshan Hassan Shashikumar <[email protected]>
@darshanhs09 darshanhs09 force-pushed the multiple-virtual-services-support branch from 6061e68 to 2222dc8 Compare August 12, 2021 11:31
@darshanhs09
Copy link
Contributor Author

@darshanhs09 could you please address the open review comments. Thanks.

Hi @shakti-das, I was out of town so couldn't check.
I have updated the changes now.
Thanks

…Argo Rollouts. fixing the lint issue. fixes argoproj#1100

Signed-off-by: Darshan Hassan Shashikumar <[email protected]>
@darshanhs09 darshanhs09 force-pushed the multiple-virtual-services-support branch from 415576c to f627404 Compare August 12, 2021 12:03
@huikang
Copy link
Member

huikang commented Aug 13, 2021

Could you resolve the conflict? Else LGTM.

@sboobna
Copy link

sboobna commented Aug 17, 2021

@darshanhs09

@darshanhs09
Copy link
Contributor Author

TlsRoutes is a new field introduced in virtualService.
Now, I cannot commit my changes directly not just because it is conflicting with some of my changes.
I have to also handle this new field in virtualServices.
So, I made the changes to handle this new field in multiple virtual services. But I am yet to test it.
Once I am done with my testing I will update the PR.

Thanks

@@ -354,9 +354,11 @@ type NginxTrafficRouting struct {
// IstioTrafficRouting configuration for Istio service mesh to enable fine grain configuration
type IstioTrafficRouting struct {
// VirtualService references an Istio VirtualService to modify to shape traffic
VirtualService IstioVirtualService `json:"virtualService" protobuf:"bytes,1,opt,name=virtualService"`
VirtualService IstioVirtualService `json:"virtualService,omitempty" protobuf:"bytes,1,opt,name=virtualService"`
Copy link
Member

Choose a reason for hiding this comment

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

I think the VirtualService field will need to be changed to a *IstioVirtualService pointer, now that it is optional, since otherwise the virtualService field will be defaulted to an empty struct after json marshaling. e.g.:

spec:
  strategy:
    canary:
      trafficRouting:
        istio:
          virtualService: {}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah! you are right!
I am thinking, I will take care of this separately. All the existing code of virtualService needs to changed for this. It would be better to take care of it in a separate issue.

…Argo Rollouts. fixing the unit test issue. fixes argoproj#1100

Signed-off-by: Darshan Hassan Shashikumar <[email protected]>
@darshanhs09 darshanhs09 force-pushed the multiple-virtual-services-support branch from 34ddd1d to 5870f2e Compare August 27, 2021 17:42
…Argo Rollouts. Adding the TLSRoute details in the multiple virtualService spec. fixes argoproj#1100

Signed-off-by: Darshan Hassan Shashikumar <[email protected]>
@darshanhs09 darshanhs09 force-pushed the multiple-virtual-services-support branch from 61c0ace to 0c0871c Compare August 27, 2021 17:55
@darshanhs09
Copy link
Contributor Author

@huikang I have resolved the conflicts and update the PR.
Can you please check and approve?
@jessesuen Can you please kickoff the CI flow?

@huikang
Copy link
Member

huikang commented Aug 27, 2021

Hi, @darshanhs09, thanks for the update. Could you resolve the lint issue and re-run codegen?

Copy link
Member

@huikang huikang left a comment

Choose a reason for hiding this comment

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

some minor suggestions in the test file

rollout/trafficrouting/istio/controller_test.go Outdated Show resolved Hide resolved
pkg/apis/rollouts/validation/validation_references_test.go Outdated Show resolved Hide resolved
pkg/apis/rollouts/validation/validation_references_test.go Outdated Show resolved Hide resolved
…Argo Rollouts. Addressing few minor comments and lint issues. fixes argoproj#1100

Signed-off-by: Darshan Hassan Shashikumar <[email protected]>
@darshanhs09 darshanhs09 force-pushed the multiple-virtual-services-support branch from 8d9cffd to bb1afbe Compare August 27, 2021 21:22
@darshanhs09
Copy link
Contributor Author

I have addressed Hui comments and lint issues.
@jessesuen Can you please kickoff the CI flow again?

@huikang
Copy link
Member

huikang commented Aug 31, 2021

LGTM

@darshanhs09 darshanhs09 force-pushed the multiple-virtual-services-support branch from 6c2f60e to 80bf601 Compare August 31, 2021 07:46
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

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

No Coverage information No Coverage information
13.7% 13.7% Duplication

@darshanhs09
Copy link
Contributor Author

@huikang Thanks for reviewing.
@jessesuen Can you please run the CI flow ?

@jessesuen jessesuen merged commit 8c3e1a2 into argoproj:master Sep 8, 2021
@jessesuen
Copy link
Member

Great work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants