Fractional traffic weights don't seem to be set accurately
herojan opened this issue · comments
herojan commented
I have created a stackset called ss-stack
with stacks v1
and v2
. When I switch traffic using fractional values, the resulting traffic percentage is slightly inaccurate. See the following examples:
Examples
zkubectl traffic ss-stack ss-stack-v2 50.1
Name │Actual│Desired
ss-stack-v1 100 50
ss-stack-v2 0 50.1
Name │Actual│Desired
ss-stack-v1 50.0 50.0
ss-stack-v2 50.0 50.0
And in the stackset status I see:
[
{
"serviceName": "ss-stack-v1",
"servicePort": 5678,
"stackName": "ss-stack-v1",
"weight": 49.95004995004995
},
{
"serviceName": "ss-stack-v2",
"servicePort": 5678,
"stackName": "ss-stack-v2",
"weight": 50.049950049950056
}
]
Another example is
zkubectl traffic ss-stack ss-stack-v2 50.8
Name │Actual│Desired
ss-stack-v1 50.0 49
ss-stack-v2 50.0 50.8
Name │Actual│Desired
ss-stack-v1 49.1 49.1
ss-stack-v2 50.9 50.9
And the stackset status is
[
{
"serviceName": "ss-stack-v1",
"servicePort": 5678,
"stackName": "ss-stack-v1",
"weight": 49.09819639278557
},
{
"serviceName": "ss-stack-v2",
"servicePort": 5678,
"stackName": "ss-stack-v2",
"weight": 50.901803607214426
}
]
The stackset used was:
apiVersion: zalando.org/v1
kind: StackSet
metadata:
labels:
application: ss-stack
name: ss-stack
spec:
externalIngress:
backendPort: 5678
stackTemplate:
spec:
replicas: 1
version: v1
podTemplate:
spec:
containers:
- name: gw-test-app
image: hashicorp/http-echo
args: ["-text", "Stack V1"]
ports:
- containerPort: 5678
resources:
requests:
cpu: 1
memory: 100Mi
limits:
memory: 100Mi
It was applied and then reapplied with v1 replaced by v2.