From c36ab21bcb3ea04b034ca20f1b885efa4dadef4a Mon Sep 17 00:00:00 2001 From: Simon Murray Date: Fri, 6 Dec 2024 09:18:52 +0000 Subject: [PATCH] Make Provisioning Work Fully We need a network for every cluster, not just those that may require one. --- ...ute.unikorn-cloud.org_computeclusters.yaml | 4 +- pkg/server/handler/cluster/client.go | 44 ++----------------- 2 files changed, 6 insertions(+), 42 deletions(-) diff --git a/charts/compute/crds/compute.unikorn-cloud.org_computeclusters.yaml b/charts/compute/crds/compute.unikorn-cloud.org_computeclusters.yaml index 41de885..d03519e 100644 --- a/charts/compute/crds/compute.unikorn-cloud.org_computeclusters.yaml +++ b/charts/compute/crds/compute.unikorn-cloud.org_computeclusters.yaml @@ -328,10 +328,10 @@ spec: hostname: description: Hostname of the machine. type: string - privateIP: + privateIp: description: PrivateIP is the private IP address. type: string - publicIP: + publicIp: description: PublicIP is the public IP address if requested. type: string required: diff --git a/pkg/server/handler/cluster/client.go b/pkg/server/handler/cluster/client.go index e2b5830..8128957 100644 --- a/pkg/server/handler/cluster/client.go +++ b/pkg/server/handler/cluster/client.go @@ -193,30 +193,6 @@ func (c *Client) createNetworkOpenstack(ctx context.Context, organizationID, pro return resp.JSON201, nil } -func (c *Client) getRegion(ctx context.Context, organizationID, regionID string) (*regionapi.RegionRead, error) { - // TODO: Need a straight get interface rather than a list. - resp, err := c.region.GetApiV1OrganizationsOrganizationIDRegionsWithResponse(ctx, organizationID) - if err != nil { - return nil, errors.OAuth2ServerError("unable to get region").WithError(err) - } - - if resp.StatusCode() != http.StatusOK { - return nil, errors.OAuth2ServerError("unable to get region") - } - - results := *resp.JSON200 - - index := slices.IndexFunc(results, func(region regionapi.RegionRead) bool { - return region.Metadata.Id == regionID - }) - - if index < 0 { - return nil, errors.OAuth2ServerError("unable to get region") - } - - return &results[index], nil -} - func (c *Client) applyCloudSpecificConfiguration(ctx context.Context, organizationID, projectID, regionID string, identity *regionapi.IdentityRead, cluster *unikornv1.ComputeCluster) error { // Save the identity ID for later cleanup. if cluster.Annotations == nil { @@ -225,25 +201,13 @@ func (c *Client) applyCloudSpecificConfiguration(ctx context.Context, organizati cluster.Annotations[constants.IdentityAnnotation] = identity.Metadata.Id - // Apply any region specific configuration based on feature flags. - region, err := c.getRegion(ctx, organizationID, regionID) + // Provision a network for nodes to attach to. + network, err := c.createNetworkOpenstack(ctx, organizationID, projectID, cluster, identity) if err != nil { - return err + return errors.OAuth2ServerError("failed to create physical network").WithError(err) } - // Provision a vlan physical network for bare-metal nodes to attach to. - // For now, do this for everything, given you may start with a VM only cluster - // and suddely want some compute nodes. CAPO won't allow you to change - // networks, so play it safe. Please note that the cluster controller will - // automatically discover the physical network, so we don't need an annotation. - if region.Spec.Features.PhysicalNetworks { - network, err := c.createNetworkOpenstack(ctx, organizationID, projectID, cluster, identity) - if err != nil { - return errors.OAuth2ServerError("failed to create physical network").WithError(err) - } - - cluster.Annotations[constants.PhysicalNetworkAnnotation] = network.Metadata.Id - } + cluster.Annotations[constants.PhysicalNetworkAnnotation] = network.Metadata.Id return nil }