Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions api/v1/qdrantcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,17 @@ type Ingress struct {
// Traefik specifies the traefik ingress specific configurations.
// +optional
Traefik *TraefikConfig `json:"traefik,omitempty"`
// EnableAccessLog overrides the region-wide Envoy proxy access log setting
// for this cluster: true forces it on, false forces it off, and unset
// follows the region.
//
// The override matters in both directions. A single tenant can carry most
// of a region's traffic, so "off" has to be expressible for one cluster
// without giving up the log for every other cluster in that region; and
// "on" has to be expressible for a cluster under investigation without
// enabling the whole region.
// +optional
EnableAccessLog *bool `json:"enableAccessLog,omitempty"`
}

func (i *Ingress) GetAnnotations() map[string]string {
Expand All @@ -785,6 +796,16 @@ func (i *Ingress) GetTls(def bool) bool {
return *i.TLS
}

// GetEnableAccessLog returns whether the Envoy access log is enabled for this
// cluster, falling back to def (the region-wide setting) when the cluster does
// not override it.
func (i *Ingress) GetEnableAccessLog(def bool) bool {
if i == nil || i.EnableAccessLog == nil {
return def
}
return *i.EnableAccessLog
}

func (i *Ingress) GetNGINX() *NGINXConfig {
if i == nil {
return nil
Expand Down
31 changes: 31 additions & 0 deletions api/v1/qdrantcluster_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,34 @@ func TestValidate(t *testing.T) {
})
}
}

// TestIngressGetEnableAccessLog pins the three-state override. The false case is
// the one that matters operationally: a single tenant can carry most of a
// region's traffic, so it has to be possible to silence one cluster without
// giving up the log for every other cluster in the region.
func TestIngressGetEnableAccessLog(t *testing.T) {
testCases := []struct {
name string
ingress *Ingress
region bool
want bool
}{
{"nil ingress follows the region", nil, true, true},
{"unset follows the region (on)", &Ingress{}, true, true},
{"unset follows the region (off)", &Ingress{}, false, false},
{"true forces on against a disabled region", &Ingress{EnableAccessLog: ptr.To(true)}, false, true},
{"false forces off against an enabled region", &Ingress{EnableAccessLog: ptr.To(false)}, true, false},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, tc.want, tc.ingress.GetEnableAccessLog(tc.region))
})
}
}

func TestIngressJSONOmitsUnsetEnableAccessLog(t *testing.T) {
data, err := json.Marshal(Ingress{})

assert.NoError(t, err)
assert.NotContains(t, string(data), "enableAccessLog")
}
5 changes: 5 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,18 @@ spec:
type: string
description: Annotations specifies annotations for the ingress.
type: object
enableAccessLog:
description: |-
EnableAccessLog overrides the region-wide Envoy proxy access log setting
for this cluster: true forces it on, false forces it off, and unset
follows the region.

The override matters in both directions. A single tenant can carry most
of a region's traffic, so "off" has to be expressible for one cluster
without giving up the log for every other cluster in that region; and
"on" has to be expressible for a cluster under investigation without
enabling the whole region.
type: boolean
enabled:
description: Enabled specifies whether to enable ingress for the
cluster or not.
Expand Down
12 changes: 12 additions & 0 deletions crds/qdrant.io_qdrantclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,18 @@ spec:
type: string
description: Annotations specifies annotations for the ingress.
type: object
enableAccessLog:
description: |-
EnableAccessLog overrides the region-wide Envoy proxy access log setting
for this cluster: true forces it on, false forces it off, and unset
follows the region.

The override matters in both directions. A single tenant can carry most
of a region's traffic, so "off" has to be expressible for one cluster
without giving up the log for every other cluster in that region; and
"on" has to be expressible for a cluster under investigation without
enabling the whole region.
type: boolean
enabled:
description: Enabled specifies whether to enable ingress for the
cluster or not.
Expand Down
1 change: 1 addition & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ _Appears in:_
| `tlsSecretName` _string_ | TLSSecretName specifies the name of the secret containing the tls certificate. | | Optional: \{\} <br /> |
| `nginx` _[NGINXConfig](#nginxconfig)_ | NGINX specifies the nginx ingress specific configurations. | | Optional: \{\} <br /> |
| `traefik` _[TraefikConfig](#traefikconfig)_ | Traefik specifies the traefik ingress specific configurations. | | Optional: \{\} <br /> |
| `enableAccessLog` _boolean_ | EnableAccessLog overrides the region-wide Envoy proxy access log setting<br />for this cluster: true forces it on, false forces it off, and unset<br />follows the region.<br />The override matters in both directions. A single tenant can carry most<br />of a region's traffic, so "off" has to be expressible for one cluster<br />without giving up the log for every other cluster in that region; and<br />"on" has to be expressible for a cluster under investigation without<br />enabling the whole region. | | Optional: \{\} <br /> |


#### KubernetesDistribution
Expand Down
Loading