Skip to content
Closed
Changes from 1 commit
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
18 changes: 13 additions & 5 deletions crate/operator/handlers/handle_update_allowed_cidrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,19 @@ async def update_service_allowed_cidrs(
if not service:
return

await core.patch_namespaced_service(
name=f"crate-{name}",
namespace=namespace,
body={"spec": {"loadBalancerSourceRanges": change.new}},
)
# Only patch loadBalancerSourceRanges if the service is of type LoadBalancer.
# For ClusterIP this field is forbidden and will cause a 422.
if service.spec.type == "LoadBalancer":
await core.patch_namespaced_service(
name=f"crate-{name}",
namespace=namespace,
body={"spec": {"loadBalancerSourceRanges": change.new}},
)
else:
logger.info(
f"Skipping loadBalancerSourceRanges patch: service 'crate-{name}' "
f"is of type '{service.spec.type}', not 'LoadBalancer'."
)

ingress = await read_grand_central_ingress(namespace=namespace, name=name)

Expand Down
Loading