Skip to content

Commit

Permalink
Merge pull request #135 from appuio/fix/zone-k8s-version-controller-logs
Browse files Browse the repository at this point in the history
Fix log messages for Zone K8s version controller
  • Loading branch information
simu authored Nov 15, 2024
2 parents 54c15d4 + cd8f613 commit 29e04f4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions controllers/zonek8sversion_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (r *ZoneK8sVersionReconciler) Reconcile(ctx context.Context, req ctrl.Reque
return ctrl.Result{}, err
}

l.Info("OCP current version", "version", ocpVersion)
l.Info("OCP current version", "version", formatVersion(ocpVersion))

// We don't use client-go's ServerVersion() so we get context support
body, err := r.RESTClient.Get().AbsPath("/version").Do(ctx).Raw()
Expand All @@ -71,7 +71,7 @@ func (r *ZoneK8sVersionReconciler) Reconcile(ctx context.Context, req ctrl.Reque
if err != nil {
return ctrl.Result{}, err
}
l.Info("K8s current version", "version", k8sVersion)
l.Info("K8s current version", "version", formatVersion(&k8sVersion))

// List zones by label because we don't enforce any naming conventions
// for the Zone objects on the control-api cluster.
Expand All @@ -91,10 +91,8 @@ func (r *ZoneK8sVersionReconciler) Reconcile(ctx context.Context, req ctrl.Reque

var errs []error
for _, z := range zones.Items {
z.Data.Features[kubernetesVersionFeatureKey] =
fmt.Sprintf("%s.%s", k8sVersion.Major, k8sVersion.Minor)
z.Data.Features[openshiftVersionFeatureKey] =
fmt.Sprintf("%s.%s", ocpVersion.Major, ocpVersion.Minor)
z.Data.Features[kubernetesVersionFeatureKey] = formatVersion(&k8sVersion)
z.Data.Features[openshiftVersionFeatureKey] = formatVersion(ocpVersion)
if err := r.ForeignClient.Update(ctx, &z); err != nil {
errs = append(errs, err)
}
Expand Down Expand Up @@ -136,3 +134,7 @@ func extractOpenShiftVersion(cv *configv1.ClusterVersion) (*version.Info, error)
}
return &version, nil
}

func formatVersion(v *version.Info) string {
return fmt.Sprintf("%s.%s", v.Major, v.Minor)
}

0 comments on commit 29e04f4

Please sign in to comment.