-
Notifications
You must be signed in to change notification settings - Fork 430
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
Migrate to CRDS and Kube builder #33
Conversation
unused-packages = true | ||
|
||
[[prune.project]] |
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.
Disabling pruning for the cluster-api project to keep the sigs.k8s/cluster-api/config
folder which is needed for applying the CRDs.
apiVersion: "cluster.k8s.io/v1alpha1" | ||
kind: Cluster | ||
metadata: | ||
name: $CLUSTER_NAME |
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.
updated to use the generated cluster name
@@ -0,0 +1,36 @@ | |||
apiVersion: apiextensions.k8s.io/v1beta1 |
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.
generated by kubebuilder
os.Exit(1) | ||
} | ||
|
||
clusterActuator, err := cluster.NewClusterActuator(cluster.ClusterActuatorParams{Client: mgr.GetClient()}) |
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.
creates the actuator and registers them
if azure.client == nil { | ||
return nil, nil | ||
} | ||
currentMachine, err := util.GetMachineIfExists(azure.client, m.ObjectMeta.Namespace, m.ObjectMeta.Name) |
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.
API changed upstream
if err != nil { | ||
return err | ||
} | ||
return azure.client.Update(context.Background(), m) |
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.
API changed upstream
} | ||
} | ||
|
||
// func TestUpdateNoSpecChange(t *testing.T) { |
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.
fake client was removed upstream so need to revisit unit testing this part.
ports: | ||
- port: 443 | ||
--- | ||
apiVersion: apps/v1 |
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.
Logic is from the provider-components template with the un-used fields removed.
Comment out test cases that depend on the cluster v1 alpha1 client
90c93e5
to
129dfde
Compare
# Build | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager github.com/platform9/azure-provider/cmd/manager | ||
|
||
# Copy the controller-manager into a thin image |
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.
Is alpine 3.8 possible?
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.
yup - it should be. The file was generated using kube-builder and I think it defaulted to ubuntu.
return nil, nil | ||
} | ||
currentMachine, err := util.GetMachineIfExists(azure.client, m.ObjectMeta.Namespace, m.ObjectMeta.Name) | ||
if 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.
if err != nil { | |
if err != nil || currentMachine == nil { |
Can we merge the two if loops using that?
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 left the two checks to differentiate between the cases when the machine is actually because it has been deleted and just erroring on attempting to call the query the clients to check for machine existence.
Can we merge them in a way without losing that info?
return nil | ||
} | ||
currentMachine, err := util.GetMachineIfExists(azure.client, machine.ObjectMeta.Namespace, machine.ObjectMeta.Name) | ||
if 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.
See previous comment
} | ||
|
||
func (azure *AzureClient) updateAnnotations(cluster *clusterv1.Cluster, machine *clusterv1.Machine) error { | ||
if azure.client == 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.
Still not sure how I feel about these nil pre-checks at the beginning of a method.I would avoid this by having a nil check / validation much earlier in the call stack so that we don't do them over here. I may not have the complete context here of course. Open to discussing more.
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.
Was mostly left there for testing. But we can just initialize the actuator in the tests using the fake
client. I'll get rid of those checks.
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.
So this change would require us to update the controller-runtime
revision to pickup this change: https://github.com/kubernetes-sigs/controller-runtime/blob/master/pkg/client/fake/client.go#L57 for the unit tests to pass.
I'd say we wait on this to reduce the scope of this PR.
@@ -0,0 +1,235 @@ | |||
/* |
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.
Mocks !!! YAY!. Great going @marwanad :)
if err != nil { | ||
return fmt.Errorf("error creating or updating network security group: %v", err) | ||
} | ||
err = azure.network().WaitForNetworkSGsCreateOrUpdateFuture(*networkSGFuture) |
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 we move to azure.network()
to a variable and reuse that?
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.
The method network()
is just a wrapper that returns azure.services.Network
. It doesn't recreate the clients or anything but I can switch it over to local variables if you think that's better for readability.
if err != nil { | ||
return fmt.Errorf("error loading cluster provider config: %v", err) | ||
} | ||
resp, err := azure.resourcemanagement().CheckGroupExistence(clusterConfig.ResourceGroup) |
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 we move azure.resourcemanagement()
and reuse that?
resp, err := azure.resourcemanagement().CheckGroupExistence(clusterConfig.ResourceGroup) | |
azResourceClient := azure.resourcemanagement() |
2dd6a73
to
ab655ce
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.
Looks good to me overall. I apologize for the not keeping up with the updates here. Thanks for keeping the tests up to date. I'll get this merged asap to prevent this PR from getting bigger.
@ok-to-test Is an account I made for testing some webhooks. |
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.
Thanks @marwanad
* added auto-scaling support for azure * changes to allow creationg of autoscaling machine pool during creation of AKS cluster
[ES-569654] Remove agent pool profiles from managed cluster update request
The diff is massive but going commit by commit should describe the migration flow.
Closes #8