Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-5.5] LOG-3301:Add watcher for Elasticsearch object #1756

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion controllers/clusterlogging/clusterlogging_controller.go
Expand Up @@ -2,7 +2,7 @@ package clusterlogging

import (
"context"

v1 "github.com/openshift/elasticsearch-operator/apis/logging/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/event"
Expand Down Expand Up @@ -154,6 +154,10 @@ func (r *ReconcileClusterLogging) SetupWithManager(mgr ctrl.Manager) error {
controllerBuilder := ctrl.NewControllerManagedBy(mgr).
Watches(&source.Kind{Type: &loggingv1.ClusterLogging{}}, &handler.EnqueueRequestForObject{}).
Watches(&source.Kind{Type: &loggingv1.ClusterLogForwarder{}}, &handler.EnqueueRequestForObject{}).
Watches(&source.Kind{Type: &v1.Elasticsearch{}}, &handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &loggingv1.ClusterLogging{},
}).
Watches(&source.Kind{Type: &corev1.Service{}}, &handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &loggingv1.ClusterLogging{},
Expand Down
4 changes: 2 additions & 2 deletions internal/k8shandler/clusterloggingrequest.go
Expand Up @@ -36,7 +36,7 @@ func (clusterRequest *ClusterLoggingRequest) IncludesManagedStorage() bool {
return clusterRequest.Cluster != nil && clusterRequest.Cluster.Spec.LogStore != nil
}

//true if equals "Managed" or empty
// true if equals "Managed" or empty
func (clusterRequest *ClusterLoggingRequest) isManaged() bool {
return clusterRequest.Cluster.Spec.ManagementState == logging.ManagementStateManaged ||
clusterRequest.Cluster.Spec.ManagementState == ""
Expand All @@ -47,7 +47,7 @@ func (clusterRequest *ClusterLoggingRequest) Create(object client.Object) error
return err
}

//Update the runtime Object or return error
// Update the runtime Object or return error
func (clusterRequest *ClusterLoggingRequest) Update(object client.Object) (err error) {
if err = clusterRequest.Client.Update(context.TODO(), object); err != nil {
log.Error(err, "Error updating ", object.GetObjectKind())
Expand Down
2 changes: 1 addition & 1 deletion internal/k8shandler/status.go
Expand Up @@ -69,7 +69,7 @@ func (clusterRequest *ClusterLoggingRequest) getElasticsearchStatus() ([]logging
}

err := clusterRequest.List(map[string]string{}, esList)
status := []logging.ElasticsearchStatus{}
var status []logging.ElasticsearchStatus

if err != nil {
return status, fmt.Errorf("Unable to get Elasticsearches: %v", err)
Expand Down