Skip to content
Draft
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
39 changes: 31 additions & 8 deletions api/azimuth/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,21 +824,44 @@ def validate(self, data):

class KubernetesClusterValidationMixin:
def validate(self, data):
# Stop ingress being turned on, only allow it to be turned off
# If ingress is being enabled, an IP must be specified and that IP must be free
if (
# Ingress is being enabled by the change
data.get("ingress_enabled", False)
and
# Ingress is not currently enabled
not getattr(self.instance, "ingress_enabled", False)
):
raise serializers.ValidationError(
{
"ingress_enabled": (
"Ingress is deprecated. It cannot be added to new clusters."
),
}
)
ip_address = data.get("ingress_controller_load_balancer_ip")
# No ingress controller IP is given
if not ip_address:
raise serializers.ValidationError(
{
"ingress_controller_load_balancer_ip": (
"Required when ingress is enabled."
),
}
)
# The given IP is not free
session = self.context["session"]
try:
ip = session.find_external_ip_by_ip_address(ip_address)
except errors.ObjectNotFoundError as exc:
raise serializers.ValidationError(
{
"ingress_controller_load_balancer_ip": str(exc),
}
)
else:
if not ip.available:
raise serializers.ValidationError(
{
"ingress_controller_load_balancer_ip": (
f"{ip_address} is already associated with "
"another platform or machine."
)
}
)

# OCCM does not respect changes to the ingress loadbalancer IP, so disallow it
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,6 @@ export const KubernetesClusterForm = ({
label="Enable Kubernetes Ingress?"
checked={getStateKey('ingress_enabled')}
onChange={setIngressEnabled}
// we only want to allow people to turn off ingress
// no new clusters should be allowed to add ingress
disabled={!getStateKey('ingress_enabled')}
/>
</Field>
<Field
Expand Down
Loading