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

feat: support logging as ui-plugin #477

Merged
merged 2 commits into from
Jun 6, 2024

Conversation

xperimental
Copy link
Contributor

@xperimental xperimental commented May 8, 2024

Implementation for COO-147.

Copy link

openshift-ci bot commented May 8, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

cmd/operator/main.go Outdated Show resolved Hide resolved
pkg/controllers/uiplugin/compatibility_matrix.go Outdated Show resolved Hide resolved
pkg/controllers/uiplugin/logging.go Show resolved Hide resolved
@xperimental xperimental changed the title Implement UIPlugin for logging-view-plugin feat: support logging as ui-plugin May 14, 2024
@xperimental xperimental force-pushed the logging-ui branch 2 times, most recently from fa45ab6 to a2bff9f Compare May 14, 2024 16:59
@xperimental
Copy link
Contributor Author

Cleaned up the PR to only contain the changes needed for the logging-ui. Are we ok with the API of UIPlugin as-is? If yes, I'd remove the draft status.

@xperimental xperimental marked this pull request as ready for review May 15, 2024 15:08
@xperimental xperimental requested a review from a team as a code owner May 15, 2024 15:08
@xperimental xperimental requested review from jan--f and slashpai and removed request for a team May 15, 2024 15:08
Copy link
Contributor

@JoaoBraveCoding JoaoBraveCoding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from my side lgtm (didn't manually test it)

Copy link
Contributor

@JoaoBraveCoding JoaoBraveCoding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on OpenShift and it works as expected 👍 However I had to manually add the "openshift.enabled"... I'm guessing that in the future there will be a version on OLM with this flag already enabled.

To test:

  • Install loki-operator using the console UI
  • Install cluster-logging operator using version in https://github.com/xperimental/cluster-logging-operator/tree/block-console-5.9
  • Install observability-operator using this PR
  • Edit CSV to add "--openshift.enabled"
  • Create ClusterLogging resource
  • Create ClusterLogForwarder resource
  • Create LokiStack resource called "lokistack-dev"
  • Create UIPlugin with type "logging" and pass the name "lokistack-dev"

Copy link

@periklis periklis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general looks good to me besides some suggestions to improve handling and clarifying missing fields. We certainly need to add support for nodeSelector and tolerations to complete this work and stay in course with OpenShift Logging releases.

pkg/apis/uiplugin/v1alpha1/types.go Outdated Show resolved Hide resolved
pkg/apis/uiplugin/v1alpha1/types.go Outdated Show resolved Hide resolved
Comment on lines 82 to 114
func marshalLoggingPluginConfig(cfg *uiv1alpha1.LoggingConfig) (string, error) {
if cfg.LogsLimit == 0 && cfg.Timeout == "" {
return "", nil
}

pluginCfg := struct {
LogsLimit int `yaml:"logsLimit"`
Timeout string `yaml:"timeout"`
}{
LogsLimit: cfg.LogsLimit,
Timeout: cfg.Timeout,
}

buf := &bytes.Buffer{}
if err := yaml.NewEncoder(buf).Encode(pluginCfg); err != nil {
return "", err
}

return buf.String(), nil
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we re-think this a little bit? I suggest to decouple from the logging-view-plugin's ConfigMap fields and use something because some might simply carry unwanted baggage (e.g. logLimit vs. logsLimit) which we would carry in our API too.

pkg/apis/uiplugin/v1alpha1/types.go Show resolved Hide resolved
pkg/apis/uiplugin/v1alpha1/types.go Outdated Show resolved Hide resolved
pkg/apis/uiplugin/v1alpha1/types.go Outdated Show resolved Hide resolved
pkg/apis/uiplugin/v1alpha1/types.go Show resolved Hide resolved
@xperimental
Copy link
Contributor Author

Some updates from the code-review comments. Not done with all the changes yet, though. Notably, the additional options for the logging-view-plugin and the nodeSelector/tolerations part is still missing.

@xperimental xperimental force-pushed the logging-ui branch 4 times, most recently from 3da8eb7 to 509b415 Compare May 27, 2024 19:33
Copy link
Contributor Author

@xperimental xperimental left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the PR for the code-review feedback again.

While testing for the timeout in the ConfigMap I noticed that a changing ConfigMap also mandates a redeploy of the Deployment, so I added code for hashing the ConfigMap's contents so that restarts happen automatically.


One open question for me is, whether the options passed to the logging-view-plugin need another "level of indentation", especially if we plan to increase the number of options from the two that are currently available.

To illustrate my point: Currently the configuration would look like this:

apiVersion: observability.openshift.io/v1alpha1
kind: UIPlugin
metadata:
  name: ui-logging
spec:
  type: Logging
  logging:
    lokiStack:
      name: lokistack-dev
    timeout: 3m
    logsLimit: 1000

And with another level of indentation/grouping it would look like this (think of frontend as a placeholder, I couldn't think of anything better so far):

apiVersion: observability.openshift.io/v1alpha1
kind: UIPlugin
metadata:
  name: ui-logging
spec:
  type: Logging
  logging:
    lokiStack:
      name: lokistack-dev
    frontend:
      timeout: 3m
      logsLimit: 1000

pkg/apis/uiplugin/v1alpha1/types.go Show resolved Hide resolved
pkg/apis/uiplugin/v1alpha1/types.go Show resolved Hide resolved
pkg/apis/uiplugin/v1alpha1/types.go Outdated Show resolved Hide resolved
pkg/apis/uiplugin/v1alpha1/types.go Show resolved Hide resolved
pkg/controllers/uiplugin/components.go Outdated Show resolved Hide resolved
pkg/controllers/uiplugin/components.go Outdated Show resolved Hide resolved
@xperimental
Copy link
Contributor Author

Two points of additional information:

  • Added an implementation with "separate struct for frontend configuration" (see previous comment) in a separate branch.
  • The 5.9 branch of Cluster Logging Operator has the "Cluster Observability Operator awareness" PR merged, so while there is no released version of that yet, Joao's instructions are simplified to using the release-5.9 branch of CLO for testing.

Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the perseverance! I'll take a deeper look tomorrow (with local testing) but I don't see any blocker.

pkg/apis/uiplugin/v1alpha1/types.go Show resolved Hide resolved
Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 final minor comments which can be addressed in a subsequent PR. Happy to merge this one after you've resolved the conflicts.

pkg/apis/uiplugin/v1alpha1/types.go Show resolved Hide resolved
// +kubebuilder:validation:Required
LokiStack LokiStackReference `json:"lokiStack"`

// LogsLimit is the max number of entries returned for a query.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) Can we document what the zero value means? Is it equivalent to no limits?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logging-view-plugin defines its own default, which is used when no limit is specified (= "when it is 0"). If I am interpreting this correctly there's a default of 100 for normal queries and 200 for tail.

@xperimental
Copy link
Contributor Author

Rebase completed ✅

Any feedback on the question whether we should put the options for the frontend in a separate struct?

Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@simonpasquier
Copy link
Contributor

/approve

Copy link

openshift-ci bot commented Jun 6, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JoaoBraveCoding, periklis, simonpasquier, xperimental

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 9ecc7fc into rhobs:main Jun 6, 2024
11 checks passed
@xperimental xperimental deleted the logging-ui branch June 6, 2024 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants