Skip to content

Canary grouping must take labels into account #4170

@kflynn

Description

@kflynn

The following configuration attempts to use labels to associate the quote-backend-foo
Mapping only with foo.example.com, and quote-backend-bar only with bar.example.com:

---
apiVersion: getambassador.io/v3alpha1
kind: Host
metadata:
  name: foo-host
spec:
  hostname: foo.example.com
  mappingSelector:
    matchLabels:
      host: foo
  ...
---
apiVersion: getambassador.io/v3alpha1
kind: Host
metadata:
  name: bar-host
spec:
  hostname: bar.example.com
  mappingSelector:
    matchLabels:
      host: bar
  ...
---
apiVersion: getambassador.io/v3alpha1
kind: Mapping
metadata:
  name: quote-backend-foo
  labels:
    host: foo
spec:
  prefix: /test/
  service: quote
---
apiVersion: getambassador.io/v3alpha1
kind: Mapping
metadata:
  name: quote-backend-bar
  labels:
    host: bar
spec:
  prefix: /test/
  service: quote

Since the two Mappings have different host labels, they will associate with different Hosts
and should not be placed in the same canary group. However, as of Emissary 2.2.2, the canary-group
logic doesn't pay attention to labels, so the two Mappings will (wrongly) be placed in the same
canary group. Since Envoy-config generation operates on groups rather than on individual Mappings,
the effect here is that https://foo.example.com/test/ will be correctly routed, but
https://bar.example.com/test/ will 404.

As an additional constraint, consider the same Hosts above, but these two Mappings:

---
apiVersion: getambassador.io/v3alpha1
kind: Mapping
metadata:
  name: quote-labels-1
  labels:
    host: foo
    irrelevant-label: "1"
spec:
  prefix: /labels/
  service: quote-1
---
apiVersion: getambassador.io/v3alpha1
kind: Mapping
metadata:
  name: quote-labels-2
  labels:
    host: foo
    irrelevant-label: "2"
spec:
  prefix: /labels/
  service: quote-2

These Mappings should be placed in the same canary group, since the Hosts don't differentiate
based on the irrelevant-label label. So we mustn't look at every label -- only the ones that
the Hosts actually care about matter.

To work around this, you can either:

  1. Give the two Mappings a precedence with different values so that they can't be canaried together, or
  2. Use the hostname rather than labels.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions