Review feedback
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
This commit is contained in:
committed by
Jefftree
parent
e0c6987ca8
commit
68226b0501
@@ -96,7 +96,7 @@ type LeaseList struct {
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
// LeaseCandidate defines a candidate for a lease object.
|
||||
// LeaseCandidate defines a candidate for a Lease object.
|
||||
// Candidates are created such that coordinated leader election will pick the best leader from the list of candidates.
|
||||
type LeaseCandidate struct {
|
||||
metav1.TypeMeta
|
||||
@@ -109,6 +109,7 @@ type LeaseCandidate struct {
|
||||
type LeaseCandidateSpec struct {
|
||||
// LeaseName is the name of the lease for which this candidate is contending.
|
||||
// This field is immutable.
|
||||
// +required
|
||||
LeaseName string
|
||||
// PingTime is the last time that the server has requested the LeaseCandidate
|
||||
// to renew. It is only done during leader election to check if any
|
||||
@@ -120,16 +121,18 @@ type LeaseCandidateSpec struct {
|
||||
// Any time a Lease needs to do leader election, the PingTime field
|
||||
// is updated to signal to the LeaseCandidate that they should update
|
||||
// the RenewTime.
|
||||
// Old LeaseCandidate objects are also garbage collected if it has been hours since the last renew.
|
||||
// Old LeaseCandidate objects are also garbage collected if it has been hours
|
||||
// since the last renew. The PingTime field is updated regularly to prevent
|
||||
// garbage collection for still active LeaseCandidates.
|
||||
// +optional
|
||||
RenewTime *metav1.MicroTime
|
||||
// BinaryVersion is the binary version. It must be in a semver format without leadig `v`.
|
||||
// This field is required when Strategy is "OldestEmulationVersion"
|
||||
// BinaryVersion is the binary version. It must be in a semver format without leading `v`.
|
||||
// This field is required when strategy is "OldestEmulationVersion"
|
||||
// +optional
|
||||
BinaryVersion string
|
||||
// EmulationVersion is the emulation version. It must be in a semver format without leading `v`.
|
||||
// EmulationVersion must be less than or equal to BinaryVersion.
|
||||
// This field is required when Strategy is "OldestEmulationVersion"
|
||||
// This field is required when strategy is "OldestEmulationVersion"
|
||||
// +optional
|
||||
EmulationVersion string
|
||||
// PreferredStrategies indicates the list of strategies for picking the leader for coordinated leader election.
|
||||
@@ -137,7 +140,7 @@ type LeaseCandidateSpec struct {
|
||||
// leader election to make a decision about the final election strategy. This follows as
|
||||
// - If all clients have strategy X as the first element in this list, strategy X will be used.
|
||||
// - If a candidate has strategy [X] and another candidate has strategy [Y, X], Y supersedes X and strategy Y
|
||||
// will be used
|
||||
// will be used.
|
||||
// - If a candidate has strategy [X, Y] and another candidate has strategy [Y, X], this is a user error and leader
|
||||
// election will not operate the Lease until resolved.
|
||||
// (Alpha) Using this field requires the CoordinatedLeaderElection feature gate to be enabled.
|
||||
|
||||
@@ -124,11 +124,11 @@ func ValidateLeaseCandidateSpec(spec *coordination.LeaseCandidateSpec, fldPath *
|
||||
allErrs = append(allErrs, field.Invalid(fld, spec.BinaryVersion, "must be greater than or equal to `emulationVersion`"))
|
||||
}
|
||||
|
||||
strategySeen := make(map[coordination.CoordinatedLeaseStrategy]bool)
|
||||
|
||||
if len(spec.PreferredStrategies) > 0 {
|
||||
for i, strategy := range spec.PreferredStrategies {
|
||||
fld := fldPath.Child("preferredStrategies").Index(i)
|
||||
|
||||
strategySeen := make(map[coordination.CoordinatedLeaseStrategy]bool)
|
||||
if _, ok := strategySeen[strategy]; ok {
|
||||
allErrs = append(allErrs, field.Duplicate(fld, strategy))
|
||||
} else {
|
||||
@@ -153,7 +153,7 @@ func ValidateLeaseCandidateSpec(spec *coordination.LeaseCandidateSpec, fldPath *
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateLeaseStrategy validates the Strategy field in both the Lease and LeaseCandidate
|
||||
// ValidateCoordinatedLeaseStrategy validates the Strategy field in both the Lease and LeaseCandidate
|
||||
func ValidateCoordinatedLeaseStrategy(strategy coordination.CoordinatedLeaseStrategy, fldPath *field.Path) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user