-
Notifications
You must be signed in to change notification settings - Fork 55
Conversation
0347619
to
26d795b
Compare
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've not looked at the parts that do the actual ssh / kubeadm stuff. I've just looked at the CAPI specific parts.
if err != nil { | ||
log.Fatal(err) | ||
} | ||
if err = clusterReconciler.SetupWithManager(mgr, controller.Options{MaxConcurrentReconciles: 1}); err != nil { |
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.
Can the reconcile occur in parallel or does it have to be a singleton? A lot of the other provider expose a concurrency
flag.
@@ -342,22 +393,11 @@ func (a *MachineActuator) installNewBootstrapToken(ns string) (*corev1.Secret, e | |||
} | |||
|
|||
// Delete the machine. If no error is returned, it is assumed that all dependent resources have been cleaned up. | |||
func (a *MachineActuator) Delete(ctx context.Context, cluster *clusterv1.Cluster, machine *clusterv1.Machine) error { | |||
contextLog := log.WithFields(log.Fields{"machine": machine.Name, "cluster": cluster.Name}) | |||
func (a *MachineController) delete(ctx context.Context, c *baremetalspecv1.BareMetalCluster, machine *clusterv1.Machine, bmm *baremetalspecv1.BareMetalMachine) error { |
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.
Could we name this reconcileDelete
instead to have consistency with other providers?
return ctrl.Result{}, nil | ||
} | ||
|
||
func (a *MachineController) create(ctx context.Context, c *baremetalspecv1.BareMetalCluster, machine *clusterv1.Machine, bmm *baremetalspecv1.BareMetalMachine) error { |
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.
Could this be called reconcileNormal
or reconcile
instead? This will be consistent with other providers.
func FirstMaster(machines []*clusterv1.Machine) *clusterv1.Machine { | ||
for _, machine := range machines { | ||
// Machines and BareMetalMachines must be in the same order | ||
func FirstMaster(machines []*clusterv1.Machine, bl []*baremetalspecv1.BareMetalMachine) (*clusterv1.Machine, *baremetalspecv1.BareMetalMachine) { |
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 wonder if we should rethink how we denote master
nodes. I'm not sure a label on Machine
is the right place. I think we should probably implement a capi control plane instead to make it explicit. https://cluster-api.sigs.k8s.io/developer/architecture/controllers/control-plane.html
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.
Assuming there is no way to reuse the existing kubeadm control plane. Or perhaps support both?
d1649f2
to
4a08ebf
Compare
851730f
to
20d6bf6
Compare
c434da7
to
2c65b3d
Compare
6fc3ed9
to
e6a282f
Compare
e6a282f
to
fb82932
Compare
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.
Awesome work @bboreham 👏!
I think we shall merge this now, and fix the comments I spot here in smaller follow-up PRs.
"github.com/weaveworks/wksctl/pkg/apis" | ||
"github.com/weaveworks/wksctl/pkg/apis/wksprovider/controller/wksctl" | ||
wks "github.com/weaveworks/wksctl/pkg/apis/wksprovider/controller/wksctl" | ||
baremetalv1 "github.com/weaveworks/wksctl/pkg/baremetal/v1alpha3" |
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.
nit: I'd either name this baremetalapi
, baremetalext
(as in external version), just baremetal
or fully-qualified baremetalv1alpha3
, but to me v1
suffix means stable
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 think we are following the precedent of upstream, e.g.:
https://github.com/kubernetes-sigs/cluster-api-provider-aws/blob/4831a1d5347b00a2523cf7b02845eee56fbac1f7/controllers/awsmachine_controller.go#L28
clustercommon "sigs.k8s.io/cluster-api/pkg/apis/cluster/common" | ||
capicluster "sigs.k8s.io/cluster-api/pkg/controller/cluster" | ||
capimachine "sigs.k8s.io/cluster-api/pkg/controller/machine" | ||
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha3" |
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.
Same here. Maybe just clusterapi
?
machineActuator, err := wks.NewMachineActuator(wks.MachineActuatorParams{ | ||
EventRecorder: mgr.GetRecorder(wks.ProviderName + "-controller"), | ||
|
||
machineController, err := wks.NewMachineController(wks.MachineControllerParams{ |
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.
As discussed, maybe rename Controller to Reconciler
} | ||
|
||
var ctlrNamespace string | ||
{ |
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.
are you creating a new scope here? maybe add a comment why
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.
To limit where client
created on the line below can be used.
I suspect the correct fix is to not care about namespaces.
if err != nil { | ||
log.Fatalf("failed to create client: %s", err) | ||
} | ||
ctlrNamespace, err = initializeControllerNamespace(client) |
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.
what is this doing? machineutil.GetKubernetesNamespaceFromMachines
that is called by this fn doesn't seem to change state, but this name suggests it does
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 question, but the name of that function did not change in this PR.
@@ -0,0 +1,46 @@ | |||
package v1alpha3 |
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.
A comment for later, but I'd maybe keep the v1alpha1
packages here for a grace period for being able to convert objects over eventually.
A comment for now: this is an api, it should exist under pkg/apis
return nil | ||
} | ||
|
||
func NewScheme() (*runtime.Scheme, error) { |
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.
This function seems unused?
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.
return nil, err | ||
} | ||
// Parse parses the provided machines io.Reader. | ||
func Parse(r io.ReadCloser) (ml []*clusterv1.Machine, bl []*baremetalspecv1.BareMetalMachine, err error) { |
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.
FYI: I've coded a pretty cool serializer that can do these things in a generic manner, so we can use that later to avoid writing the same code over and over again. But for a future PR.
} | ||
Populate(machines) | ||
|
||
errors := Validate(machines) | ||
return errorsHandler(machines, errors) | ||
errors := Validate(machines, bl) |
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'd put validation of the API objects in pkg/apis/baremetal/validation
@@ -38,14 +38,14 @@ var AddToScheme = SchemeBuilder.AddToScheme | |||
|
|||
func addKnownTypes(scheme *runtime.Scheme) error { |
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.
This function seems weird. I'd use the AddToScheme methods instead to get what's actually needed without duplicating code.
Many things have changed: - Where we had a List of Machine, we now have a YAML stream, i.e. multiple documents separated by --- - Where we had a single struct, we must deal with a ClusterAPI struct and a provider-specific struct Fix up ParseAndDefaultAndValidate to return both cluster structs
(renamed from "actuator")
(renamed from 'actuator')
Blank means use the default, but when ImageRepository is set the current code is failing.
Almost everywhere uses Public.Address or Private.Address, so these other ones are just a source of confusion.
Signed-off-by: Dennis Marttinen <dennis@weave.works>
so it can be used by other packages
It's awkward having to do this every time the controller does anything.
This means the controller will see it as unchanged when it fires up.
550d9da
to
2b644aa
Compare
Fixes #170
v1alpha1
types are left in place for anyone who wants to run programs containing both.