Skip to content

Commit c48740e

Browse files
committed
Make MachineDeployment.Spec.Strategy a pointer
This is required in order to allow defaulting it via a MutatingWebhook. When it is a literal and the user creates a MachineDeployment where that property does not exist, the creation of a jsonpatch will happen based on a representation where that field exists, since literals always gets marshaled. This means a generated jsonpatch will get refused by the APIServer which doesn't know anything about that field with an error like this: `doc is missing path: "/spec/strategy/type"`
1 parent 19551f1 commit c48740e

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

pkg/apis/cluster/v1alpha1/machinedeployment_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type MachineDeploymentSpec struct {
4040
// The deployment strategy to use to replace existing machines with
4141
// new ones.
4242
// +optional
43-
Strategy MachineDeploymentStrategy `json:"strategy,omitempty"`
43+
Strategy *MachineDeploymentStrategy `json:"strategy,omitempty"`
4444

4545
// Minimum number of seconds for which a newly created machine should
4646
// be ready.

pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/controller/machinedeployment/machinedeployment_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func TestReconcile(t *testing.T) {
4848
MinReadySeconds: int32Ptr(0),
4949
Replicas: int32Ptr(2),
5050
Selector: metav1.LabelSelector{MatchLabels: labels},
51-
Strategy: clusterv1alpha1.MachineDeploymentStrategy{
51+
Strategy: &clusterv1alpha1.MachineDeploymentStrategy{
5252
Type: common.RollingUpdateMachineDeploymentStrategyType,
5353
RollingUpdate: &clusterv1alpha1.MachineRollingUpdateDeployment{
5454
MaxUnavailable: intstrPtr(0),

0 commit comments

Comments
 (0)