Skip to content

Commit

Permalink
Allow Processing BootConfigs without IgnitionSecRefs and Remove depre…
Browse files Browse the repository at this point in the history
…cated MachineBootConfig Reconciler
  • Loading branch information
hardikdr committed Nov 11, 2024
1 parent 473ef3e commit 9ff3da4
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 263 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ issues:
- lll
- path: "server/*"
linters:
- dupl
- lll
- path: "cmd/*"
linters:
Expand Down
8 changes: 4 additions & 4 deletions api/v1alpha1/httpbootconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (

// HTTPBootConfigSpec defines the desired state of HTTPBootConfig
type HTTPBootConfigSpec struct {
SystemUUID string `json:"systemUUID,omitempty"`
IgnitionSecretRef *corev1.ObjectReference `json:"ignitionSecretRef,omitempty"`
SystemIPs []string `json:"systemIPs,omitempty"`
UKIURL string `json:"ukiURL,omitempty"`
SystemUUID string `json:"systemUUID,omitempty"`
IgnitionSecretRef *corev1.LocalObjectReference `json:"ignitionSecretRef,omitempty"`
SystemIPs []string `json:"systemIPs,omitempty"`
UKIURL string `json:"ukiURL,omitempty"`
}

// HTTPBootConfigStatus defines the observed state of HTTPBootConfig
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/zz_generated.deepcopy.go

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

24 changes: 4 additions & 20 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ var (

const (
// core controllers
machineBootConfigControllerHttp = "machinebootconfighttp"
ipxeBootConfigController = "ipxebootconfig"
serverBootConfigControllerPxe = "serverbootconfigpxe"
httpBootConfigController = "httpbootconfig"
serverBootConfigControllerHttp = "serverbootconfighttp"
ipxeBootConfigController = "ipxebootconfig"
serverBootConfigControllerPxe = "serverbootconfigpxe"
httpBootConfigController = "httpbootconfig"
serverBootConfigControllerHttp = "serverbootconfighttp"
)

func init() {
Expand Down Expand Up @@ -76,7 +75,6 @@ func main() {
var ipxeServiceProtocol string
var ipxeServicePort int
var imageServerURL string
var bootconfigNamespace string

flag.IntVar(&ipxeServicePort, "ipxe-service-port", 5000, "IPXE Service port to listen on.")
flag.StringVar(&ipxeServiceProtocol, "ipxe-service-protocol", "http", "IPXE Service Protocol.")
Expand All @@ -85,7 +83,6 @@ func main() {
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.StringVar(&bootserverAddr, "boot-server-address", ":8082", "The address the boot-server binds to.")
flag.StringVar(&bootconfigNamespace, "machinebootconfig-namespace", "default", "The namespace in which HTTPBootConfigs should be created for MachineBootConfiguration Controller.")
flag.StringVar(&imageProxyServerAddr, "image-proxy-server-address", ":8083", "The address the image-proxy-server binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
Expand All @@ -100,7 +97,6 @@ func main() {
ipxeBootConfigController,
serverBootConfigControllerPxe,
serverBootConfigControllerHttp,
machineBootConfigControllerHttp,
httpBootConfigController,
)

Expand Down Expand Up @@ -213,18 +209,6 @@ func main() {
}
}

if controllers.Enabled(machineBootConfigControllerHttp) {
if err = (&controller.MachineBootConfigurationHTTPReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
ImageServerURL: imageServerURL,
BootConfigNamespace: bootconfigNamespace,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "MachineBootConfigHttp")
os.Exit(1)
}
}

if controllers.Enabled(httpBootConfigController) {
if err = (&controller.HTTPBootConfigReconciler{
Client: mgr.GetClient(),
Expand Down
42 changes: 7 additions & 35 deletions config/crd/bases/boot.ironcore.dev_httpbootconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,47 +47,19 @@ spec:
description: HTTPBootConfigSpec defines the desired state of HTTPBootConfig
properties:
ignitionSecretRef:
description: ObjectReference contains enough information to let you
inspect or modify the referred object.
description: |-
LocalObjectReference contains enough information to let you locate the
referenced object inside the same namespace.
properties:
apiVersion:
description: API version of the referent.
type: string
fieldPath:
description: |-
If referring to a piece of an object instead of an entire object, this string
should contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].
For example, if the object reference is to a container within a pod, this would take on a value like:
"spec.containers{name}" (where "name" refers to the name of the container that triggered
the event) or if no container name is specified "spec.containers[2]" (container with
index 2 in this pod). This syntax is chosen only to have some well-defined way of
referencing a part of an object.
type: string
kind:
description: |-
Kind of the referent.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
namespace:
description: |-
Namespace of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/
type: string
resourceVersion:
description: |-
Specific resourceVersion to which this reference is made, if any.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency
type: string
uid:
description: |-
UID of the referent.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids
type: string
type: object
x-kubernetes-map-type: atomic
systemIPs:
Expand Down
4 changes: 0 additions & 4 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ rules:
- apiGroups:
- metal.ironcore.dev
resources:
- bootconfigurations
- machines
- serverbootconfigurations
- servers
verbs:
Expand All @@ -74,14 +72,12 @@ rules:
- apiGroups:
- metal.ironcore.dev
resources:
- bootconfigurations/finalizers
- serverbootconfigurations/finalizers
verbs:
- update
- apiGroups:
- metal.ironcore.dev
resources:
- bootconfigurations/status
- serverbootconfigurations/status
verbs:
- get
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/httpbootconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (r *HTTPBootConfigReconciler) ensureIgnition(ctx context.Context, _ logr.Lo
// Verify if the IgnitionRef is set, and it has the intended data key.
if HTTPBootConfig.Spec.IgnitionSecretRef != nil {
IgnitionSecret := &corev1.Secret{}
if err := r.Get(ctx, client.ObjectKey{Name: HTTPBootConfig.Spec.IgnitionSecretRef.Name, Namespace: HTTPBootConfig.Spec.IgnitionSecretRef.Namespace}, IgnitionSecret); err != nil {
if err := r.Get(ctx, client.ObjectKey{Name: HTTPBootConfig.Spec.IgnitionSecretRef.Name, Namespace: HTTPBootConfig.Namespace}, IgnitionSecret); err != nil {
return bootv1alpha1.HTTPBootConfigStateError, err
// TODO: Add some validation steps to ensure that the IgntionData is compliant, if necessary.
// Assume for now, that it's going to json format.
Expand Down Expand Up @@ -143,7 +143,7 @@ func (r *HTTPBootConfigReconciler) enqueueHTTPBootConfigReferencingIgnitionSecre
for _, HTTPBootConfig := range list.Items {
if HTTPBootConfig.Spec.IgnitionSecretRef != nil &&
HTTPBootConfig.Spec.IgnitionSecretRef.Name == secretObj.Name &&
HTTPBootConfig.Spec.IgnitionSecretRef.Namespace == secretObj.Namespace {
HTTPBootConfig.Namespace == secretObj.Namespace {
requests = append(requests, reconcile.Request{
NamespacedName: types.NamespacedName{
Name: HTTPBootConfig.Name,
Expand Down
183 changes: 0 additions & 183 deletions internal/controller/machinebootconfiguration_http_controller.go

This file was deleted.

Loading

0 comments on commit 9ff3da4

Please sign in to comment.