Skip to content

Conversation

@agonzalezrh
Copy link
Contributor

@agonzalezrh agonzalezrh commented Jun 16, 2025

Ordering a OcpSandbox, sandbox will do:

  • Check if the ocpv has associated netbox_api_url and netbox_token
  • Check if there is prefixes (subnets)
  • Get an availabile IP
  • Create a EgressIP object on OCP, filtering to namespace with label guid: theguidrequested

If connection or if there is any error getting the Egressip, is ignored and throwing error to the log.

Idea EgressIP is not, at this point, blocking the provisioning.

@agonzalezrh agonzalezrh changed the title WIP Adding netbox support for EgressIP for OcpSandbox Jun 17, 2025
@agonzalezrh agonzalezrh requested a review from fridim June 17, 2025 20:28
@agonzalezrh agonzalezrh marked this pull request as ready for review June 17, 2025 20:43
"egressIPs": []string{strings.Split(egressIPAvailable, "/")[0]},
"namespaceSelector": map[string]any{
"matchLabels": map[string]any{
"guid": guid, // The label selector for the Keycloak realm
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use service_uuid instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we add some logic in the Candidate loop to check:

  • if the annotation egressip is there
  • make sure the cluster has an availableIP
  • otherwise => move to the next one

?

egressIPAvailable, err = netbox.RequestIP(selectedCluster.NetboxApiUrl, selectedCluster.NetboxToken, rnew.ServiceUuid)
log.Logger.Info("selectedCluster", "egressip", egressIPAvailable)
if err != nil {
log.Logger.Error("Error creating EgressIP", "error", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

So this is non-fatal?

if ok && egressIP != "" {
err = netbox.ReleaseIP(cluster.NetboxApiUrl, cluster.NetboxToken, egressIP+"/"+deletens.Labels["egressNetmask"])
if err != nil {
log.Logger.Error("Error deleting egressIP on netbox", egressIP, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

we should make this fatal, no?
Releasing the IP should work, otherwise consider the delete as fail, and don't proceed. Retry later

Otherwise it's going to leak IPs?

Problem is if something goes wrong here with the netboxapi, then namespaces aren't deleted

Not sure how we can address that?

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