Skip to content

Commit 3702644

Browse files
authored
Merge pull request #5315 from fabriziopandini/remove-machine.status.version
⚠️ Remove machine.status.version
2 parents f2cc211 + 3b7701b commit 3702644

File tree

9 files changed

+85
-52
lines changed

9 files changed

+85
-52
lines changed

api/v1alpha3/conversion.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,6 @@ func (dst *MachineDeployment) ConvertFrom(srcRaw conversion.Hub) error {
210210
return nil
211211
}
212212

213-
// Status.Conditions was introduced in v1alpha4, thus requiring a custom conversion function; the values is going to be preserved in an annotation thus allowing roundtrip without loosing informations
214-
func Convert_v1beta1_MachineDeploymentStatus_To_v1alpha3_MachineDeploymentStatus(in *v1beta1.MachineDeploymentStatus, out *MachineDeploymentStatus, s apiconversion.Scope) error {
215-
return autoConvert_v1beta1_MachineDeploymentStatus_To_v1alpha3_MachineDeploymentStatus(in, out, s)
216-
}
217-
218213
func (src *MachineDeploymentList) ConvertTo(dstRaw conversion.Hub) error {
219214
dst := dstRaw.(*v1beta1.MachineDeploymentList)
220215

@@ -307,3 +302,13 @@ func Convert_v1alpha3_ObjectMeta_To_v1beta1_ObjectMeta(in *ObjectMeta, out *v1be
307302
func Convert_v1beta1_MachineStatus_To_v1alpha3_MachineStatus(in *v1beta1.MachineStatus, out *MachineStatus, s apiconversion.Scope) error {
308303
return autoConvert_v1beta1_MachineStatus_To_v1alpha3_MachineStatus(in, out, s)
309304
}
305+
306+
func Convert_v1beta1_MachineDeploymentStatus_To_v1alpha3_MachineDeploymentStatus(in *v1beta1.MachineDeploymentStatus, out *MachineDeploymentStatus, s apiconversion.Scope) error {
307+
// Status.Conditions was introduced in v1alpha4, thus requiring a custom conversion function; the values is going to be preserved in an annotation thus allowing roundtrip without loosing informations
308+
return autoConvert_v1beta1_MachineDeploymentStatus_To_v1alpha3_MachineDeploymentStatus(in, out, s)
309+
}
310+
311+
func Convert_v1alpha3_MachineStatus_To_v1beta1_MachineStatus(in *MachineStatus, out *v1beta1.MachineStatus, s apiconversion.Scope) error {
312+
// Status.version has been removed in v1beta1, thus requiring custom conversion function. the information will be dropped.
313+
return autoConvert_v1alpha3_MachineStatus_To_v1beta1_MachineStatus(in, out, s)
314+
}

api/v1alpha3/conversion_test.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestFuzzyConversion(t *testing.T) {
3737
t.Run("for Machine", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
3838
Hub: &v1beta1.Machine{},
3939
Spoke: &Machine{},
40-
FuzzerFuncs: []fuzzer.FuzzerFuncs{BootstrapFuzzFuncs},
40+
FuzzerFuncs: []fuzzer.FuzzerFuncs{BootstrapFuzzFuncs, MachineStatusFuzzFunc},
4141
}))
4242

4343
t.Run("for MachineSet", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
@@ -58,6 +58,20 @@ func TestFuzzyConversion(t *testing.T) {
5858
}))
5959
}
6060

61+
func MachineStatusFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} {
62+
return []interface{}{
63+
MachineStatusFuzzer,
64+
}
65+
}
66+
67+
func MachineStatusFuzzer(in *MachineStatus, c fuzz.Continue) {
68+
c.FuzzNoCustom(in)
69+
70+
// These fields have been removed in v1beta1
71+
// data is going to be lost, so we're forcing zero values to avoid round trip errors.
72+
in.Version = nil
73+
}
74+
6175
func CustomObjectMetaFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} {
6276
return []interface{}{
6377
CustomObjectMetaFuzzer,

api/v1alpha3/zz_generated.conversion.go

Lines changed: 6 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha4/conversion.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1alpha4
1818

1919
import (
20+
apiconversion "k8s.io/apimachinery/pkg/conversion"
2021
"sigs.k8s.io/cluster-api/api/v1beta1"
2122
"sigs.k8s.io/controller-runtime/pkg/conversion"
2223
)
@@ -164,3 +165,8 @@ func (dst *MachineHealthCheckList) ConvertFrom(srcRaw conversion.Hub) error {
164165

165166
return Convert_v1beta1_MachineHealthCheckList_To_v1alpha4_MachineHealthCheckList(src, dst, nil)
166167
}
168+
169+
func Convert_v1alpha4_MachineStatus_To_v1beta1_MachineStatus(in *MachineStatus, out *v1beta1.MachineStatus, s apiconversion.Scope) error {
170+
// Status.version has been removed in v1beta1, thus requiring custom conversion function. the information will be dropped.
171+
return autoConvert_v1alpha4_MachineStatus_To_v1beta1_MachineStatus(in, out, s)
172+
}

api/v1alpha4/conversion_test.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ package v1alpha4
1919
import (
2020
"testing"
2121

22+
fuzz "github.com/google/gofuzz"
23+
"k8s.io/apimachinery/pkg/api/apitesting/fuzzer"
24+
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
2225
"sigs.k8s.io/cluster-api/api/v1beta1"
2326
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
2427
)
@@ -34,8 +37,9 @@ func TestFuzzyConversion(t *testing.T) {
3437
}))
3538

3639
t.Run("for Machine", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
37-
Hub: &v1beta1.Machine{},
38-
Spoke: &Machine{},
40+
Hub: &v1beta1.Machine{},
41+
Spoke: &Machine{},
42+
FuzzerFuncs: []fuzzer.FuzzerFuncs{MachineStatusFuzzFunc},
3943
}))
4044

4145
t.Run("for MachineSet", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
@@ -53,3 +57,17 @@ func TestFuzzyConversion(t *testing.T) {
5357
Spoke: &MachineHealthCheck{},
5458
}))
5559
}
60+
61+
func MachineStatusFuzzFunc(_ runtimeserializer.CodecFactory) []interface{} {
62+
return []interface{}{
63+
MachineStatusFuzzer,
64+
}
65+
}
66+
67+
func MachineStatusFuzzer(in *MachineStatus, c fuzz.Continue) {
68+
c.FuzzNoCustom(in)
69+
70+
// These fields have been removed in v1beta1
71+
// data is going to be lost, so we're forcing zero values to avoid round trip errors.
72+
in.Version = nil
73+
}

api/v1alpha4/zz_generated.conversion.go

Lines changed: 28 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/machine_types.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,6 @@ type MachineStatus struct {
116116
// +optional
117117
LastUpdated *metav1.Time `json:"lastUpdated,omitempty"`
118118

119-
// Version specifies the current version of Kubernetes running
120-
// on the corresponding Node. This is meant to be a means of bubbling
121-
// up status from the Node to the Machine.
122-
// It is entirely optional, but useful for end-user UX if it’s present.
123-
// +optional
124-
Version *string `json:"version,omitempty"`
125-
126119
// FailureReason will be set in the event that there is a terminal problem
127120
// reconciling the Machine and will contain a succinct value suitable
128121
// for machine interpretation.

api/v1beta1/zz_generated.deepcopy.go

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

config/crd/bases/cluster.x-k8s.io_machines.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,12 +1125,6 @@ spec:
11251125
description: Phase represents the current phase of machine actuation.
11261126
E.g. Pending, Running, Terminating, Failed etc.
11271127
type: string
1128-
version:
1129-
description: Version specifies the current version of Kubernetes running
1130-
on the corresponding Node. This is meant to be a means of bubbling
1131-
up status from the Node to the Machine. It is entirely optional,
1132-
but useful for end-user UX if it’s present.
1133-
type: string
11341128
type: object
11351129
type: object
11361130
served: true

0 commit comments

Comments
 (0)