Skip to content

Commit

Permalink
Various review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
willie-yao committed Aug 10, 2023
1 parent dd5ccf6 commit f5d13f8
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 69 deletions.
47 changes: 0 additions & 47 deletions config/crd/bases/cluster.x-k8s.io_machinepools.yaml

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

1 change: 0 additions & 1 deletion exp/api/v1alpha3/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ func (src *MachinePool) ConvertTo(dstRaw conversion.Hub) error {
}
dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout
dst.Spec.Selector = restored.Spec.Selector
return nil
}

Expand Down
1 change: 0 additions & 1 deletion exp/api/v1alpha3/zz_generated.conversion.go

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

1 change: 0 additions & 1 deletion exp/api/v1alpha4/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func (src *MachinePool) ConvertTo(dstRaw conversion.Hub) error {
}
dst.Spec.Template.Spec.NodeDeletionTimeout = restored.Spec.Template.Spec.NodeDeletionTimeout
dst.Spec.Template.Spec.NodeVolumeDetachTimeout = restored.Spec.Template.Spec.NodeVolumeDetachTimeout
dst.Spec.Selector = restored.Spec.Selector
return nil
}

Expand Down
1 change: 0 additions & 1 deletion exp/api/v1alpha4/zz_generated.conversion.go

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

5 changes: 0 additions & 5 deletions exp/api/v1beta1/machinepool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ type MachinePoolSpec struct {
// +optional
Replicas *int32 `json:"replicas,omitempty"`

// Label selector for machines. Existing MachineSets whose machines are
// selected by this will be the ones affected by this deployment.
// It must match the machine template's labels.
Selector metav1.LabelSelector `json:"selector"`

// Template describes the machines that will be created.
Template clusterv1.MachineTemplateSpec `json:"template"`

Expand Down
1 change: 0 additions & 1 deletion exp/api/v1beta1/zz_generated.deepcopy.go

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

8 changes: 0 additions & 8 deletions internal/controllers/topology/cluster/desired_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -1059,14 +1059,6 @@ func computeMachinePool(_ context.Context, s *scope.Scope, desiredControlPlaneSt
// Note: the labels in MachineSet are used to properly cleanup templates when the MachineSet is deleted.
desiredMachinePoolObj.Spec.Template.Labels = machinePoolLabels

// Set the selector with the subset of labels identifying controlled machines.
// NOTE: this prevents the web hook to add cluster.x-k8s.io/pool-name label, that is
// redundant for managed MachinePool given that we already have topology.cluster.x-k8s.io/pool-name.
desiredMachinePoolObj.Spec.Selector.MatchLabels = map[string]string{}
desiredMachinePoolObj.Spec.Selector.MatchLabels[clusterv1.ClusterNameLabel] = s.Current.Cluster.Name
desiredMachinePoolObj.Spec.Selector.MatchLabels[clusterv1.ClusterTopologyOwnedLabel] = ""
desiredMachinePoolObj.Spec.Selector.MatchLabels[clusterv1.ClusterTopologyMachinePoolNameLabel] = machinePoolTopology.Name

// Set the desired replicas.
desiredMachinePoolObj.Spec.Replicas = machinePoolTopology.Replicas

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ func matchesSelector(req *runtimehooksv1.GeneratePatchesRequestItem, templateVar
}

// Check if the request is for a BootstrapConfigTemplate or an InfrastructureMachineTemplate
// of one of the configured MachineDeploymentClasses or MachinePoolClasses.
if selector.MatchResources.MachineDeploymentClass != nil || selector.MatchResources.MachinePoolClass != nil {
// of one of the configured MachineDeploymentClasses.
if selector.MatchResources.MachineDeploymentClass != nil {
// MachineDeployment.spec.template.spec.bootstrap.configRef or
// MachineDeployment.spec.template.spec.infrastructureRef holds the BootstrapConfigTemplate or
// InfrastructureMachineTemplate.
Expand Down Expand Up @@ -184,7 +184,11 @@ func matchesSelector(req *runtimehooksv1.GeneratePatchesRequestItem, templateVar
}
}
}
}

// Check if the request is for a BootstrapConfigTemplate or an InfrastructureMachineTemplate
// of one of the configured MachinePoolClasses.
if selector.MatchResources.MachinePoolClass != nil {
if req.HolderReference.Kind == "MachinePool" &&
(req.HolderReference.FieldPath == "spec.template.spec.bootstrap.configRef" ||
req.HolderReference.FieldPath == "spec.template.spec.infrastructureRef") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ type MachineDeploymentBuiltins struct {
// Bootstrap is the value of the .spec.template.spec.bootstrap field of the MachineDeployment.
Bootstrap *MachineBootstrapBuiltins `json:"bootstrap,omitempty"`

// InfrastructureRef is the value of the .spec.template.spec.bootstrap field of the MachineDeployment.
// InfrastructureRef is the value of the .spec.template.spec.infrastructureRef field of the MachineDeployment.
InfrastructureRef *MachineInfrastructureRefBuiltins `json:"infrastructureRef,omitempty"`
}

Expand Down Expand Up @@ -181,7 +181,7 @@ type MachinePoolBuiltins struct {
// Bootstrap is the value of the .spec.template.spec.bootstrap field of the MachinePool.
Bootstrap *MachineBootstrapBuiltins `json:"bootstrap,omitempty"`

// InfrastructureRef is the value of the .spec.template.spec.bootstrap field of the MachinePool.
// InfrastructureRef is the value of the .spec.template.spec.infrastructureRef field of the MachinePool.
InfrastructureRef *MachineInfrastructureRefBuiltins `json:"infrastructureRef,omitempty"`
}

Expand Down

0 comments on commit f5d13f8

Please sign in to comment.