Users want Ambassador to normalize route weights to integers.
See original GitHub issueDescribe the bug Configuration generation crash (config.py)
To Reproduce Create any app that you have, integrate with ambassador with following piece of yaml
---
apiVersion: v1
kind: Service
metadata:
name: sample-application
annotations:
getambassador.io/config: |
---
apiVersion: ambassador/v0
kind: Mapping
name: sample-application
prefix: /sample-application/
service: https://sample-application:80
tls: upstream
spec:
ports:
- port: 80
name: http
protocol: TCP
targetPort: 8080
selector:
app: sample-application
type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
name: sample-application-2
annotations:
getambassador.io/config: |
---
apiVersion: ambassador/v0
kind: Mapping
name: sample-application-2
prefix: /sample-application/
service: https://sample-application-2:80
tls: upstream
spec:
ports:
- port: 80
name: http
protocol: TCP
targetPort: 8080
selector:
app: sample-application
type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
name: sample-application-3
annotations:
getambassador.io/config: |
---
apiVersion: ambassador/v0
kind: Mapping
name: sample-application-3
prefix: /sample-application/
service: https://sample-application-3:80
tls: upstream
spec:
ports:
- port: 80
name: http
protocol: TCP
targetPort: 8080
selector:
app: sample-application
type: ClusterIP
---
this will result in following error
[2018-09-17 15:06:54.898][1941][critical][main] source/server/config_validation/server.cc:48] error initializing configuration '/ambassador/ambassador-config-104-envoy.json': JSON at lines 1-1 does not conform to schema.
Invalid schema: #/definitions/weighted_clusters/properties/clusters/items/properties/weight
Schema violation: type
Offending document key: #/weighted_clusters/clusters/0/weight
2018-09-17 15:06:54 kubewatch 0.39.0 INFO: Invalid envoy config
2018-09-17 15:06:54 kubewatch 0.39.0 INFO: {
.... a lot of stuff here ...
2018-09-17 15:06:54 kubewatch 0.39.0 ERROR: could not restart Envoy
Traceback (most recent call last):
File "/ambassador/kubewatch.py", line 126, in run
self.restart()
File "/ambassador/kubewatch.py", line 135, in restart
config = self.generate_config(output)
File "/ambassador/kubewatch.py", line 192, in generate_config
raise ValueError("Unable to generate config")
ValueError: Unable to generate config
Expected behavior Ambassador is able to consume following piece of configuration
"clusters": [
{ "name": "cluster_https___sample_app_80_otls_upstream", "weight": 33.333333333333336 },
{ "name": "cluster_https___sample_app_80_otls_upstream", "weight": 33.333333333333336 },
{ "name": "cluster_https___sample_app_80_otls_upstream", "weight": 33.333333333333336 }
]
Versions (please complete the following information):
- Ambassador: ambassador:0.39.0
- Kubernetes environment:
- Version:
Additional context Problem is probably with following piece of code
for cluster in configuration.get('clusters', []):
maps_to_service = cluster_to_service_mapping.get(cluster['name'])
if maps_to_service:
service_weigth = 100.0 / len(cluster['urls'])
for url in cluster['urls']:
ambassador_services.append(SourcedDict(
_from=cluster,
type=maps_to_service,
name=url,
cluster=cluster['name'],
_service_weight=service_weigth
ambassador generates floating variable
"weight": 33.333333333333336
but requires integer in the schema : https://github.com/datawire/ambassador/blob/master/ambassador/schemas/v0/Mapping.schema#L70
In newest version, this causes crash, but not cause downtime, as far as I remember, when I first time saw this error, it caused ambassador downtime (so, is better), this is not a blocker 😃
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Users want Ambassador to normalize route weights to integers.
Users want Ambassador to normalize route weights to integers. ... Create any app that you have, integrate with ambassador with following ...
Read more >HTTP route components (proto) - Envoy Proxy
The router selects an upstream cluster based on the weights. ... (WebSocket and the like) as they are normalized in Envoy as HTTP/1.1...
Read more >Text - H.R.2471 - 117th Congress (2021-2022): Consolidated ...
Text for H.R.2471 - 117th Congress (2021-2022): Consolidated Appropriations Act, 2022.
Read more >Build a Reporting and Analytics Strategy
BI tools access and analyze data sets and present analytical findings in reports, summaries, dashboards, graphs, charts, and maps to provide users with ......
Read more >Rethinking the Egyptian–Israeli Peace Treaty: Perceptions and ...
The Israeli invasion of Lebanon in June 1982 led Cairo to recall its ambassador to Israel—as a result, the budding relations between the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for testing!
We run into the same issue, when you add 3 times the same service without weight, the calculated weight is: 33.333333333. This will break envoy.
I tried to fix it: https://github.com/datawire/ambassador/compare/master...Nightapes:fix/weight?expand=1#diff-497e4afaf589877b6ff5f8325ef97798. But i have problems running the tests on my machine. Should i make a PR for that?