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: OU-571 Add Perses Flag #664

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

zhuje
Copy link
Contributor

@zhuje zhuje commented Jan 30, 2025

JIRA Issue

https://issues.redhat.com/browse/OU-571

Description

  • Adjust COO to include the perses-dashboards flag in the arguments for the monitoring-console-plugin's Deployment; we then can use this flag to render the Perses Dashboard component.
  • Add perses proxy information to the list of proxies in the monitoring-console-plugin's ConsolePlugin; this allows the monitoring-console-plugin to proxy to perses an instance.
[OU-571](https://issues.redhat.com//browse/OU-571)-perses-feature-flag

Figure 1. The second screen shows UIPlugin configuration for perses, the third screen shows the alias: perses being listed as a proxy within the ConsolePlugin CR for the monitoring-console-plugin, the fourth screen shows the --feature='perses-dashboards being listed in the Deployment for the monitoring-console-plugin.

Changes

  1. Remove the required properties of thanosQuerier and Alertmanager (because we want Perses to be able to be used without ACM). In the future, we must add +kubebuilder validations/webhooks to validate the UIPlugin custom resources for type: monitoring. monitoring.go checks if thanosQuerier URL, alertManager URL, perses name, and namespace are not empty.
  • bundle/manifests/observability.openshift.io_uiplugins.yaml
  • deploy/crds/common/observability.openshift.io_uiplugins.yaml
  • types.go
  1. Add Perses dashboards to the compatibility matrix, which enables feature flags based on the conditions of the cluster. "perses-dashboards" will only be available in OCP 4.19+.
  • pkg/controllers/uiplugin/compatibility_matrix.go
  • pkg/controllers/uiplugin/compatibility_matrix_test.go
  1. Adjust list of proxies to include perses
  • pkg/controllers/uiplugin/monitoring.go
  • pkg/controllers/uiplugin/monitoring_test.go

Testing

  1. Login into a OCP v4.19+ cluster

  2. set openshift.enabled to true in main.go

# main.go 
...
	flag.BoolVar(&openShiftEnabled, "openshift.enabled", true, "Enable OpenShift specific features such as Console Plugins.")
...
  1. Build the image and push it to your quay.io repo (and regenerate CRD from types.go with make generate and make bundle)
make generate && \
make bundle && \
make operator-image bundle-image operator-push bundle-push  \
    IMAGE_BASE="quay.io/jezhu/observability-operator" \
    VERSION=1.1.0-dev-0.35.0
  1. Deploy to cluster (and clean up components from previous observability-operator deploys)
oc delete catalogsource observability-operator-catalog -n openshift-operators && \
operator-sdk cleanup observability-operator -n openshift-operators && \
operator-sdk run bundle \
    quay.io/jezhu/observability-operator-bundle:1.1.0-dev-0.35.0 \
    --install-mode AllNamespaces \
    --namespace openshift-operators \
    --security-context-config restricted
  1. Install Advanced Cluster Management (this enables the feature flag "--features=acm-alerting")
  • Go to OpenShift Container Platform UI
  • Go to the Menu > Administrator Perspective > Operators > OperatorHub
  • Search for "Advanced Cluster Management for Kubernetes", and install a version that is > v2.11
  • Create a the required MultiClusterHub
  1. Apply UIPlugin configuration for monitoring
oc apply -f - <<EOF
apiVersion: observability.openshift.io/v1alpha1
kind: UIPlugin
metadata:
  name: monitoring
spec:
  type: Monitoring
  monitoring:
    alertmanager: 
      url: 'https://alertmanager.open-cluster-management-observability.svc:9095'
    thanosQuerier:
      url: 'https://rbac-query-proxy.open-cluster-management-observability.svc:8443'
    perses:
      name: "perses-api-http"
      namespace: "perses-operator"  
EOF

Troubleshooting

mac specific troubleshooting

sed commands need to be adjusted on macOS update sed ... -i to sed ... -i '' .

# Makefile
...
.PHONY: bundle
...
# before 
	sed -e 's|<IMG_OBSERVABILITY_OPERATOR>|$(OPERATOR_IMG)|g' \
		-i bundle/manifests/observability-operator.clusterserviceversion.yaml
# after
	sed -e 's|<IMG_OBSERVABILITY_OPERATOR>|$(OPERATOR_IMG)|g' \
		-i  '' bundle/manifests/observability-operator.clusterserviceversion.yaml
...

Alternatively, install https://formulae.brew.sh/formula/gnu-sed and add it to your path to replace "sed"

GNU "sed" has been installed as "gsed".If you need to use it as "sed", you can add a "gnubin" directory to your PATH from your bashrc like:     PATH="$HOMEBREW_PREFIX/opt/gnu-sed/libexec/gnubin:$PATH"

If uninstall is hung

  1. oc edit crd uiplugins.observability.openshift.io
    n the editor, find the finalizers field under metadata, and remove any finalizers (it will look something like this):
metadata:
  finalizers:
  - kubernetes

After removing the finalizer(s), save and exit the editor. This should allow the CRD to be deleted.

  1. Go the the UI > Installed Operator > manually delete the operator

VSCode Local Debugger configurations

# launch.json
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Run",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "/Users/jezhu/Git/observability-operator/cmd/operator", 
            "args": [
                "--namespace=openshift-operators",
                "--metrics-bind-address=:8080",
                "--images=alertmanager=alertmanager=quay.io/prometheus/alertmanager:v0.26.0",
                "--images=prometheus=prometheus=quay.io/prometheus/prometheus:v2.49.1",
                "--images=thanos=thanos=quay.io/thanos/thanos:v0.33.0",
                "--openshift.enabled",
            ],
            "showLog": false,
            "cwd": "/Users/jezhu/Git/observability-operator/cmd/operator",
            "env": {},
        }
    ]
}

@zhuje zhuje requested a review from a team as a code owner January 30, 2025 02:27
@zhuje zhuje requested review from slashpai and JoaoBraveCoding and removed request for a team January 30, 2025 02:27
@openshift-ci openshift-ci bot requested review from jan--f and marioferh January 30, 2025 02:27
Copy link

openshift-ci bot commented Jan 30, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zhuje
Once this PR has been reviewed and has the lgtm label, please assign jan--f for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@zhuje zhuje force-pushed the OU-571-perses-feature-flag-pr branch from db5581f to 15ffcc9 Compare January 30, 2025 02:40
Comment on lines 42 to 44
if v.PluginType == "Monitoring" && slices.Contains(v.Features, "perses-dashboards") {
continue
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why do we need this exception.

Copy link
Contributor Author

@zhuje zhuje Feb 3, 2025

Choose a reason for hiding this comment

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

It allows the PluginType: uiv1alpha1.TypeMonitoring multiple cases where "MaxClusterVersion" is empty. I've includes the code snippet below that defines the cases.

The issue is if OCP is v4.19+ we need to create cases where ACM is present and absent. In both these cases MaxClusterVersion: "".

# compatibility_matrix.go

var compatibilityMatrix = []CompatibilityEntry{
        ...
   {
   	PluginType:        uiv1alpha1.TypeMonitoring,
   	MinClusterVersion: "v4.19",
   	MaxClusterVersion: "",
   	ImageKey:          "ui-monitoring",
   	MinAcmVersion:     "v2.11",
   	MaxAcmVersion:     "",
   	SupportLevel:      DevPreview,
   	Features: []string{
   		"acm-alerting",
   		"perses-dashboards",
   	},
   },
   {
   	PluginType:        uiv1alpha1.TypeMonitoring,
   	MinClusterVersion: "v4.14",
   	MaxClusterVersion: "",
   	ImageKey:          "ui-monitoring",
   	MinAcmVersion:     "v2.11",
   	MaxAcmVersion:     "",
   	SupportLevel:      DevPreview,
   	Features: []string{
   		"acm-alerting",
   	},
   },
   {
   	PluginType:        uiv1alpha1.TypeMonitoring,
   	MinClusterVersion: "v4.19",
   	MaxClusterVersion: "",
   	ImageKey:          "ui-monitoring",
   	MinAcmVersion:     "",
   	MaxAcmVersion:     "",
   	SupportLevel:      DevPreview,
   	Features: []string{
   		"perses-dashboards",
   	},
   },
}

Copy link
Contributor

Choose a reason for hiding this comment

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

There should be only one MaxClusterVersion. Perses flag won't be enabled by default, on dev preview will be an admin choice. We should test that it should be present when we enable Perses using the perses field in the UIPlugin CR, the compatibility matrix is built to enable by default plugin features based on cluster or ACM versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update so that only one MaxClusterVersion and the "perses-dashboards" flag is not enabled by default.

},
{
pluginType: uiv1alpha1.TypeMonitoring,
clusterVersion: "v4.19",
Copy link
Contributor

Choose a reason for hiding this comment

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

The cluster version for Perses could be lower as in older versions Perses dashboards can be added as a new Menu item. Nothing to block this PR as this can be adjusted when we decide.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, I'll leave it as is for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perses will be supported from 4.14. We need to adjust the logic to validate this cluster version if Perses is enabled in the UIPlugin CR, but not on the compatibility matrix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The latest push allows "perses-dashboards" feature flag to be added on OCP 4.14+.

},
}

if persesDashboardsFeatureEnabled && !invalidPersesConfig {
Copy link
Contributor

Choose a reason for hiding this comment

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

this logic seems a bit complex to maintain, we can maybe fail first if Perses or ACM configuration is not set

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the latest commit, I updated the logic in monitoring.go. It validates and fails first if Perses or ACM configuration is not set.

@zhuje
Copy link
Contributor Author

zhuje commented Feb 4, 2025

/hold
I pushed some changes, but they must be tested on a cluster.

@zhuje
Copy link
Contributor Author

zhuje commented Feb 4, 2025

/unhold

tested on cluster

image

@zhuje zhuje force-pushed the OU-571-perses-feature-flag-pr branch 3 times, most recently from 85e113b to 81002e1 Compare February 4, 2025 06:30
@zhuje zhuje force-pushed the OU-571-perses-feature-flag-pr branch from 81002e1 to ab5e989 Compare February 4, 2025 06:44
@zhuje zhuje force-pushed the OU-571-perses-feature-flag-pr branch from 5f38854 to 8e2364f Compare February 5, 2025 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants