Skip to content

Commit d750d27

Browse files
authored
🌱 Deprecate (ssh) PortAfterCloudInit. (#1670)
* 🌱 Deprecate (ssh) PortAfterCloudInit. Since [PR Install Cloud-Init-Data via post-install.sh #1407](#1407) this field is not functional. The additional reboot after InstallImage was removed. The ssh port after InstallImage is the port which gets used.
1 parent 67a49a8 commit d750d27

15 files changed

+23
-266
lines changed

api/v1beta1/hetznerbaremetalmachine_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ type SSHSpec struct {
121121
// +optional
122122
PortAfterInstallImage int `json:"portAfterInstallImage"`
123123

124-
// PortAfterCloudInit specifies the port that has to be used to connect to the machine
125-
// by reaching the server via SSH after the successful completion of cloud init.
124+
// PortAfterCloudInit is deprecated. Since PR Install Cloud-Init-Data via post-install.sh #1407 this field is not functional.
125+
// Deprecated: This field is not used anymore.
126126
// +optional
127127
PortAfterCloudInit int `json:"portAfterCloudInit"`
128128
}

api/v1beta1/hetznerbaremetalmachine_validation_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ func TestValidateHetznerBareMetalMachineSpecUpdate(t *testing.T) {
267267
},
268268
},
269269
PortAfterInstallImage: 22,
270-
PortAfterCloudInit: 22,
271270
},
272271
},
273272
newSpec: HetznerBareMetalMachineSpec{
@@ -281,7 +280,6 @@ func TestValidateHetznerBareMetalMachineSpecUpdate(t *testing.T) {
281280
},
282281
},
283282
PortAfterInstallImage: 2222,
284-
PortAfterCloudInit: 2222,
285283
},
286284
},
287285
},
@@ -295,7 +293,6 @@ func TestValidateHetznerBareMetalMachineSpecUpdate(t *testing.T) {
295293
},
296294
},
297295
PortAfterInstallImage: 2222,
298-
PortAfterCloudInit: 2222,
299296
}, "sshSpec immutable"),
300297
},
301298
{
@@ -363,7 +360,6 @@ func TestValidateHetznerBareMetalMachineSpecUpdate(t *testing.T) {
363360
},
364361
},
365362
PortAfterInstallImage: 22,
366-
PortAfterCloudInit: 22,
367363
},
368364
HostSelector: HostSelector{
369365
MatchLabels: map[string]string{
@@ -395,7 +391,6 @@ func TestValidateHetznerBareMetalMachineSpecUpdate(t *testing.T) {
395391
},
396392
},
397393
PortAfterInstallImage: 22,
398-
PortAfterCloudInit: 22,
399394
},
400395
HostSelector: HostSelector{
401396
MatchLabels: map[string]string{

api/v1beta1/hetznerbaremetalmachine_webhook.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,7 @@ var _ webhook.Validator = &HetznerBareMetalMachine{}
4343

4444
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
4545
func (bmMachine *HetznerBareMetalMachine) ValidateCreate() (admission.Warnings, error) {
46-
if bmMachine.Spec.SSHSpec.PortAfterCloudInit == 0 {
47-
bmMachine.Spec.SSHSpec.PortAfterCloudInit = bmMachine.Spec.SSHSpec.PortAfterInstallImage
48-
}
49-
5046
allErrs := validateHetznerBareMetalMachineSpecCreate(bmMachine.Spec)
51-
5247
return nil, aggregateObjErrors(bmMachine.GroupVersionKind().GroupKind(), bmMachine.Name, allErrs)
5348
}
5449

api/v1beta1/hetznerbaremetalmachinetemplate_webhook.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,7 @@ type HetznerBareMetalMachineTemplateWebhook struct{}
4747
var _ webhook.CustomValidator = &HetznerBareMetalMachineTemplateWebhook{}
4848

4949
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
50-
func (r *HetznerBareMetalMachineTemplateWebhook) ValidateCreate(_ context.Context, raw runtime.Object) (admission.Warnings, error) {
51-
hbmmt, ok := raw.(*HetznerBareMetalMachineTemplate)
52-
if !ok {
53-
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a HetznerBareMetalMachineTemplate but got a %T", raw))
54-
}
55-
56-
if hbmmt.Spec.Template.Spec.SSHSpec.PortAfterCloudInit == 0 {
57-
hbmmt.Spec.Template.Spec.SSHSpec.PortAfterCloudInit = hbmmt.Spec.Template.Spec.SSHSpec.PortAfterInstallImage
58-
}
59-
50+
func (r *HetznerBareMetalMachineTemplateWebhook) ValidateCreate(_ context.Context, _ runtime.Object) (admission.Warnings, error) {
6051
// TODO: Cannot validate it because ClusterClass applies empty template objects
6152
// allErrs := validateHetznerBareMetalMachineSpecCreate(hbmmt.Spec.Template.Spec)
6253
return nil, nil

config/crd/bases/infrastructure.cluster.x-k8s.io_hetznerbaremetalhosts.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,8 @@ spec:
499499
properties:
500500
portAfterCloudInit:
501501
description: |-
502-
PortAfterCloudInit specifies the port that has to be used to connect to the machine
503-
by reaching the server via SSH after the successful completion of cloud init.
502+
PortAfterCloudInit is deprecated. Since PR Install Cloud-Init-Data via post-install.sh #1407 this field is not functional.
503+
Deprecated: This field is not used anymore.
504504
type: integer
505505
portAfterInstallImage:
506506
default: 22

config/crd/bases/infrastructure.cluster.x-k8s.io_hetznerbaremetalmachines.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ spec:
258258
properties:
259259
portAfterCloudInit:
260260
description: |-
261-
PortAfterCloudInit specifies the port that has to be used to connect to the machine
262-
by reaching the server via SSH after the successful completion of cloud init.
261+
PortAfterCloudInit is deprecated. Since PR Install Cloud-Init-Data via post-install.sh #1407 this field is not functional.
262+
Deprecated: This field is not used anymore.
263263
type: integer
264264
portAfterInstallImage:
265265
default: 22

config/crd/bases/infrastructure.cluster.x-k8s.io_hetznerbaremetalmachinetemplates.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ spec:
245245
properties:
246246
portAfterCloudInit:
247247
description: |-
248-
PortAfterCloudInit specifies the port that has to be used to connect to the machine
249-
by reaching the server via SSH after the successful completion of cloud init.
248+
PortAfterCloudInit is deprecated. Since PR Install Cloud-Init-Data via post-install.sh #1407 this field is not functional.
249+
Deprecated: This field is not used anymore.
250250
type: integer
251251
portAfterInstallImage:
252252
default: 22

controllers/controllers_suite_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ func getDefaultHetznerBareMetalMachineSpec() infrav1.HetznerBareMetalMachineSpec
285285
},
286286
},
287287
PortAfterInstallImage: 22,
288-
PortAfterCloudInit: 22,
289288
},
290289
}
291290
}

controllers/hetznerbaremetalhost_controller_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,6 @@ var _ = Describe("HetznerBareMetalHostReconciler", func() {
550550
Spec: getDefaultHetznerBareMetalMachineSpec(),
551551
}
552552
bmMachine.Spec.SSHSpec.PortAfterInstallImage = 23
553-
bmMachine.Spec.SSHSpec.PortAfterCloudInit = 24
554553

555554
Expect(testEnv.Create(ctx, bmMachine)).To(Succeed())
556555
})

controllers/hetznerbaremetalmachine_controller_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,6 @@ var _ = Describe("HetznerBareMetalMachineReconciler", func() {
791791
},
792792
},
793793
PortAfterInstallImage: 2222,
794-
PortAfterCloudInit: 2222,
795794
},
796795
},
797796
},

0 commit comments

Comments
 (0)