Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Markus Lehtonen <markus.lehtonen@intel.com>
  • Loading branch information
ArangoGutierrez and marquiz committed Oct 5, 2021
1 parent 4712346 commit 0d696dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
4 changes: 2 additions & 2 deletions controllers/nodefeaturediscovery_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 8 additions & 14 deletions controllers/nodefeaturediscovery_status.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand All @@ -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()

Expand All @@ -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()

Expand All @@ -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()

Expand All @@ -488,21 +483,20 @@ 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)
}

// 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()

Expand Down

0 comments on commit 0d696dc

Please sign in to comment.