Skip to content

Commit b12ec80

Browse files
committed
Fix lint
Signed-off-by: rick.stokkingreef <rick.stokkingreef@airalo.com>
1 parent 615fb9c commit b12ec80

File tree

7 files changed

+78
-14
lines changed

7 files changed

+78
-14
lines changed

pkg/plugin/grpcroute.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,16 @@ func removeManagedGRPCRouteEntry(managedRouteMap ManagedRouteMap, routeRuleList
397397
managedRouteMapKey := managedRouteName + "." + grpcRouteName
398398
return nil, fmt.Errorf(ManagedRouteMapEntryDeleteError, managedRouteMapKey, managedRouteMapKey)
399399
}
400+
if managedRouteIndex < 0 || managedRouteIndex >= len(routeRuleList) {
401+
// stale or corrupted managed route index; clean references for this route and continue gracefully
402+
for name, managedMap := range managedRouteMap {
403+
delete(managedMap, grpcRouteName)
404+
if len(managedMap) == 0 {
405+
delete(managedRouteMap, name)
406+
}
407+
}
408+
return routeRuleList, nil
409+
}
400410
delete(routeManagedRouteMap, grpcRouteName)
401411
if len(managedRouteMap[managedRouteName]) == 0 {
402412
delete(managedRouteMap, managedRouteName)

pkg/plugin/httproute.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,16 @@ func removeManagedHTTPRouteEntry(managedRouteMap ManagedRouteMap, routeRuleList
396396
managedRouteMapKey := managedRouteName + "." + httpRouteName
397397
return nil, fmt.Errorf(ManagedRouteMapEntryDeleteError, managedRouteMapKey, managedRouteMapKey)
398398
}
399+
if managedRouteIndex < 0 || managedRouteIndex >= len(routeRuleList) {
400+
// stale or corrupted managed route index; clean references for this route and continue gracefully
401+
for name, managedMap := range managedRouteMap {
402+
delete(managedMap, httpRouteName)
403+
if len(managedMap) == 0 {
404+
delete(managedRouteMap, name)
405+
}
406+
}
407+
return routeRuleList, nil
408+
}
399409
delete(routeManagedRouteMap, httpRouteName)
400410
if len(managedRouteMap[managedRouteName]) == 0 {
401411
delete(managedRouteMap, managedRouteName)

test/e2e/constants.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ const (
3535
GRPC_ROUTE_FILTERS_PATH = "./testdata/grpcroute-filters.yml"
3636
GRPC_ROUTE_FILTERS_ROLLOUT_PATH = "./testdata/single-grpcroute-filters-rollout.yml"
3737

38+
// HTTP Route label test paths
39+
HTTP_ROUTE_LABEL_PATH = "./testdata/httproute-basic.yml"
40+
HTTP_ROUTE_LABEL_ROLLOUT_PATH = "./testdata/single-httproute-label-rollout.yml"
41+
3842
ROLLOUT_TEMPLATE_CONTAINERS_FIELD = "spec.template.spec.containers"
3943
ROLLOUT_TEMPLATE_FIRST_CONTAINER_FIELD = "spec.template.spec.containers.0"
4044
NEW_IMAGE_FIELD_VALUE = "argoproj/rollouts-demo:green"

test/e2e/httproute_label_test.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,36 +52,36 @@ func setupHTTPRouteLabelEnv(ctx context.Context, t *testing.T, config *envconf.C
5252
clusterResources := config.Client().Resources()
5353
resourcesMap := map[string]*unstructured.Unstructured{}
5454
ctx = context.WithValue(ctx, RESOURCES_MAP_KEY, resourcesMap)
55-
firstHTTPRouteFile, err := os.Open(HTTP_ROUTE_BASIC_PATH)
55+
firstHTTPRouteFile, err := os.Open(HTTP_ROUTE_LABEL_PATH)
5656
if err != nil {
57-
logrus.Errorf("file %q opening was failed: %s", HTTP_ROUTE_BASIC_PATH, err)
57+
logrus.Errorf("file %q opening was failed: %s", HTTP_ROUTE_LABEL_PATH, err)
5858
t.Error()
5959
return ctx
6060
}
6161
defer firstHTTPRouteFile.Close()
62-
logrus.Infof("file %q was opened", HTTP_ROUTE_BASIC_PATH)
63-
rolloutFile, err := os.Open(HTTP_ROUTE_BASIC_ROLLOUT_PATH)
62+
logrus.Infof("file %q was opened", HTTP_ROUTE_LABEL_PATH)
63+
rolloutFile, err := os.Open(HTTP_ROUTE_LABEL_ROLLOUT_PATH)
6464
if err != nil {
65-
logrus.Errorf("file %q opening was failed: %s", HTTP_ROUTE_BASIC_ROLLOUT_PATH, err)
65+
logrus.Errorf("file %q opening was failed: %s", HTTP_ROUTE_LABEL_ROLLOUT_PATH, err)
6666
t.Error()
6767
return ctx
6868
}
6969
defer rolloutFile.Close()
70-
logrus.Infof("file %q was opened", HTTP_ROUTE_BASIC_ROLLOUT_PATH)
70+
logrus.Infof("file %q was opened", HTTP_ROUTE_LABEL_ROLLOUT_PATH)
7171
err = decoder.Decode(firstHTTPRouteFile, &httpRoute)
7272
if err != nil {
73-
logrus.Errorf("file %q decoding was failed: %s", HTTP_ROUTE_BASIC_PATH, err)
73+
logrus.Errorf("file %q decoding was failed: %s", HTTP_ROUTE_LABEL_PATH, err)
7474
t.Error()
7575
return ctx
7676
}
77-
logrus.Infof("file %q was decoded", HTTP_ROUTE_BASIC_PATH)
77+
logrus.Infof("file %q was decoded", HTTP_ROUTE_LABEL_PATH)
7878
err = decoder.Decode(rolloutFile, &rollout)
7979
if err != nil {
80-
logrus.Errorf("file %q decoding was failed: %s", HTTP_ROUTE_BASIC_ROLLOUT_PATH, err)
80+
logrus.Errorf("file %q decoding was failed: %s", HTTP_ROUTE_LABEL_ROLLOUT_PATH, err)
8181
t.Error()
8282
return ctx
8383
}
84-
logrus.Infof("file %q was decoded", HTTP_ROUTE_BASIC_ROLLOUT_PATH)
84+
logrus.Infof("file %q was decoded", HTTP_ROUTE_LABEL_ROLLOUT_PATH)
8585
httpRouteObject, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&httpRoute)
8686
if err != nil {
8787
logrus.Errorf("httpRoute %q converting to unstructured was failed: %s", httpRoute.GetName(), err)
@@ -327,4 +327,3 @@ func getMatchHTTPRouteLabelFetcher(t *testing.T, expectLabel bool) func(k8s.Obje
327327
return !ok
328328
}
329329
}
330-

test/e2e/testdata/grpcroute-filters.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ spec:
2525
value: grpc-added-value
2626
remove:
2727
- X-Remove-GRPC-Header
28-
# ResponseHeaderModifier - adds, sets, and removes response headers
28+
# Unsupported filters
29+
# ResponseHeaderModifier - adds, sets, and removes response headers
2930
- type: ResponseHeaderModifier
3031
responseHeaderModifier:
3132
set:
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: Rollout
3+
metadata:
4+
name: httproute-label
5+
namespace: default
6+
spec:
7+
replicas: 2
8+
strategy:
9+
canary:
10+
canaryService: argo-rollouts-canary-service
11+
stableService: argo-rollouts-stable-service
12+
trafficRouting:
13+
plugins:
14+
argoproj-labs/gatewayAPI:
15+
httpRoute: httproute-basic
16+
namespace: default
17+
steps:
18+
- setWeight: 30
19+
- pause:
20+
duration: 10s
21+
revisionHistoryLimit: 1
22+
selector:
23+
matchLabels:
24+
app: rollouts-demo
25+
template:
26+
metadata:
27+
labels:
28+
app: rollouts-demo
29+
spec:
30+
containers:
31+
- name: rollouts-demo
32+
image: argoproj/rollouts-demo:red
33+
ports:
34+
- name: http
35+
containerPort: 8080
36+
protocol: TCP
37+
resources:
38+
requests:
39+
memory: 32Mi
40+
cpu: 5m

test/e2e/testdata/single-httproute-rollout.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ spec:
1616
namespace: default
1717
steps:
1818
- setWeight: 30
19-
- pause: { }
19+
- pause: {}
2020
revisionHistoryLimit: 1
2121
selector:
2222
matchLabels:
@@ -36,4 +36,4 @@ spec:
3636
resources:
3737
requests:
3838
memory: 32Mi
39-
cpu: 5m
39+
cpu: 5m

0 commit comments

Comments
 (0)