-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adds code commentary and improves a log message #52
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,6 +139,8 @@ func (r *AgentReconciler) getMachineFromBMH( | |
return machine, nil | ||
} | ||
|
||
// findBMH returns the BareMetalHost whose BootMACAddress matches an interface | ||
// on the Agent's status. | ||
func (r *AgentReconciler) findBMH( | ||
ctx context.Context, | ||
agent *aiv1beta1.Agent, | ||
|
@@ -147,6 +149,10 @@ func (r *AgentReconciler) findBMH( | |
return nil, errors.New("agent doesn't have inventory yet") | ||
} | ||
|
||
// TODO maybe we can find a better way than listing and scanning every BMH | ||
// that exists, such as explicitly watching BMHs and setting up a | ||
// FieldIndexer. | ||
// Example: https://github.com/kubernetes-sigs/kubebuilder/blob/master/docs/book/src/reference/watching-resources/testdata/external-indexed-field/controller.go | ||
Comment on lines
+152
to
+155
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea! Will look into this, thank you!! |
||
bmhs := &metal3v1alpha1.BareMetalHostList{} | ||
if err := r.Client.List(ctx, bmhs); err != nil { | ||
return nil, err | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,6 +228,7 @@ func (r *AgentBootstrapConfigReconciler) Reconcile(ctx context.Context, req ctrl | |
return ctrl.Result{}, err | ||
} | ||
|
||
// check if the InfraEnv controller has set the ISO URL yet. If not, keep waiting. | ||
if config.Status.ISODownloadURL == "" { | ||
conditions.MarkFalse( | ||
config, | ||
|
@@ -239,6 +240,7 @@ func (r *AgentBootstrapConfigReconciler) Reconcile(ctx context.Context, req ctrl | |
return ctrl.Result{}, nil | ||
} | ||
|
||
// ensure the live ISO URL and type are set on the metal3 MachineTemplate | ||
if err := r.setMetal3MachineTemplateImage(ctx, config, machine); err != nil { | ||
conditions.MarkFalse( | ||
config, | ||
|
@@ -432,12 +434,14 @@ func (r *AgentBootstrapConfigReconciler) setMetal3MachineImage( | |
return err | ||
} | ||
log.V(logutil.TraceLevel). | ||
Info("Added ISO URLs to metal3 machines", "machine", metal3Machine.Name, "namespace", metal3Machine.Namespace) | ||
Info("Added ISO URL to metal3 machine", "machine", metal3Machine.Name, "namespace", metal3Machine.Namespace) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, thank you!! |
||
} | ||
return nil | ||
} | ||
|
||
// Retrieves InfrastructureRefKey | ||
// getInfrastructureRefKey retrieves InfrastructureRefKey by looking for an | ||
// owner reference to a AgentControlPlane, and if not found, an owner reference | ||
// to a MachineDeployment. Returns an error if the Machine is owned by neither. | ||
func (r *AgentBootstrapConfigReconciler) getInfrastructureRefKey( | ||
ctx context.Context, | ||
machine *clusterv1.Machine, | ||
|
@@ -461,7 +465,9 @@ func (r *AgentBootstrapConfigReconciler) getInfrastructureRefKey( | |
}, nil | ||
} | ||
|
||
// Overrides image reference by setting the LiveISO present on the AgentBootstrapConfig.Status.ISODownloadURL | ||
// setMetal3MachineTemplateImage overrides image reference by copying the | ||
// LiveISO URL from AgentBootstrapConfig.Status.ISODownloadURL to metal3 | ||
// MachineTemplate Spec. | ||
func (r *AgentBootstrapConfigReconciler) setMetal3MachineTemplateImage( | ||
ctx context.Context, | ||
config *bootstrapv1alpha1.AgentBootstrapConfig, | ||
|
@@ -553,6 +559,11 @@ func (r *AgentBootstrapConfigReconciler) SetupWithManager(mgr ctrl.Manager) erro | |
). | ||
Watches( | ||
&hivev1.ClusterDeployment{}, | ||
// TODO does this depend on the name and namespace for the | ||
// ClusterDeployment being the same as the name and namespace of the | ||
// ABC? Could we put an owner reference on the CD instead and use | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes we definitely need to change a few naming convenction, ClusterImageSet is another example. |
||
// that as a concrete relationship, along with the | ||
// EnqueueRequestForOwner handler? | ||
&handler.EnqueueRequestForObject{}, | ||
). | ||
Complete(r) | ||
|
@@ -563,6 +574,7 @@ func (r *AgentBootstrapConfigReconciler) FilterMachine(_ context.Context, o clie | |
result := []ctrl.Request{} | ||
m, ok := o.(*clusterv1.Machine) | ||
if !ok { | ||
// TODO handle this without a panic | ||
panic(fmt.Sprintf("Expected a Machine but got a %T", o)) | ||
} | ||
// m.Spec.ClusterName | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we initially moved it here to prevent the user from setting this field.
What are the reasons to move it to spec?EDIT: Nvm, I see your comment below about it being unconventional to set status on a resource it doesn't own
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's desired state. We want the URL to be used in the bootstrap process. And of course in a declarative API, we "spec"ify our desired state in the
spec
. :)The status should be reserved for observations about the world that were taken the last time the owning controller reconciled this resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see! That makes sense, thank you for the explanation! CC @rccrdpccl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, however I was thinking that might be a better idea to remove the InfraEnv controller altogether and just watch InfraEnv from the ABC controller, so we might remove the field altogether.
I also think we should probably apply the same concept to other controller we have for assisted's resources. WDYT?