From 0d696dcc85338c3f38e1ee7fcd332473542f7594 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Tue, 5 Oct 2021 08:22:04 -0500 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Markus Lehtonen --- .../nodefeaturediscovery_controller.go | 4 ++-- controllers/nodefeaturediscovery_status.go | 22 +++++++------------ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/controllers/nodefeaturediscovery_controller.go b/controllers/nodefeaturediscovery_controller.go index 9adf7d0b..8f51ca36 100644 --- a/controllers/nodefeaturediscovery_controller.go +++ b/controllers/nodefeaturediscovery_controller.go @@ -199,14 +199,14 @@ func (r *NodeFeatureDiscoveryReconciler) Reconcile(ctx context.Context, req ctrl if rstatus, err := r.getClusterRoleBindingConditions(ctx); err != nil { return r.updateDegradedCondition(instance, conditionFailedGettingNFDClusterRoleBinding, err.Error()) } else if rstatus.isDegraded { - return r.updateDegradedCondition(instance, conditionNFDClusterRoleBindingDegraded, "nfd ClusterRole has been degraded") + return r.updateDegradedCondition(instance, conditionNFDClusterRoleBindingDegraded, "nfd ClusterRoleBinding has been degraded") } // Check the status of the NFD Operator role binding if rstatus, err := r.getRoleBindingConditions(ctx); err != nil { return r.updateDegradedCondition(instance, conditionFailedGettingNFDRoleBinding, err.Error()) } else if rstatus.isDegraded { - return r.updateDegradedCondition(instance, conditionNFDRoleBindingDegraded, "nfd ClusterRoleBinding has been degraded") + return r.updateDegradedCondition(instance, conditionNFDRoleBindingDegraded, "nfd RoleBinding has been degraded") } // Check the status of the NFD Operator Service diff --git a/controllers/nodefeaturediscovery_status.go b/controllers/nodefeaturediscovery_status.go index 980d094f..b3f8753e 100644 --- a/controllers/nodefeaturediscovery_status.go +++ b/controllers/nodefeaturediscovery_status.go @@ -1,5 +1,5 @@ /* -Copyright 2020-2021 The Kubernetes Authors. +Copyright 2021 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -157,8 +157,8 @@ func (r *NodeFeatureDiscoveryReconciler) updateProgressingCondition(nfd *nfdv1.N return reconcile.Result{Requeue: true}, nil } -// getAvailableConditions returns a list of conditionsv1.Condition objects and marks -// every condition as FALSE except for conditionsv1.ConditionAvailable so that the +// getAvailableConditions returns a list of Condition objects and marks +// every condition as FALSE except for ConditionAvailable so that the // reconciler can determine that the resource is available. func (r *NodeFeatureDiscoveryReconciler) getAvailableConditions() []metav1.Condition { now := time.Now() @@ -217,8 +217,8 @@ func (r *NodeFeatureDiscoveryReconciler) getDegradedConditions(reason string, me } } -// getProgressingConditions returns a list of conditions.Condition objects and marks -// every condition as FALSE except for conditions.ConditionProgressing so that the +// getProgressingConditions returns a list of Condition objects and marks +// every condition as FALSE except for ConditionProgressing so that the // reconciler can determine that the resource is progressing. func (r *NodeFeatureDiscoveryReconciler) getProgressingConditions(reason string, message string) []metav1.Condition { now := time.Now() @@ -251,7 +251,6 @@ func (r *NodeFeatureDiscoveryReconciler) getProgressingConditions(reason string, // The status of the resource (available, upgradeable, progressing, or // degraded). type Status struct { - // Is the resource available, upgradable, etc.? isAvailable bool isUpgradeable bool @@ -401,7 +400,6 @@ func (r *NodeFeatureDiscoveryReconciler) getWorkerConfigConditions(n NFD) (Statu // getRoleConditions gets the current status of a Role. If an error occurs, this // function returns the corresponding error message func (r *NodeFeatureDiscoveryReconciler) getRoleConditions(ctx context.Context) (Status, error) { - // Initialize status to 'Degraded' status := initializeDegradedStatus() @@ -420,10 +418,9 @@ func (r *NodeFeatureDiscoveryReconciler) getRoleConditions(ctx context.Context) return status, nil } -// getDaemonRoleBindingConditions gets the current status of a RoleBinding. If an error +// getRoleBindingConditions gets the current status of a RoleBinding. If an error // occurs, this function returns the corresponding error message func (r *NodeFeatureDiscoveryReconciler) getRoleBindingConditions(ctx context.Context) (Status, error) { - // Initialize status to 'Degraded' status := initializeDegradedStatus() @@ -445,7 +442,6 @@ func (r *NodeFeatureDiscoveryReconciler) getRoleBindingConditions(ctx context.Co // geClusterRoleConditions gets the current status of a ClusterRole. If an error // occurs, this function returns the corresponding error message func (r *NodeFeatureDiscoveryReconciler) getClusterRoleConditions(ctx context.Context) (Status, error) { - // Initialize status to 'Degraded' status := initializeDegradedStatus() @@ -467,7 +463,6 @@ func (r *NodeFeatureDiscoveryReconciler) getClusterRoleConditions(ctx context.Co // getClusterRoleBindingConditions gets the current status of a ClusterRoleBinding. // If an error occurs, this function returns the corresponding error message func (r *NodeFeatureDiscoveryReconciler) getClusterRoleBindingConditions(ctx context.Context) (Status, error) { - // Initialize status to 'Degraded' status := initializeDegradedStatus() @@ -488,13 +483,13 @@ func (r *NodeFeatureDiscoveryReconciler) getClusterRoleBindingConditions(ctx con } // getWorkerServiceAccountConditions is a wrapper around "getServiceAccountConditions" for -// worker service accounts +// worker service account. func (r *NodeFeatureDiscoveryReconciler) getWorkerServiceAccountConditions(ctx context.Context) (Status, error) { return r.getServiceAccountConditions(ctx, nfdWorkerApp) } // getMasterServiceAccountConditions is a wrapper around "getServiceAccountConditions" for -// master service accounts +// master service account. func (r *NodeFeatureDiscoveryReconciler) getMasterServiceAccountConditions(ctx context.Context) (Status, error) { return r.getServiceAccountConditions(ctx, nfdMasterApp) } @@ -502,7 +497,6 @@ func (r *NodeFeatureDiscoveryReconciler) getMasterServiceAccountConditions(ctx c // getServiceAccountConditions gets the current status of a ServiceAccount. If an error // occurs, this function returns the corresponding error message func (r *NodeFeatureDiscoveryReconciler) getServiceAccountConditions(ctx context.Context, nfdAppName string) (Status, error) { - // Initialize status to 'Degraded' status := initializeDegradedStatus()