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

AV-206859 Setting ResolvedRef Condition in HTTProute #1558

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pkoshtavmware
Copy link
Contributor

@pkoshtavmware pkoshtavmware commented Oct 18, 2024

AV-206859 Setting ResolvedRef Condition in HTTProute

Testing Status:
Manual Testing done
Unit TestCase added

@pkoshtavmware
Copy link
Contributor Author

Ut run result:

        github.com/vmware/load-balancer-and-ingress-services-for-kubernetes/tests/gatewayapitests               coverage: 0.0% of statements
ok      github.com/vmware/load-balancer-and-ingress-services-for-kubernetes/tests/gatewayapitests/graphlayer    448.268s        coverage: 18.4% of statements in ./...
ok      github.com/vmware/load-balancer-and-ingress-services-for-kubernetes/tests/gatewayapitests/ingestion     220.704s        coverage: 2.8% of statements in ./...
ok      github.com/vmware/load-balancer-and-ingress-services-for-kubernetes/tests/gatewayapitests/npltests      60.479s coverage: 15.7% of statements in ./...
ok      github.com/vmware/load-balancer-and-ingress-services-for-kubernetes/tests/gatewayapitests/status        301.047s        coverage: 12.8% of statements in ./...

_, namespace, name := lib.ExtractTypeNameNamespace(routeTypeNsName)
httpRoute, err := akogatewayapilib.AKOControlConfig().GatewayApiInformers().HTTPRouteInformer.Lister().HTTPRoutes(namespace).Get(name)
if err != nil {
utils.AviLog.Debugf("key: %s, msg: Unable to extract the HTTPRoute object %s for BackendRef validation", key, name)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be Warn or Error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -295,6 +296,9 @@ func (hr *httpRoute) ParseRouteConfig() *RouteConfig {
//Default 0
backend.Port = int32(*ruleBackend.Port)
}
if ruleBackend.BackendRef.Kind != nil {
backend.Kind = string(*ruleBackend.Kind)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

should we by default add Services?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we do not add anything for Kind, as in if we keep kind as "", by default Service gets added as kind

map[string][]string{"RequestHeaderModifier": {"add", "remove", "replace"}},
[][]string{{"avisvc", "default", "8080", "1"}}, nil)
kind := gatewayv1.Kind("InvalidKind")
rule.BackendRefs[0].BackendRef.Kind = &kind
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have additional unit test with two backends, one invalid and one valid and then check for Conditions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

for _, httpbackend := range rule.Backends {
isValidBackend, resolvedRefConditionforBackend := validateBackendReference(key, *httpbackend.Backend, httpRoute)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should include this logic as part of ParseRouteConfig instead of writing down over here. Advantage: We will separate of parsing (and setting of httproute object) from logic of populating AviController objects. Also we will save one Informer call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -764,8 +764,8 @@ func TestHTTPRouteBackendServiceCDC(t *testing.T) {
return 0
}
nodes := aviModel.(*avinodes.AviObjectGraph).GetAviEvhVS()
return len(nodes[0].EvhNodes[0].PoolGroupRefs[0].Members)
}, 25*time.Second).Should(gomega.Equal(1))
return len(nodes[0].EvhNodes[0].PoolGroupRefs)
Copy link
Contributor

Choose a reason for hiding this comment

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

should we have .Members condition also (Which is removed)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@pkoshtavmware pkoshtavmware force-pushed the AV-206859-master branch 3 times, most recently from 5364ef9 to 2021ef1 Compare October 24, 2024 10:28
@pkoshtavmware
Copy link
Contributor Author

Ut run result:

        github.com/vmware/load-balancer-and-ingress-services-for-kubernetes/tests/gatewayapitests               coverage: 0.0% of statements
ok      github.com/vmware/load-balancer-and-ingress-services-for-kubernetes/tests/gatewayapitests/graphlayer    448.181s        coverage: 18.4% of statements in ./...
ok      github.com/vmware/load-balancer-and-ingress-services-for-kubernetes/tests/gatewayapitests/ingestion     220.647s        coverage: 2.7% of statements in ./...
ok      github.com/vmware/load-balancer-and-ingress-services-for-kubernetes/tests/gatewayapitests/npltests      60.348s coverage: 16.0% of statements in ./...
ok      github.com/vmware/load-balancer-and-ingress-services-for-kubernetes/tests/gatewayapitests/status        328.979s        coverage: 16.9% of statements in ./...

@pkoshtavmware
Copy link
Contributor Author

Screenshot 2024-10-24 at 6 18 25 PM

routeConfigRule.Backends = append(routeConfigRule.Backends, httpBackend)
isValidBackend, resolvedRefConditionforBackend := validateBackendReference(key, *backend, hr)
if isValidBackend {
httpBackend.IsValid = true
Copy link
Contributor

Choose a reason for hiding this comment

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

@pkoshtavmware: We do not require IsValid field as we are appending valid Backends only to routeConfigRule.Backends which is being parsed in Graph layer function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

} else {
hasInvalidBackend = true
resolvedRefCondition = resolvedRefConditionforBackend
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

why continue is required over here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

@ashishnayak96
Copy link
Contributor

build ako

@pkoshtavmware
Copy link
Contributor Author

Unit Test run:

        github.com/vmware/load-balancer-and-ingress-services-for-kubernetes/tests/gatewayapitests               coverage: 0.0% of statements
ok      github.com/vmware/load-balancer-and-ingress-services-for-kubernetes/tests/gatewayapitests/graphlayer    448.278s        coverage: 18.4% of statements in ./...
ok      github.com/vmware/load-balancer-and-ingress-services-for-kubernetes/tests/gatewayapitests/ingestion     220.705s        coverage: 2.8% of statements in ./...
ok      github.com/vmware/load-balancer-and-ingress-services-for-kubernetes/tests/gatewayapitests/npltests      60.442s coverage: 15.9% of statements in ./...
ok      github.com/vmware/load-balancer-and-ingress-services-for-kubernetes/tests/gatewayapitests/status        329.120s        coverage: 17.0% of statements in ./...

@pkoshtavmware
Copy link
Contributor Author

Screenshot 2024-10-25 at 3 43 25 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-for-review Pull request is up for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants