Skip to content

Commit

Permalink
Make MachineDeployment.Spec.Strategy a pointer
Browse files Browse the repository at this point in the history
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"`
  • Loading branch information
alvaroaleman committed Oct 18, 2018
1 parent a33496d commit b5d2c67
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/cluster/v1alpha1/machinedeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type MachineDeploymentSpec struct {
// The deployment strategy to use to replace existing machines with
// new ones.
// +optional
Strategy MachineDeploymentStrategy `json:"strategy,omitempty"`
Strategy *MachineDeploymentStrategy `json:"strategy,omitempty"`

// Minimum number of seconds for which a newly created machine should
// be ready.
Expand Down
6 changes: 5 additions & 1 deletion pkg/apis/cluster/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestReconcile(t *testing.T) {
Replicas: int32Ptr(2),
RevisionHistoryLimit: int32Ptr(0),
Selector: metav1.LabelSelector{MatchLabels: labels},
Strategy: clusterv1alpha1.MachineDeploymentStrategy{
Strategy: &clusterv1alpha1.MachineDeploymentStrategy{
Type: common.RollingUpdateMachineDeploymentStrategyType,
RollingUpdate: &clusterv1alpha1.MachineRollingUpdateDeployment{
MaxUnavailable: intstrPtr(0),
Expand Down

0 comments on commit b5d2c67

Please sign in to comment.