Skip to content

Commit

Permalink
Merge pull request #298 from jcantrill/1768688
Browse files Browse the repository at this point in the history
Bug 1768688: Enable status for CRDs
  • Loading branch information
openshift-merge-robot committed Nov 15, 2019
2 parents e02c91f + 5405b48 commit c689079
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
6 changes: 3 additions & 3 deletions hack/undeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

source "$(dirname $0)/common"

oc delete ns openshift-logging --force --ignore-not-found --grace-period=0
oc delete -n openshift is origin-cluster-logging-operator --force --ignore-not-found --grace-period=0
oc delete -n openshift bc cluster-logging-operator --force --ignore-not-found --grace-period=0
oc delete ns openshift-logging --force --ignore-not-found --grace-period=0 ||:
oc delete -n openshift is origin-cluster-logging-operator --force --ignore-not-found --grace-period=0 ||:
oc delete -n openshift bc cluster-logging-operator --force --ignore-not-found --grace-period=0||:
2 changes: 2 additions & 0 deletions manifests/4.3/cluster-loggings.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,5 @@ spec:
- schedule
required:
- type
subresources:
status: {}
2 changes: 2 additions & 0 deletions manifests/4.3/collectors.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ spec:
description: Define which Nodes the Pods are scheduled on.
required:
- type
subresources:
status: {}
8 changes: 5 additions & 3 deletions manifests/4.3/logforwardings.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ spec:
type: string
outputRefs:
description: The name of outputs to send the source logs
items:
items:
type: string
type: array
inputType:
Expand All @@ -71,8 +71,10 @@ spec:
- name
- source
- outputRefs
type: array
type: array
required:
- outputs
- pipelines

subresources:
status: {}

11 changes: 11 additions & 0 deletions pkg/controller/forwarding/forwarding_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
loggingv1 "github.com/openshift/cluster-logging-operator/pkg/apis/logging/v1"
logforwarding "github.com/openshift/cluster-logging-operator/pkg/apis/logging/v1alpha1"
"github.com/openshift/cluster-logging-operator/pkg/k8shandler"
"github.com/openshift/cluster-logging-operator/pkg/logger"

"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -76,10 +77,13 @@ var (
// The Controller will requeue the Request to be processed again if the returned error is non-nil or
// Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
func (r *ReconcileForwarding) Reconcile(request reconcile.Request) (reconcile.Result, error) {
logger.Debugf("logforwarding-controller Reconciling: %v", request)
// Fetch the LogForwarding instance
instance := &logforwarding.LogForwarding{}
logger.Debug("logforwarding-controller fetching LF instance")
err := r.client.Get(context.TODO(), request.NamespacedName, instance)
if err != nil {
logger.Debugf("logforwarding-controller Error getting instance. It will be retried if other then 'NotFound': %v", err)
if errors.IsNotFound(err) {
// Request object not found, could have been deleted after reconcile request.
// Owned objects are automatically garbage collected. For additional cleanup logic use finalizers.
Expand All @@ -89,6 +93,7 @@ func (r *ReconcileForwarding) Reconcile(request reconcile.Request) (reconcile.Re
// Error reading the object - requeue the request.
return reconcile.Result{}, err
}
logger.Debugf("logforwarding-controller fetched LF instance: %v", instance)

//check for instancename and then update status
var reconcileErr error = nil
Expand All @@ -97,22 +102,28 @@ func (r *ReconcileForwarding) Reconcile(request reconcile.Request) (reconcile.Re
} else {
instance.Status = logforwarding.NewForwardingStatus(logforwarding.LogForwardingStateAccepted, logforwarding.LogForwardingReasonName, "")

logger.Debug("logforwarding-controller fetching ClusterLogging instance...")
clInstance := &loggingv1.ClusterLogging{}
clName := types.NamespacedName{Name: singletonName, Namespace: openshiftNS}
err = r.client.Get(context.TODO(), clName, clInstance)
if err != nil && !errors.IsNotFound(err) {
// Request object not found, could have been deleted after reconcile request.
// Owned objects are automatically garbage collected. For additional cleanup logic use finalizers.
// Return and don't requeue
logger.Debugf("logforwarding-controller error fetching ClusterLogging instance: %v")
return reconcile.Result{}, err
}

logger.Debug("logforwarding-controller calling ClusterLogging reconciler...")
reconcileErr = k8shandler.Reconcile(clInstance, instance, r.client)
}

logger.Debugf("logforwarding-controller updating status of instance: %v", instance)
if err = r.client.Status().Update(context.TODO(), instance); err != nil {
logger.Debugf("logforwarding-controller error updating status: %v", err)
return reconcile.Result{}, err
}

logger.Debugf("logforwarding-controller returning %v, error: %v", reconcileResult, reconcileErr)
return reconcileResult, reconcileErr
}
2 changes: 1 addition & 1 deletion pkg/k8shandler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func Reconcile(requestCluster *logging.ClusterLogging, forwarding *logforwarding.LogForwarding, requestClient client.Client) (err error) {
logger.Debugf("Reconciling %v", requestCluster)
logger.Debugf("Reconciling cl: %v, forwarding: %v", requestCluster, forwarding)
clusterLoggingRequest := ClusterLoggingRequest{
client: requestClient,
cluster: requestCluster,
Expand Down

0 comments on commit c689079

Please sign in to comment.