Skip to content

Commit 916a1b9

Browse files
committed
delete/recreate
1 parent 32ddcd8 commit 916a1b9

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

containers/tailscale-operator-manager/operator.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,34 @@ def _ensure_proxy_group(custom_api, crd_name, labels, default_tags, logger):
225225
"spec": spec,
226226
}
227227
try:
228-
custom_api.get_cluster_custom_object(
228+
existing = custom_api.get_cluster_custom_object(
229229
PROXY_GROUP_API["group"],
230230
PROXY_GROUP_API["version"],
231231
PROXY_GROUP_API["plural"],
232232
pg_name,
233233
)
234-
logger.info(f"ProxyGroup {pg_name} already exists")
234+
# spec.tailnet is immutable — if missing or wrong, delete and recreate
235+
existing_tailnet = existing.get("spec", {}).get("tailnet", "")
236+
if existing_tailnet != crd_name:
237+
logger.info(
238+
f"ProxyGroup {pg_name} has tailnet={existing_tailnet!r}, "
239+
f"expected {crd_name!r} — recreating"
240+
)
241+
custom_api.delete_cluster_custom_object(
242+
PROXY_GROUP_API["group"],
243+
PROXY_GROUP_API["version"],
244+
PROXY_GROUP_API["plural"],
245+
pg_name,
246+
)
247+
custom_api.create_cluster_custom_object(
248+
PROXY_GROUP_API["group"],
249+
PROXY_GROUP_API["version"],
250+
PROXY_GROUP_API["plural"],
251+
body,
252+
)
253+
logger.info(f"Recreated ProxyGroup {pg_name} with tailnet={crd_name}")
254+
else:
255+
logger.info(f"ProxyGroup {pg_name} already exists")
235256
except ApiException as exc:
236257
if exc.status == 404:
237258
custom_api.create_cluster_custom_object(

0 commit comments

Comments
 (0)