Skip to content

Commit a1a69bb

Browse files
authored
Merge pull request #574 from element-hq/bbz/more-hostAliases
More hostAliases tweaking
2 parents 0ba0768 + d417f3a commit a1a69bb

File tree

9 files changed

+22
-40
lines changed

9 files changed

+22
-40
lines changed

charts/matrix-stack/source/matrix-rtc.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,6 @@
165165
"containersSecurityContext": {
166166
"$ref": "file://common/containersSecurityContext.json"
167167
},
168-
"hostAliases": {
169-
"$ref": "file://common/hostAliases.json"
170-
},
171168
"nodeSelector": {
172169
"$ref": "file://common/nodeSelector.json"
173170
},

charts/matrix-stack/source/matrix-rtc.yaml.j2

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ sfu:
6666
{{- sub_schema_values.labels() | indent(2) }}
6767
{{- sub_schema_values.workloadAnnotations() | indent(2) }}
6868
{{- sub_schema_values.containersSecurityContext() | indent(2) }}
69-
{{- sub_schema_values.hostAliases() | indent(2) }}
7069
{{- sub_schema_values.nodeSelector() | indent(2) }}
7170
{{- sub_schema_values.podSecurityContext(user_id='10030', group_id='10030') | indent(2) }}
7271
{{- sub_schema_values.resources(requests_memory='150Mi', requests_cpu='100m', limits_memory='4Gi') | indent(2) }}

charts/matrix-stack/templates/synapse/_synapse_pod.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ template:
4848
"deployment" false
4949
"usesMatrixTools" true)
5050
) | nindent 4 }}
51+
{{- if not $isHook }}
5152
{{- with .hostAliases }}
5253
hostAliases:
5354
{{- tpl (toYaml . | nindent 6) $root }}
5455
{{- end }}
56+
{{- end }}
5557
{{- /*
5658
We have an init container to render & merge the config for several reasons:
5759
* We have external, user-supplied Secrets and don't want to use `lookup` as that doesn't work with things like ArgoCD

charts/matrix-stack/values.schema.json

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,24 +1805,6 @@
18051805
"type": "object",
18061806
"additionalProperties": false
18071807
},
1808-
"hostAliases": {
1809-
"type": "array",
1810-
"items": {
1811-
"type": "object",
1812-
"properties": {
1813-
"ip": {
1814-
"type": "string"
1815-
},
1816-
"hostnames": {
1817-
"type": "array",
1818-
"items": {
1819-
"type": "string"
1820-
}
1821-
}
1822-
},
1823-
"additionalProperties": false
1824-
}
1825-
},
18261808
"nodeSelector": {
18271809
"type": "object",
18281810
"additionalProperties": {

charts/matrix-stack/values.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -742,18 +742,6 @@ matrixRTC:
742742
## localhostProfile must only be set set if type Localhost. It indicates the path of the pre-configured profile on the node, relative to the kubelet's configured Seccomp profile location (configured with the --root-dir flag).
743743
# seccompProfile:
744744
# type: RuntimeDefault
745-
## The list of hosts aliases to configure on the pod spec.
746-
## It should be avoid as much as possible to use this feature.
747-
## Please prefer using an DNS entry to resolve your hostnames.
748-
## This can be used as a workaround when entries cannot be resolved using DNS, for example for our automated testings.
749-
## e.g.
750-
## hostAliases:
751-
## - ip: 192.0.2.1 # An IP resolution to add to /etc/hosts
752-
## # A list of hostnames to be associated with the above IP
753-
## hostnames:
754-
## - ess.localhost
755-
## - synapse.ess.localhost
756-
hostAliases: []
757745
## NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
758746
# nodeSelector: {}
759747
## A subset of PodSecurityContext. PodSecurityContext holds pod-level security attributes and common container settings

newsfragments/574.changed.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Don't set `hostAliases` on the Synapse config job as it just operates on the config files.

newsfragments/574.changed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed `hostAliases` support from Matrix RTC SFU as it doesn't make outbound requests.

newsfragments/574.internal.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CI: test that `hostAliases` are correctly set for all workloads that make outbound requests.

tests/manifests/__init__.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ def deployable_details_for_container(self, container_name: str) -> "DeployableDe
204204

205205
@dataclass(unsafe_hash=True)
206206
class SidecarDetails(DeployableDetails):
207+
# We have to be a workload as we're a sidecar
208+
has_workloads: bool = True
209+
207210
parent: DeployableDetails = field(default=None, init=False, hash=False) # type: ignore[assignment]
208211

209212
def __post_init__(self):
@@ -223,12 +226,19 @@ def __post_init__(self):
223226
# Not possible, will come from the parent components
224227
self.has_topology_spread_constraints = False
225228

226-
# We have to be a workload as we're a sidecar
227-
self.has_workloads = True
228-
229229
# We dont support replicas
230230
self.has_replicas = False
231231

232+
def create_ownership_link(self, parent: "ComponentDetails | SubComponentDetails"):
233+
self.parent = parent
234+
235+
# If the sidecar makes outbound requests, the parent will need hostAlias support
236+
# even if it itself doesn't make outbound requests
237+
if self.makes_outbound_requests:
238+
self.parent.makes_outbound_requests = True
239+
# As we won't have the properties ourselves
240+
self.makes_outbound_requests = False
241+
232242
def owns_manifest_named(self, manifest_name: str) -> bool:
233243
# Sidecars shouldn't own anything that their parent could possibly own
234244
if self.parent.owns_manifest_named(manifest_name):
@@ -248,7 +258,7 @@ def __post_init__(self):
248258
super().__post_init__()
249259

250260
for sidecar in self.sidecars:
251-
sidecar.parent = self
261+
sidecar.create_ownership_link(self)
252262

253263
def owns_manifest_named(self, manifest_name: str) -> bool:
254264
return manifest_name.startswith(self.name)
@@ -285,7 +295,7 @@ def __post_init__(
285295
super().__post_init__()
286296

287297
for sidecar in self.sidecars:
288-
sidecar.parent = self
298+
sidecar.create_ownership_link(self)
289299

290300
if not self.value_file_prefix:
291301
self.value_file_prefix = self.name
@@ -461,6 +471,7 @@ def make_synapse_worker_sub_component(worker_name: str, worker_type: str) -> Sub
461471
has_topology_spread_constraints=False,
462472
has_ingress=False,
463473
has_replicas=False,
474+
makes_outbound_requests=False,
464475
),
465476
),
466477
shared_component_names=("init-secrets",),
@@ -546,7 +557,6 @@ def make_synapse_worker_sub_component(worker_name: str, worker_type: str) -> Sub
546557
values_file_path=ValuesFilePath.read_write("synapse", "checkConfigHook"),
547558
values_file_path_overrides={
548559
PropertyType.Env: ValuesFilePath.read_elsewhere("synapse", "extraEnv"),
549-
PropertyType.HostAliases: ValuesFilePath.read_elsewhere("synapse", "hostAliases"),
550560
PropertyType.Image: ValuesFilePath.read_elsewhere("synapse", "image"),
551561
# Job so no livenessProbe
552562
PropertyType.LivenessProbe: ValuesFilePath.not_supported(),
@@ -565,6 +575,7 @@ def make_synapse_worker_sub_component(worker_name: str, worker_type: str) -> Sub
565575
has_ingress=False,
566576
has_service_monitor=False,
567577
has_replicas=False,
578+
makes_outbound_requests=False,
568579
),
569580
),
570581
shared_component_names=("deployment-markers", "init-secrets", "haproxy", "postgres"),

0 commit comments

Comments
 (0)