Skip to content

Commit

Permalink
Add logic to set the operator's status in the NFD CR
Browse files Browse the repository at this point in the history
Add logic that sets the operator's status in the NFD CR based on
whether one or more of NFD's resources is: degraded, progressing,
upgradeable, or available. Also add a "applyComponents" function
to simplify readability.

Signed-off-by: Carlos Eduardo Arango Gutierrez <carangog@redhat.com>
Co-Authored-by: Courtney Pacheco <cpacheco@redhat.com>
Co-authored-by: Markus Lehtonen <markus.lehtonen@intel.com>
  • Loading branch information
3 people committed Oct 1, 2021
1 parent 84fa1b5 commit 437f8da
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions controllers/nodefeaturediscovery_status.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
Copyright 2020-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.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers

import (
Expand All @@ -14,14 +30,12 @@ import (
)

// nodeType is either 'worker' or 'master'
type nodeType int
type nfdInstanceType string

const (
worker nodeType = 0
master nodeType = 1
nfdNamespace = "node-feature-discovery-operator"
workerName = "nfd-worker"
masterName = "nfd-master"
nfdNamespace = "node-feature-discovery-operator"
workerInstance nfdInstanceType = "nfd-worker"
masterInstance nfdInstanceType = "nfd-master"
)

const (
Expand Down Expand Up @@ -130,15 +144,8 @@ func (r *NodeFeatureDiscoveryReconciler) updateStatus(nfd *nfdv1.NodeFeatureDisc

// updateDegradedCondition is used to mark a given resource as "degraded" so that
// the reconciler can take steps to rectify the situation.
func (r *NodeFeatureDiscoveryReconciler) updateDegradedCondition(nfd *nfdv1.NodeFeatureDiscovery, condition string, conditionErr error) (ctrl.Result, error) {

// It is already assumed that the resource has been degraded, so the first
// step is to gather the correct list of conditions.
var conditionErrMsg string = "Degraded"
if conditionErr != nil {
conditionErrMsg = conditionErr.Error()
}
degradedCondition := r.getDegradedConditions(condition, conditionErrMsg)
func (r *NodeFeatureDiscoveryReconciler) updateDegradedCondition(nfd *nfdv1.NodeFeatureDiscovery, reason, message string) (ctrl.Result, error) {
degradedCondition := r.getDegradedConditions(reason, message)
if err := r.updateStatus(nfd, degradedCondition); err != nil {
return reconcile.Result{}, err
}
Expand Down

0 comments on commit 437f8da

Please sign in to comment.