Skip to content

Commit

Permalink
[OSPK8-431] Migrate osipset functionality to osnetcfg
Browse files Browse the repository at this point in the history
This migrates the IP reservation functionality from osipset to
osmacaddr controller. The osmacaddr controller watches osctlplane
osvmset, osclient and osbmset resources and creates IP reservations
if needed. The reservations get stored on the osnet spec, like before.
The ip set information is stored on the status of the osnetcfg CR.

If a node gets deleted, the default is to persist the reservations
of a node if the full role isn't deleted (like before). With this
change this can be controlled by the osnetcfg Spec.PreserveReservations
parameter, which controlls both IP and MAC address reservations.

In a follow up static IP reservation will be added.
  • Loading branch information
stuggi committed Jan 26, 2022
1 parent 806f5c1 commit c4ba7d1
Show file tree
Hide file tree
Showing 82 changed files with 1,975 additions and 3,539 deletions.
6 changes: 0 additions & 6 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ resources:
defaulting: true
validation: true
webhookVersion: v1
- controller: true
domain: openstack.org
group: osp-director
kind: OpenStackIPSet
path: github.com/openstack-k8s-operators/osp-director-operator/api/v1beta1
version: v1beta1
- api:
crdVersion: v1
namespaced: true
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ The OSP Director Operator creates a set of Custom Resource Definitions on top of
Hardware Provisioning CRDs
--------------------------
- openstacknetattachment: manages NodeNetworkConfigurationPolicy and NodeSriovConfigurationPolicy used to attach networks to virtual machines
- openstacknetconfig: high level CRD to specify openstacknetattachments and openstacknets to describe the full network configuration.
- openstacknetconfig: high level CRD to specify openstacknetattachments and openstacknets to describe the full network configuration. The set of reserved IP/MAC addresses per node are reflected in the status.
- openstackbaremetalset: create sets of baremetal hosts for a specific TripleO role (Compute, Storage, etc.)
- openstackcontrolplane: A CRD used to create the OpenStack control plane and manage associated openstackvmsets
- openstackipset: Contains a set of IPs for a given network and role. Used internally to manage IP addresses.
- openstacknet: Create networks which are used to assign IPs to the vmset and baremetalset resources below
- openstackprovisionservers: used to serve custom images for baremetal provisioning with Metal3
- openstackvmset: create sets of VMs using OpenShift Virtualization for a specific TripleO role (Controller, Database, NetworkController, etc.)
Expand Down
11 changes: 11 additions & 0 deletions api/v1beta1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ const (
CommonCondReasonRemoveFinalizerError ConditionReason = "RemoveFinalizerError"
// CommonCondReasonAddRefLabelError - error adding reference label
CommonCondReasonAddRefLabelError ConditionReason = "AddRefLabelError"
// CommonCondReasonAddOSNetLabelError - error adding osnet labels
CommonCondReasonAddOSNetLabelError ConditionReason = "AddOSNetLabelError"
// CommonCondReasonCIDRParseError - could not parse CIDR
CommonCondReasonCIDRParseError ConditionReason = "CIDRParseError"
// CommonCondReasonServiceNotFound - service not found
CommonCondReasonServiceNotFound ConditionReason = "ServiceNotFound"
)

// Hash - struct to add hashes to status
Expand All @@ -127,6 +133,11 @@ type Hash struct {
// ProvisioningState - the overall state of all VMs in this OpenStackVmSet
type ProvisioningState string

const (
// HostRefInitState - intial HostRef state of a new node which has not yet assigned
HostRefInitState string = "unassigned"
)

// HostStatus represents the hostname and IP info for a specific host
type HostStatus struct {
Hostname string `json:"hostname"`
Expand Down
2 changes: 0 additions & 2 deletions api/v1beta1/openstackbackup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ type CrsForBackup struct {
OpenStackClients OpenStackClientList `json:"openStackClients,omitempty" optional:"true"`
// OpenStackControlPlanes - list of OpenStackControlPlanes saved in the backup
OpenStackControlPlanes OpenStackControlPlaneList `json:"openStackControlPlanes,omitempty" optional:"true"`
// OpenStackIPSets - list of OpenStackIPSets saved in the backup
OpenStackIPSets OpenStackIPSetList `json:"openStackIPSets,omitempty" optional:"true"`
// OpenStackMACAddresses - list of OpenStackMACAddresses saved in the backup
OpenStackMACAddresses OpenStackMACAddressList `json:"openStackMACAddresses,omitempty" optional:"true"`
// OpenStackNets - list of OpenStackNets saved in the backup
Expand Down
139 changes: 0 additions & 139 deletions api/v1beta1/openstackipset_types.go

This file was deleted.

8 changes: 2 additions & 6 deletions api/v1beta1/openstackmacaddress_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,8 @@ const (
MACCondReasonAllMACAddressesCreated ConditionReason = "MACAddressesCreated"
// MACCondReasonError - General error getting the OSMACaddr object
MACCondReasonError ConditionReason = "MACError"
/*
// MACCondReasonStaticMACNotUniqError - Mac from provided static list is not uniq
MACCondReasonStaticMACNotUniqError ConditionReason = "StaticMACNotUniqError"
// MACCondReasonStaticMACNotValidError - Mac from provided static list is a valid MAC address
MACCondReasonStaticMACNotValidError ConditionReason = "StaticMACNotValidError"
*/
// MACCondReasonMACNotFound - osmacaddr object not found
MACCondReasonMACNotFound ConditionReason = "OpenStackMACNotFound"
)

// OpenStackMACAddressStatus defines the observed state of OpenStackMACAddress
Expand Down
21 changes: 18 additions & 3 deletions api/v1beta1/openstacknet_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ type IPReservation struct {
Deleted bool `json:"deleted"`
}

// NodeIPReservation contains an IP and Deleted flag
type NodeIPReservation struct {
IP string `json:"ip"`
Deleted bool `json:"deleted"`
}

// Route definition
type Route struct {
// +kubebuilder:validation:Required
Expand Down Expand Up @@ -94,7 +100,7 @@ type OpenStackNetSpec struct {

// +kubebuilder:validation:Optional
// Reservations, IP address reservations per role
RoleReservations map[string]OpenStackNetRoleStatus `json:"roleReservations"`
RoleReservations map[string]OpenStackNetRoleReservation `json:"roleReservations"`
}

// OpenStackNetRoleStatus defines the observed state of the Role Net status
Expand All @@ -104,10 +110,17 @@ type OpenStackNetRoleStatus struct {
AddToPredictableIPs bool `json:"addToPredictableIPs"`
}

// OpenStackNetRoleReservation defines the observed state of the Role Net reservation
type OpenStackNetRoleReservation struct {
// Reservations IP address reservations
Reservations []IPReservation `json:"reservations"`
AddToPredictableIPs bool `json:"addToPredictableIPs"`
}

// OpenStackNetStatus defines the observed state of OpenStackNet
type OpenStackNetStatus struct {
// Reservations IP address reservations per role
RoleReservations map[string]OpenStackNetRoleStatus `json:"roleReservations"`
// Reservations MAC address reservations per node
Reservations map[string]NodeIPReservation `json:"reservations"`

// ReservedIPCount - the count of all IPs ever reserved on this network
ReservedIPCount int `json:"reservedIpCount"`
Expand Down Expand Up @@ -145,6 +158,8 @@ const (
NetCondReasonCreated ConditionReason = "OpenStackNetCreated"
// NetCondReasonCreateError - error creating osnet object
NetCondReasonCreateError ConditionReason = "OpenStackNetCreateError"
// NetCondReasonNetNotFound - error osnet not found
NetCondReasonNetNotFound ConditionReason = "OpenStackNetNotFound"
)

// IsReady - Is this resource in its fully-configured (quiesced) state?
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/openstacknet_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (r *OpenStackNet) Default() {
// The OpenStackNet "XYZ" is invalid: spec.roleReservations: Invalid value: "null": spec.roleReservations in body must be of type object: "null"
//
if r.Spec.RoleReservations == nil {
r.Spec.RoleReservations = map[string]OpenStackNetRoleStatus{}
r.Spec.RoleReservations = map[string]OpenStackNetRoleReservation{}
}

//
Expand Down
39 changes: 31 additions & 8 deletions api/v1beta1/openstacknetconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ type Network struct {
// +kubebuilder:default=true
// VIP create virtual ip on the network
VIP bool `json:"vip"`

/*
// +kubebuilder:validation:Optional
// StaticReservations, manual/static IP address reservations per node
StaticReservations map[string]OpenStackMACNodeReservation `json:"staticReservations"`
*/
}

// OpenStackNetConfigSpec defines the desired state of OpenStackNetConfig
Expand Down Expand Up @@ -138,6 +144,13 @@ type OpenStackNetConfigSpec struct {
// - If the macPrefix is not specified for a physnet, the default macPrefix "fa:16:3a" is used.
// - If PreserveReservations is not specified, the default is true.
OVNBridgeMacMappings OVNBridgeMacMappingConfig `json:"ovnBridgeMacMappings"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=true
// PreserveReservations - preserve the MAC/IP reservation of the host within a node role when the node got deleted
// but the role itself is not deleted. The reservations of all nodes in the role get deleted when the full node
// role is being deleted. (default: true)
PreserveReservations *bool `json:"preserveReservations"`
}

// OVNBridgeMacMappingConfig defines the desired state of OpenStackMACAddress
Expand All @@ -147,14 +160,7 @@ type OVNBridgeMacMappingConfig struct {
PhysNetworks []Physnet `json:"physNetworks"`

// +kubebuilder:validation:Optional
// +kubebuilder:default=true
// PreserveReservations - preserve the MAC reservation of the host within a node role when the node got deleted
// but the role itself is not deleted. The reservations of all nodes in the role get deleted when the full node
// role is being deleted. (default: true)
PreserveReservations *bool `json:"preserveReservations"`

// +kubebuilder:validation:Optional
// StaticReservations, manual/static MAC address reservations per role
// StaticReservations, manual/static MAC address reservations per node
StaticReservations map[string]OpenStackMACNodeReservation `json:"staticReservations"`
}

Expand All @@ -163,6 +169,14 @@ type OpenStackNetConfigStatus struct {
// Conditions - conditions to display in the OpenShift GUI, which reflect CurrentState
Conditions ConditionList `json:"conditions,omitempty" optional:"true"`
ProvisioningStatus OpenStackNetConfigProvisioningStatus `json:"provisioningStatus,omitempty"`

Hosts map[string]OpenStackHostStatus `json:"hosts"`
}

// OpenStackHostStatus per host IP set
type OpenStackHostStatus struct {
IPAddresses map[string]string `json:"ipaddresses"`
OVNBridgeMacAdresses map[string]string `json:"ovnBridgeMacAdresses"`
}

// OpenStackNetConfigProvisioningStatus represents the overall provisioning state of
Expand All @@ -189,6 +203,15 @@ const (
NetConfigConfigured ProvisioningState = "Configured"
// NetConfigError - the network configuration hit a generic error
NetConfigError ProvisioningState = "Error"

// NetConfigCondReasonWaitingOnIPsForHost - waiting on IPs for all configured networks to be created
NetConfigCondReasonWaitingOnIPsForHost ConditionReason = "WaitingOnIPsForHost"
// NetConfigCondReasonWaitingOnHost - waiting on host to be added to osnetcfg
NetConfigCondReasonWaitingOnHost ConditionReason = "WaitingOnHost"
// NetConfigCondReasonIPReservationError - Failed to do ip reservation
NetConfigCondReasonIPReservationError ConditionReason = "IPReservationError"
// NetConfigCondReasonIPReservation - ip reservation created
NetConfigCondReasonIPReservation ConditionReason = "IPReservationCreated"
)

// IsReady - Is this resource in its fully-configured (quiesced) state?
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/openstacknetconfig_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ func (r *OpenStackNetConfig) Default() {
r.Spec.OVNBridgeMacMappings.StaticReservations = map[string]OpenStackMACNodeReservation{}
}

if r.Spec.OVNBridgeMacMappings.PreserveReservations == nil {
if r.Spec.PreserveReservations == nil {
var trueVal bool = true
r.Spec.OVNBridgeMacMappings.PreserveReservations = &trueVal
r.Spec.PreserveReservations = &trueVal
}

//
Expand Down
5 changes: 0 additions & 5 deletions api/v1beta1/openstackvmset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,6 @@ const (
// VMSetCondReasonVirtualMachineCountZero - no virtual machines requested
VMSetCondReasonVirtualMachineCountZero ConditionReason = "VirtualMachineCountZero"

// VMSetCondReasonIPsetCreateOrUpdateError - create or update ipset error
VMSetCondReasonIPsetCreateOrUpdateError ConditionReason = "CreateOrUpdateIPsetError"
// VMSetCondReasonIPsetWaitCount - IPSet has not yet reached the required count
VMSetCondReasonIPsetWaitCount ConditionReason = "CreateOrUpdateIPsetError"

// VMSetCondReasonPersitentVolumeClaimNotFound - Persitent Volume Claim Not Found
VMSetCondReasonPersitentVolumeClaimNotFound ConditionReason = "PersitentVolumeClaimNotFound"
// VMSetCondReasonPersitentVolumeClaimError - Persitent Volume Claim error
Expand Down
Loading

0 comments on commit c4ba7d1

Please sign in to comment.