Skip to content

Commit

Permalink
Merge pull request #220 from rabi/cherry-pick
Browse files Browse the repository at this point in the history
Remove PreprovisioningNetworkData
  • Loading branch information
openshift-merge-bot[bot] authored Oct 7, 2024
2 parents 71990de + 78df55e commit d27051c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 134 deletions.
36 changes: 0 additions & 36 deletions api/bases/baremetal.openstack.org_openstackbaremetalsets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ spec:
type: string
type: object
x-kubernetes-map-type: atomic
preprovisioningNetworkDataName:
description: PreprovisioningNetworkDataName - NetwoData Secret
name for Preprovisining in the local namespace
type: string
userData:
description: UserData - Host User Data
properties:
Expand Down Expand Up @@ -243,22 +239,6 @@ spec:
type: object
type: object
type: object
networkData:
description: NetworkData holds the reference to the Secret containing
network data to be passed to the hosts. NetworkData can be set per
host in BaremetalHosts or here. If none of these are provided it
will use default NetworkData to configure CtlPlaneIP.
properties:
name:
description: name is unique within a namespace to reference a
secret resource.
type: string
namespace:
description: namespace defines the space within which the secret
name must be unique.
type: string
type: object
x-kubernetes-map-type: atomic
osContainerImageUrl:
description: OSContainerImageURL - Container image URL for init with
the OS qcow2 image (osImage)
Expand Down Expand Up @@ -290,22 +270,6 @@ spec:
with ProvisionServerName, it would be discovered from CBO. This
is the provisioning interface on the OCP masters/workers.
type: string
userData:
description: UserData holds the reference to the Secret containing
the user data to be passed to the host before it boots. UserData
can be set per host in BaremetalHosts or here. If none of these
are provided it will use a default cloud-config.
properties:
name:
description: name is unique within a namespace to reference a
secret resource.
type: string
namespace:
description: namespace defines the space within which the secret
name must be unique.
type: string
type: object
x-kubernetes-map-type: atomic
required:
- cloudUserName
- ctlplaneInterface
Expand Down
14 changes: 0 additions & 14 deletions api/v1beta1/openstackbaremetalset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ type InstanceSpec struct {
// NetworkData - Host Network Data
NetworkData *corev1.SecretReference `json:"networkData,omitempty"`
// +kubebuilder:validation:Optional
// PreprovisioningNetworkDataName - NetwoData Secret name for Preprovisining in the local namespace
PreprovisioningNetworkDataName string `json:"preprovisioningNetworkDataName,omitempty"`
}

// Allowed automated cleaning modes
Expand All @@ -65,18 +63,6 @@ type OpenStackBaremetalSetSpec struct {
// +kubebuilder:validation:Optional
// AgentImageURL - Container image URL for the sidecar container that discovers provisioning network IPs
AgentImageURL string `json:"agentImageUrl,omitempty"`
// +kubebuilder:validation:Optional
// UserData holds the reference to the Secret containing the user
// data to be passed to the host before it boots. UserData can be
// set per host in BaremetalHosts or here. If none of these are
// provided it will use a default cloud-config.
UserData *corev1.SecretReference `json:"userData,omitempty"`
// +kubebuilder:validation:Optional
// NetworkData holds the reference to the Secret containing network
// data to be passed to the hosts. NetworkData can be set per host in
// BaremetalHosts or here. If none of these are provided it will use
// default NetworkData to configure CtlPlaneIP.
NetworkData *corev1.SecretReference `json:"networkData,omitempty"`
// When set to disabled, automated cleaning will be avoided
// during provisioning and deprovisioning.
// +kubebuilder:default=metadata
Expand Down
10 changes: 0 additions & 10 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ spec:
type: string
type: object
x-kubernetes-map-type: atomic
preprovisioningNetworkDataName:
description: PreprovisioningNetworkDataName - NetwoData Secret
name for Preprovisining in the local namespace
type: string
userData:
description: UserData - Host User Data
properties:
Expand Down Expand Up @@ -243,22 +239,6 @@ spec:
type: object
type: object
type: object
networkData:
description: NetworkData holds the reference to the Secret containing
network data to be passed to the hosts. NetworkData can be set per
host in BaremetalHosts or here. If none of these are provided it
will use default NetworkData to configure CtlPlaneIP.
properties:
name:
description: name is unique within a namespace to reference a
secret resource.
type: string
namespace:
description: namespace defines the space within which the secret
name must be unique.
type: string
type: object
x-kubernetes-map-type: atomic
osContainerImageUrl:
description: OSContainerImageURL - Container image URL for init with
the OS qcow2 image (osImage)
Expand Down Expand Up @@ -290,22 +270,6 @@ spec:
with ProvisionServerName, it would be discovered from CBO. This
is the provisioning interface on the OCP masters/workers.
type: string
userData:
description: UserData holds the reference to the Secret containing
the user data to be passed to the host before it boots. UserData
can be set per host in BaremetalHosts or here. If none of these
are provided it will use a default cloud-config.
properties:
name:
description: name is unique within a namespace to reference a
secret resource.
type: string
namespace:
description: namespace defines the space within which the secret
name must be unique.
type: string
type: object
x-kubernetes-map-type: atomic
required:
- cloudUserName
- ctlplaneInterface
Expand Down
43 changes: 11 additions & 32 deletions pkg/openstackbaremetalset/baremetalhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,10 @@ func BaremetalHostProvision(
}
bmhStatus.IPAddresses["ctlplane"] = ctlPlaneIP
}

// Instance UserData/NetworkData overrides the default
// Instance UserData/NetworkData
userDataSecret := instance.Spec.BaremetalHosts[hostName].UserData
networkDataSecret := instance.Spec.BaremetalHosts[hostName].NetworkData

if userDataSecret == nil {
userDataSecret = instance.Spec.UserData
}

if networkDataSecret == nil {
networkDataSecret = instance.Spec.NetworkData
}

sts := []util.Template{}
// User data cloud-init secret
if userDataSecret == nil {
Expand Down Expand Up @@ -105,21 +96,7 @@ func BaremetalHostProvision(

}

//
// Provision the BaremetalHost
//
foundBaremetalHost := &metal3v1.BareMetalHost{}
err := helper.GetClient().Get(ctx, types.NamespacedName{Name: bmh, Namespace: instance.Spec.BmhNamespace}, foundBaremetalHost)
if err != nil {
return err
}

preProvNetworkData := foundBaremetalHost.Spec.PreprovisioningNetworkDataName
if preProvNetworkData == "" {
preProvNetworkData = instance.Spec.BaremetalHosts[hostName].PreprovisioningNetworkDataName
}

if networkDataSecret == nil && preProvNetworkData == "" {
if networkDataSecret == nil {

// Check IP version and set template variables accordingly
ipAddr, ipNet, err := net.ParseCIDR(ctlPlaneIP)
Expand Down Expand Up @@ -195,6 +172,14 @@ func BaremetalHostProvision(
}
}

//
// Provision the BaremetalHost
//
foundBaremetalHost := &metal3v1.BareMetalHost{}
err := helper.GetClient().Get(ctx, types.NamespacedName{Name: bmh, Namespace: instance.Spec.BmhNamespace}, foundBaremetalHost)
if err != nil {
return err
}
op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), foundBaremetalHost, func() error {
// Set our ownership labels so we can watch this resource and also indicate that this BMH
// belongs to the particular OSBMS.Spec.BaremetalHosts entry we have passed to this function.
Expand All @@ -210,8 +195,6 @@ func BaremetalHostProvision(
// Ensure AutomatedCleaningMode is set as per spec
foundBaremetalHost.Spec.AutomatedCleaningMode = metal3v1.AutomatedCleaningMode(instance.Spec.AutomatedCleaningMode)

foundBaremetalHost.Spec.PreprovisioningNetworkDataName = preProvNetworkData

//
// Ensure the image url is up to date unless already provisioned
//
Expand Down Expand Up @@ -253,11 +236,7 @@ func BaremetalHostProvision(
// Update status with BMH provisioning details
//
bmhStatus.UserDataSecretName = userDataSecret.Name
if networkDataSecret != nil {
bmhStatus.NetworkDataSecretName = networkDataSecret.Name
} else {
bmhStatus.NetworkDataSecretName = preProvNetworkData
}
bmhStatus.NetworkDataSecretName = networkDataSecret.Name
bmhStatus.ProvisioningState = baremetalv1.ProvisioningState(foundBaremetalHost.Status.Provisioning.State)
instance.Status.BaremetalHosts[hostName] = bmhStatus

Expand Down
9 changes: 3 additions & 6 deletions tests/functional/openstackbaremetalset_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,15 @@ var _ = Describe("BaremetalSet Test", func() {
spec := baremetalv1.OpenStackBaremetalSetSpec{
BaremetalHosts: map[string]baremetalv1.InstanceSpec{
"compute-0": {
CtlPlaneIP: "10.0.0.1",
UserData: nil,
NetworkData: nil,
PreprovisioningNetworkDataName: "",
CtlPlaneIP: "10.0.0.1",
UserData: nil,
NetworkData: nil,
},
},
OSImage: "",
OSContainerImageURL: "",
ApacheImageURL: "",
AgentImageURL: "",
UserData: nil,
NetworkData: nil,
AutomatedCleaningMode: "metadata",
ProvisionServerName: "",
ProvisioningInterface: "",
Expand Down

0 comments on commit d27051c

Please sign in to comment.