diff --git a/Makefile b/Makefile index f703a95627..1982d8714a 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ FLUENTD_IMAGE?=quay.io/openshift/origin-logging-fluentd:latest # Do a `make pre-submit` *before* submitting a PR, it ensurse generated code and tools # are up to date, source is formatted and lint-free and unit tests pass. pre-submit: tools regenerate check - echo "Git status after pre-submt (check for unexpected changes)" + @echo "Git status after pre-submit (check for unexpected changes)" git status tools: $(BINGO) $(GOLANGCI_LINT) $(JUNITREPORT) $(OPERATOR_SDK) $(OPM) @@ -158,6 +158,8 @@ redeploy: $(MAKE) undeploy $(MAKE) deploy +undeploy-all: undeploy undeploy-elasticsearch-operator + cluster-logging-catalog: cluster-logging-catalog-build cluster-logging-catalog-deploy cluster-logging-cleanup: cluster-logging-operator-uninstall cluster-logging-catalog-uninstall diff --git a/bundle/manifests/cluster-logging.v4.6.0.clusterserviceversion.yaml b/bundle/manifests/cluster-logging.v4.6.0.clusterserviceversion.yaml index 021b69834e..f77f9b6779 100755 --- a/bundle/manifests/cluster-logging.v4.6.0.clusterserviceversion.yaml +++ b/bundle/manifests/cluster-logging.v4.6.0.clusterserviceversion.yaml @@ -310,9 +310,7 @@ spec: - cluster-logging-operator env: - name: WATCH_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.annotations['olm.targetNamespaces'] + value: "" - name: POD_NAME valueFrom: fieldRef: diff --git a/docs/HACKING.md b/docs/HACKING.md index 212462281d..70bc03d705 100644 --- a/docs/HACKING.md +++ b/docs/HACKING.md @@ -32,15 +32,18 @@ Quick summary of main targets only, see below and the Makefile itself for more d To build, deploy and test the CLO image in your own cluster: * `make deploy`: Build CLO image and deploy to cluster with elasticsearch. * `make undeploy`: Undo `make deploy`. +* `make undeploy-all`: Undeploys CLO and Elasticsearch operator. To run CLO as a local process: * `make run`: Run CLO as a local process. Does not require `make deploy`. * `make debug`: Run CLO in the `dlv` debugger. -To do a complete deploy, test, cleanup cycle: +To run the e2e tests: * `make test-olm-e2e`: Run e2e tests using locally built images. * `make test-olm-e2e`: Run e2e tests using CI latest images. +NOTE: e2e tests require a clean cluster starting point, `make undeploy-all` will provide it. + ## Testing Overview There are two types of test: diff --git a/hack/testing-olm/utils b/hack/testing-olm/utils index c61b59db05..28354c9c44 100755 --- a/hack/testing-olm/utils +++ b/hack/testing-olm/utils @@ -21,7 +21,8 @@ gather_logging_resources() { oc -n ${LOGGING_NS} get ds -o wide > $outdir/daemonsets.txt 2>&1 || : oc -n ${LOGGING_NS} get pods -o wide > $outdir/pods.txt 2>&1 || : oc -n ${LOGGING_NS} get clusterlogging instance -o yaml > $outdir/clusterlogging.instance.yaml ||: - oc -n ${LOGGING_NS} get clusterlogforwarder instance -o yaml > $outdir/clusterlogforwarder.instance.yaml ||: + # Note: clusterlogforwarder is cluster scoped. + oc get clusterlogforwarder instance -o yaml > $outdir/clusterlogforwarder.instance.yaml ||: oc -n ${LOGGING_NS} extract secret/elasticsearch --to=$outdir ||: oc -n ${LOGGING_NS} extract configmap/fluentd --to=$outdir ||: diff --git a/manifests/4.6/cluster-logging.v4.6.0.clusterserviceversion.yaml b/manifests/4.6/cluster-logging.v4.6.0.clusterserviceversion.yaml index 581fc363ec..327e3c4e28 100755 --- a/manifests/4.6/cluster-logging.v4.6.0.clusterserviceversion.yaml +++ b/manifests/4.6/cluster-logging.v4.6.0.clusterserviceversion.yaml @@ -159,9 +159,9 @@ spec: - type: SingleNamespace supported: true - type: MultiNamespace - supported: false + supported: true - type: AllNamespaces - supported: false + supported: true install: strategy: deployment spec: @@ -243,6 +243,16 @@ spec: clusterPermissions: - serviceAccountName: cluster-logging-operator rules: + - apiGroups: + - "logging.openshift.io" + resources: + - clusterlogforwarders + - clusterlogforwarders/status + verbs: + - get + - list + - watch + - update - apiGroups: - console.openshift.io resources: @@ -316,9 +326,7 @@ spec: - cluster-logging-operator env: - name: WATCH_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.annotations['olm.targetNamespaces'] + value: "" - name: POD_NAME valueFrom: fieldRef: diff --git a/manifests/4.6/logging.openshift.io_clusterlogforwarders_crd.yaml b/manifests/4.6/logging.openshift.io_clusterlogforwarders_crd.yaml index c8c7dd55c4..0408f7344d 100644 --- a/manifests/4.6/logging.openshift.io_clusterlogforwarders_crd.yaml +++ b/manifests/4.6/logging.openshift.io_clusterlogforwarders_crd.yaml @@ -11,7 +11,7 @@ spec: shortNames: - clf singular: clusterlogforwarder - scope: Namespaced + scope: Cluster versions: - name: v1 schema: diff --git a/olm_deploy/subscription/operator-group.yaml b/olm_deploy/subscription/operator-group.yaml index c9815b2c64..bccd821da4 100644 --- a/olm_deploy/subscription/operator-group.yaml +++ b/olm_deploy/subscription/operator-group.yaml @@ -4,6 +4,6 @@ metadata: name: cluster-logging-operator namespace: ${CLUSTER_LOGGING_OPERATOR_NAMESPACE} spec: - targetNamespaces: - - ${CLUSTER_LOGGING_OPERATOR_NAMESPACE} + targetNamespaces: [] + diff --git a/pkg/apis/logging/v1/cluster_log_forwarder_types.go b/pkg/apis/logging/v1/cluster_log_forwarder_types.go index 05ace8a47d..87f2151ae9 100644 --- a/pkg/apis/logging/v1/cluster_log_forwarder_types.go +++ b/pkg/apis/logging/v1/cluster_log_forwarder_types.go @@ -9,7 +9,7 @@ const ClusterLogForwarderKind = "ClusterLogForwarder" // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object // +kubebuilder:subresource:status -// +kubebuilder:resource:shortName=clf +// +kubebuilder:resource:shortName=clf,scope=Cluster // ClusterLogForwarder is an API to configure forwarding logs. // diff --git a/pkg/k8shandler/reconciler.go b/pkg/k8shandler/reconciler.go index 98620ce3fb..e998687ce8 100644 --- a/pkg/k8shandler/reconciler.go +++ b/pkg/k8shandler/reconciler.go @@ -183,12 +183,12 @@ func (clusterRequest *ClusterLoggingRequest) getProxyConfig() *configv1.Proxy { } func (clusterRequest *ClusterLoggingRequest) getLogForwarder() *logging.ClusterLogForwarder { - nsname := types.NamespacedName{Name: constants.SingletonName, Namespace: constants.OpenshiftNS} + name := types.NamespacedName{Name: constants.SingletonName} // Cluster scope, no namespace forwarder := &logging.ClusterLogForwarder{} logger.Debug("clusterlogforwarder-controller fetching LF instance") - if err := clusterRequest.Client.Get(context.TODO(), nsname, forwarder); err != nil { + if err := clusterRequest.Client.Get(context.TODO(), name, forwarder); err != nil { if !apierrors.IsNotFound(err) { - fmt.Printf("Encountered unexpected error getting %v", nsname) + fmt.Printf("Encountered unexpected error getting %v", name) } } diff --git a/test/helpers/framework.go b/test/helpers/framework.go index 5553d85495..b30b0477bf 100644 --- a/test/helpers/framework.go +++ b/test/helpers/framework.go @@ -29,7 +29,7 @@ import ( const ( clusterLoggingURI = "apis/logging.openshift.io/v1/namespaces/openshift-logging/clusterloggings" - clusterlogforwarderURI = "apis/logging.openshift.io/v1/namespaces/openshift-logging/clusterlogforwarders" + clusterlogforwarderURI = "apis/logging.openshift.io/v1/clusterlogforwarders" DefaultCleanUpTimeout = 60.0 * 2 )