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

Generate VirtualServices based on DependencyProxy #282

Merged

Conversation

shriramsharma
Copy link
Collaborator

fixes #278

@shriramsharma shriramsharma marked this pull request as ready for review February 8, 2023 20:17
@aattuluri aattuluri changed the title added ability to generate VirtualServices based of dependencyProxy resources Generate VirtualServices based on DependencyProxy Feb 10, 2023
addUpdateVirtualService(ctx, obj, exist, syncNamespace, rc)
}
}
}
return nil
}

func addUpdateVirtualService(ctx context.Context, obj *v1alpha3.VirtualService, exist *v1alpha3.VirtualService, namespace string, rc *RemoteController) {
func addUpdateVirtualService(ctx context.Context, obj *v1alpha3.VirtualService, exist *v1alpha3.VirtualService, namespace string, rc *RemoteController) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add a function to evaluate if the update is destructive or not?

And do we need knowledge from multiple clusters to build this virtual service? Just like admiral requires knowledge from multiple clusters to build service entries, hence we skip destructive updates during start up time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Add some logging on diff

}
for _, dependency := range dependencies {
vs := remoteRegistry.AdmiralCache.DependencyProxyVirtualServiceCache.get(dependency)
if vs == nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick:

if vs == nil || len(vs) == 0 {
  continue
}

if err != nil {
return fmt.Errorf("failed generating proxy VirtualService %s due to error: %w", v.Name, err)
}
log.Infof("successfully generated proxy VirtualService %s", v.Name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick suggestion: addUpdateVirtualService is adding success/failure logs.

expectedVS *v1alpha3.VirtualService
}{
{
name: "Given dependency proxy to generate VS, when dependencylookipCache is nil, then the func should return an error",
Copy link
Collaborator

@nirvanagit nirvanagit Feb 10, 2023

Choose a reason for hiding this comment

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

nitpick, typo: dependencylookipCache -> dependencylookupCache

expectedError: fmt.Errorf("remoteRegistry.AdmiralCache.DependencyProxyVirtualServiceCache is nil"),
},
{
name: "Given dependency proxy to generate VS, when the sourceIdentity is not in dependencylookipCache, then the func should not return an error",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we also assert that we are calling the client to create the VS ?

@@ -124,6 +135,32 @@ func NewRemoteRegistry(ctx context.Context, params common.AdmiralParams) *Remote
}
}

type dependencyLookupCache struct {
sourceDestinations map[string][]string
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we call this destinationBySource, or sourceToDestinations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sourceToDestinations

dnsSuffix := dependencyProxyObj.Spec.Destination.DnsSuffix
proxyEnv := dependencyProxyObj.ObjectMeta.Annotations[common.GetEnvKey()]

defaultVSHostName := strings.ToLower(common.GetCnameVal([]string{proxyEnv, destinationServiceIdentity, dnsSuffix}))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

just put this in a interface

…sources

Signed-off-by: Shriram Sharma <shriram_sharma@intuit.com>
Signed-off-by: Shriram Sharma <shriram_sharma@intuit.com>
Signed-off-by: Shriram Sharma <shriram_sharma@intuit.com>
@@ -1,8 +1,6 @@
apiversion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: sample
Copy link
Collaborator

Choose a reason for hiding this comment

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

not using namespace anymore?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

adding it back, I'm not sure how this got removed

@@ -0,0 +1,24 @@
#!/bin/bash -e

## This test verifies if the DependencyProxy created for the httpbin service
Copy link
Collaborator

Choose a reason for hiding this comment

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

May be add the flow of request what we discussed yesterday as well.

Signed-off-by: Shriram Sharma <shriram_sharma@intuit.com>
@shriramsharma shriramsharma merged commit 3ff6232 into istio-ecosystem:master Feb 15, 2023
@shriramsharma shriramsharma deleted the create-vs-dep-proxy branch February 15, 2023 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants