Skip to content

Commit

Permalink
hostedcluster: set condition if OldestKubeletVersion < MinimumKubelet…
Browse files Browse the repository at this point in the history
…Version

Signed-off-by: Peter Hunt <pehunt@redhat.com>
  • Loading branch information
haircommander committed Nov 22, 2024
1 parent 66f550a commit f346983
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/s3/s3iface"
"github.com/blang/semver"
semverv4 "github.com/blang/semver/v4"
"github.com/go-logr/logr"
"github.com/google/uuid"
configv1 "github.com/openshift/api/config/v1"
Expand Down Expand Up @@ -111,6 +112,7 @@ import (
"github.com/openshift/hypershift/support/supportedversion"
"github.com/openshift/hypershift/support/upsert"
hyperutil "github.com/openshift/hypershift/support/util"
nodelib "github.com/openshift/library-go/pkg/apiserver/node"
)

const (
Expand Down Expand Up @@ -4130,6 +4132,10 @@ func (r *HostedClusterReconciler) validateConfigAndClusterCapabilities(ctx conte
errs = append(errs, err...)
}

if err := r.validateMinimumKubeletVersion(ctx, hc); err != nil {
errs = append(errs, err)
}

return utilerrors.NewAggregate(errs)
}

Expand Down Expand Up @@ -4173,6 +4179,30 @@ func (r *HostedClusterReconciler) validateUserCAConfigMaps(ctx context.Context,
return errs
}

// validateMinimumKubeletVersion
func (r *HostedClusterReconciler) validateMinimumKubeletVersion(ctx context.Context, hcluster *hyperv1.HostedCluster) error {
if hcluster.Spec.Configuration == nil || hcluster.Spec.Configuration.Node == nil {
return nil
}
specifiedMinVersion := hcluster.Spec.Configuration.Node.MinimumKubeletVersion
if specifiedMinVersion == "" {
return nil
}

if hcluster.Status.OldestKubeletVersion == nil || *hcluster.Status.OldestKubeletVersion == "" {
// No Kubelets are running in the cluster yet, this is safe?
return nil
}
v, err := semverv4.Parse(specifiedMinVersion)
if err != nil {
return fmt.Errorf("invalid minimumKubeletVersion: %s %v", specifiedMinVersion, err)
}
if err := nodelib.IsKubeletVersionTooOld(*hcluster.Status.OldestKubeletVersion, &v); err != nil {
return fmt.Errorf("validating failed for %s: %v", specifiedMinVersion, err)
}
return nil
}

func (r *HostedClusterReconciler) validateReleaseImage(ctx context.Context, hc *hyperv1.HostedCluster, releaseProvider releaseinfo.ProviderWithOpenShiftImageRegistryOverrides) error {
if _, exists := hc.Annotations[hyperv1.SkipReleaseImageValidation]; exists {
return nil
Expand Down

0 comments on commit f346983

Please sign in to comment.