Skip to content

Commit baf0219

Browse files
author
Yuvaraj Kakaraparthi
committed
clean up MHC changes
1 parent 528af2c commit baf0219

15 files changed

+5
-139
lines changed

api/v1alpha3/conversion.go

-2
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,6 @@ func (src *MachineHealthCheck) ConvertTo(dstRaw conversion.Hub) error {
243243
if restored.Spec.UnhealthyRange != nil {
244244
dst.Spec.UnhealthyRange = restored.Spec.UnhealthyRange
245245
}
246-
247-
dst.Spec.Certificates = restored.Spec.Certificates
248246
return nil
249247
}
250248

api/v1alpha3/zz_generated.conversion.go

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha4/conversion.go

-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ func (src *MachineHealthCheck) ConvertTo(dstRaw conversion.Hub) error {
283283
return err
284284
}
285285

286-
dst.Spec.Certificates = restored.Spec.Certificates
287286
return nil
288287
}
289288

api/v1alpha4/zz_generated.conversion.go

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/clusterclass_types.go

-4
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@ type MachineHealthCheckClass struct {
167167
// +optional
168168
NodeStartupTimeout *metav1.Duration `json:"nodeStartupTimeout,omitempty"`
169169

170-
// Certificates contains the information needed to validate the health of machine certificates.
171-
// +optional
172-
Certificates *Certificates `json:"certificates,omitempty"`
173-
174170
// RemediationTemplate is a reference to a remediation template
175171
// provided by an infrastructure provider.
176172
//

api/v1beta1/machinehealthcheck_types.go

-15
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ type MachineHealthCheckSpec struct {
6161
// +optional
6262
NodeStartupTimeout *metav1.Duration `json:"nodeStartupTimeout,omitempty"`
6363

64-
// Certificates contains the information needed to validate the health of machine certificates.
65-
// +optional
66-
Certificates *Certificates `json:"certificates,omitempty"`
67-
6864
// RemediationTemplate is a reference to a remediation template
6965
// provided by an infrastructure provider.
7066
//
@@ -77,17 +73,6 @@ type MachineHealthCheckSpec struct {
7773

7874
// ANCHOR_END: MachineHealthCHeckSpec
7975

80-
// ANCHOR: Certificates
81-
82-
// Certificates contains the information needed to validate the health of machine certificates.
83-
type Certificates struct {
84-
// ExpiresWithinDays is the number of days after which certificates is considered to be expired.
85-
// +optional
86-
ExpiresWithinDays *int `json:"expiresWithinDays,omitempty"`
87-
}
88-
89-
// ANCHOR_END: Certificates
90-
9176
// ANCHOR: UnhealthyCondition
9277

9378
// UnhealthyCondition represents a Node condition type and value with a timeout

api/v1beta1/zz_generated.deepcopy.go

-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/zz_generated.openapi.go

+2-35
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_clusterclasses.yaml

-19
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_machinehealthchecks.yaml

-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/controllers/machinehealthcheck/machinehealthcheck_targets.go

-16
Original file line numberDiff line numberDiff line change
@@ -185,22 +185,6 @@ func (t *healthCheckTarget) needsRemediation(logger logr.Logger, timeoutForMachi
185185
nextCheckTimes = append(nextCheckTimes, nextCheck)
186186
}
187187
}
188-
189-
// check certificate expiration
190-
if t.MHC.Spec.Certificates != nil && t.MHC.Spec.Certificates.ExpiresWithinDays != nil {
191-
// Check only if the certificate expiry information is available.
192-
if t.Machine.Status.CertificatesExpiryDate != nil {
193-
certificatesExpireAt := t.Machine.Status.CertificatesExpiryDate.Time
194-
// if now.Add(time.Duration(*t.MHC.Spec.Certificates.ExpiresWithinDays) * 24 * time.Hour).After(certificatesExpireAt) {
195-
if now.Add(time.Duration(*t.MHC.Spec.Certificates.ExpiresWithinDays) * time.Minute).After(certificatesExpireAt) {
196-
expiresIn := certificatesExpireAt.Sub(now)
197-
expiredInRoundedToMinutes := expiresIn.Round(time.Minute)
198-
conditions.MarkFalse(t.Machine, clusterv1.MachineHealthCheckSucceededCondition, clusterv1.CertificateExpiryReason, clusterv1.ConditionSeverityWarning, "Certificates expire in %s", expiredInRoundedToMinutes.String())
199-
logger.V(3).Info("Target is unhealthy: certificates expire in %s", expiredInRoundedToMinutes.String())
200-
return true, time.Duration(0)
201-
}
202-
}
203-
}
204188
return false, minDuration(nextCheckTimes)
205189
}
206190

internal/controllers/machinehealthcheck/machinehealthcheck_targets_test.go

-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
corev1 "k8s.io/api/core/v1"
2525
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2626
"k8s.io/client-go/tools/record"
27-
"k8s.io/utils/pointer"
2827
ctrl "sigs.k8s.io/controller-runtime"
2928
"sigs.k8s.io/controller-runtime/pkg/client"
3029
"sigs.k8s.io/controller-runtime/pkg/client/fake"
@@ -237,9 +236,6 @@ func TestHealthCheckTargets(t *testing.T) {
237236
Timeout: metav1.Duration{Duration: timeoutForUnhealthyConditions},
238237
},
239238
},
240-
Certificates: &clusterv1.Certificates{
241-
ExpiresWithinDays: pointer.Int(7),
242-
},
243239
},
244240
}
245241

internal/controllers/topology/cluster/desired_state.go

-1
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,6 @@ func computeMachineHealthCheck(healthCheckTarget client.Object, selector *metav1
859859
MaxUnhealthy: check.MaxUnhealthy,
860860
UnhealthyRange: check.UnhealthyRange,
861861
NodeStartupTimeout: check.NodeStartupTimeout,
862-
Certificates: check.Certificates,
863862
RemediationTemplate: check.RemediationTemplate,
864863
},
865864
}

util/collections/machine_filters.go

+2
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ func ShouldRolloutAfter(reconciliationTime, rolloutAfter *metav1.Time) Func {
179179
}
180180
}
181181

182+
// ShouldRolloutIfCertificatesExpireWithinMinutes returns a filter to find all machines
183+
// whose certificates will expire within expiry minutes.
182184
func ShouldRolloutIfCertificatesExpireWithinMinutes(expiry *int32) Func {
183185
return func(machine *clusterv1.Machine) bool {
184186
if expiry == nil {

util/collections/machine_filters_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func TestShouldRolloutIfCertificatesExpireWithinMinutes(t *testing.T) {
175175
g := NewWithT(t)
176176
g.Expect(collections.ShouldRolloutIfCertificatesExpireWithinMinutes(pointer.Int32(10))(nil)).To(BeFalse())
177177
})
178-
t.Run("if the machine certificate expiry infromation is not available it should return false", func(t *testing.T) {
178+
t.Run("if the machine certificate expiry information is not available it should return false", func(t *testing.T) {
179179
g := NewWithT(t)
180180
m := &clusterv1.Machine{}
181181
g.Expect(collections.ShouldRolloutIfCertificatesExpireWithinMinutes(pointer.Int32(10))(m)).To(BeFalse())

0 commit comments

Comments
 (0)