Skip to content

feat: RBAC pre-flight check, containerlab fixes, controller refactor#131

Merged
privateip merged 2 commits into
mainfrom
feat/galactic-router-updates
Jun 25, 2026
Merged

feat: RBAC pre-flight check, containerlab fixes, controller refactor#131
privateip merged 2 commits into
mainfrom
feat/galactic-router-updates

Conversation

@privateip

@privateip privateip commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

This is a set of patches to fix the containerlab deployment to work with the latest CRDs published by Cosmos. It also adds a new function to log RBAC failures before attempting to start galactic-router. Prior to this patch, galatic-router would look like it starts fine but never established peer connections.

Changes

  • RBAC pre-flight checkcheckWatchPermissions() issues a test list for every resource the manager watches at startup. If any return Forbidden, logs a clear actionable message so cache sync failures are immediately visible rather than silent.
  • Containerlab IPv6 fixes — Skip TLS verify in kubectl wrapper for IPv6-only kind clusters; add lo-galactic dummy interface with IPv6 address for transit mesh routing.
  • RBAC migration — Rename from galactic-agentgalactic-router; update apiGroups from providers.bgp.miloapis.combgp.miloapis.com; add permissions for all new CRDs (BGPRouter, BGPPeer, BGPAdvertisement, BGPPolicy, BGPVRFInstance) plus Node and Secret.
  • Containerlab routing — Add BGP_LOCAL_ADDRESS env for iad-rr tenant; add FRR route-map SET_SRC to set src address for EVPN routes.
  • Remove ASN patchfix-asn-maximum.sh no longer needed after cosmos API update.
  • Cosmos API updatePrefix type changed from AdvertisedPrefix.CIDR to direct Prefix string; added int32→uint32 conversion for LOCAL_PREF (cosmos uses int32, GoBGP uses uint32 per RFC 4271).
  • Controller refactor — Moved BGPAdvertisement Watches handler into BGPRouter.SetupWithManager; removed redundant empty reconciler.
  • Fix field index names — Corrected BGPPeerByRouterNameBGPAdvByRouterName and BGPPeerByRouterNameBGPPolicyByRouterName in status update list calls.

- Add RBAC pre-flight check at startup to surface missing list+watch
  permissions before manager starts (cmd/galactic-router/main.go)
- Fix containerlab IPv6 kubectl TLS skip and lo-galactic interface
  setup for IPv6-only clusters
- Update RBAC from legacy galactic-agent/BGPInstance to galactic-router
  with full CRD permissions (BGPRouter, BGPPeer, BGPAdvertisement,
  BGPPolicy, BGPVRFInstance, Node, Secret)
- Remove ASN maximum patch from install-overlay (no longer needed)
- Add BGP_LOCAL_ADDRESS env for iad-rr tenant router
- Add route-map SET_SRC in FRR underlay to set src address for EVPN
- Update cosmos API: Prefix type changed from AdvertisedPrefix.CIDR to
  direct Prefix string; add int32→uint32 conversion for LOCAL_PREF
- Refactor BGPAdvertisement controller: move Watches into
  BGPRouter SetupWithManager, remove redundant reconciler
- Fix field index name typos in status update list calls

Co-Authored-By: Claude <noreply@anthropic.com>
@privateip privateip requested a review from a team as a code owner June 25, 2026 12:32
Comment thread cmd/galactic-router/main.go Outdated
Comment on lines +218 to +223
if err := c.List(ctx, objList, client.Limit(1)); err != nil {
if apierrors.IsForbidden(err) {
logger.Error(err, "missing list+watch RBAC",
"detail", "informer cache will not sync; add resource to ServiceAccount ClusterRole and restart")
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend doing a SelfSubjectAccessReview check here. It's a simple permission check instead having to list resources. You can also check for the Watch permission when this is only checking the list permission.

scotwells
scotwells previously approved these changes Jun 25, 2026
@scotwells

Copy link
Copy Markdown
Contributor

Assume we should have also have alerts that catch these situations? E.g. the controller is erroring when making API requests

- Replace List() calls with SelfSubjectAccessReview to check watch permission
  without reading cluster data
- Check the watch verb explicitly instead of relying on list API behavior
- Remove unused corev1 and apierrors imports
- Use plain resource name structs instead of CRD List types
@privateip

privateip commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

Assume we should have also have alerts that catch these situations?

yes, i have held off putting alerts into galactic until the code settled down. Im very close to starting that work now across the board

@privateip privateip requested a review from scotwells June 25, 2026 13:27
@privateip privateip merged commit 12d07ae into main Jun 25, 2026
5 checks passed
@privateip privateip deleted the feat/galactic-router-updates branch June 25, 2026 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants