Skip to content

Commit

Permalink
feat: add support annotation to uiplugins at runtime (#604)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterYurkovich authored Oct 29, 2024
1 parent a826c09 commit 41c578c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
18 changes: 18 additions & 0 deletions pkg/controllers/uiplugin/compatibility_matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ import (
uiv1alpha1 "github.com/rhobs/observability-operator/pkg/apis/uiplugin/v1alpha1"
)

type SupportLevel string

var (
DevPreview SupportLevel = "DevPreview"
TechPreview SupportLevel = "TechPreview"
GeneralAvailability SupportLevel = "GeneralAvailability"
Experimental_SSA SupportLevel = "Experimental-SSA"
)

type CompatibilityEntry struct {
PluginType uiv1alpha1.UIPluginType
// Minimal OpenShift version supporting this plugin (inclusive).
Expand All @@ -22,6 +31,7 @@ type CompatibilityEntry struct {
// Maximal ACM version supporting this plugin (exclusive).
MaxAcmVersion string
ImageKey string
SupportLevel SupportLevel
Features []string
}

Expand All @@ -36,6 +46,7 @@ var compatibilityMatrix = []CompatibilityEntry{
MinAcmVersion: "",
MaxAcmVersion: "",
Features: []string{},
SupportLevel: DevPreview,
},
{
PluginType: uiv1alpha1.TypeTroubleshootingPanel,
Expand All @@ -47,6 +58,7 @@ var compatibilityMatrix = []CompatibilityEntry{
ImageKey: "ui-troubleshooting-panel",
MinAcmVersion: "",
MaxAcmVersion: "",
SupportLevel: TechPreview,
Features: []string{},
},
{
Expand All @@ -56,6 +68,7 @@ var compatibilityMatrix = []CompatibilityEntry{
ImageKey: "ui-distributed-tracing",
MinAcmVersion: "",
MaxAcmVersion: "",
SupportLevel: TechPreview,
Features: []string{},
},
{
Expand All @@ -65,6 +78,7 @@ var compatibilityMatrix = []CompatibilityEntry{
ImageKey: "ui-logging",
MinAcmVersion: "",
MaxAcmVersion: "",
SupportLevel: GeneralAvailability,
Features: []string{},
},
{
Expand All @@ -74,6 +88,7 @@ var compatibilityMatrix = []CompatibilityEntry{
ImageKey: "ui-logging",
MinAcmVersion: "",
MaxAcmVersion: "",
SupportLevel: GeneralAvailability,
Features: []string{
"dev-console",
},
Expand All @@ -85,6 +100,7 @@ var compatibilityMatrix = []CompatibilityEntry{
ImageKey: "ui-logging",
MinAcmVersion: "",
MaxAcmVersion: "",
SupportLevel: GeneralAvailability,
Features: []string{
"dev-console",
"alerts",
Expand All @@ -97,6 +113,7 @@ var compatibilityMatrix = []CompatibilityEntry{
ImageKey: "ui-logging",
MinAcmVersion: "",
MaxAcmVersion: "",
SupportLevel: GeneralAvailability,
Features: []string{
"dev-console",
"alerts",
Expand All @@ -110,6 +127,7 @@ var compatibilityMatrix = []CompatibilityEntry{
ImageKey: "ui-monitoring",
MinAcmVersion: "v2.11",
MaxAcmVersion: "",
SupportLevel: DevPreview,
Features: []string{
"acm-alerting",
},
Expand Down
26 changes: 25 additions & 1 deletion pkg/controllers/uiplugin/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,31 @@ func (rm resourceManager) Reconcile(ctx context.Context, req ctrl.Request) (ctrl
}
}

pluginInfo, err := PluginInfoBuilder(ctx, rm.k8sClient, plugin, rm.pluginConf, rm.clusterVersion, acmVersion)
compatibilityInfo, err := lookupImageAndFeatures(plugin.Spec.Type, rm.clusterVersion, acmVersion)
if err != nil {
return ctrl.Result{}, err
}

if plugin.Annotations == nil {
plugin.Annotations = map[string]string{}
plugin.Annotations["observability.openshift.io/api-support"] = string(compatibilityInfo.SupportLevel)

if err := rm.k8sClient.Update(ctx, plugin); err != nil {
return ctrl.Result{}, err
}
// Upon changes to the uiplugin, reconciliation will happen anyways, so just return early
// and let the reconciliation handle the further changes
return ctrl.Result{}, nil
} else if plugin.Annotations["observability.openshift.io/api-support"] != string(compatibilityInfo.SupportLevel) {
plugin.Annotations["observability.openshift.io/api-support"] = string(compatibilityInfo.SupportLevel)

if err := rm.k8sClient.Update(ctx, plugin); err != nil {
return ctrl.Result{}, err
}
return ctrl.Result{}, err
}

pluginInfo, err := PluginInfoBuilder(ctx, rm.k8sClient, plugin, rm.pluginConf, compatibilityInfo)

if err != nil {
logger.Error(err, "failed to reconcile plugin")
Expand Down
6 changes: 1 addition & 5 deletions pkg/controllers/uiplugin/plugin_info_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ var pluginTypeToConsoleName = map[uiv1alpha1.UIPluginType]string{
uiv1alpha1.TypeLogging: "logging-view-plugin",
}

func PluginInfoBuilder(ctx context.Context, k client.Client, plugin *uiv1alpha1.UIPlugin, pluginConf UIPluginsConfiguration, clusterVersion string, acmVersion string) (*UIPluginInfo, error) {
compatibilityInfo, err := lookupImageAndFeatures(plugin.Spec.Type, clusterVersion, acmVersion)
if err != nil {
return nil, err
}
func PluginInfoBuilder(ctx context.Context, k client.Client, plugin *uiv1alpha1.UIPlugin, pluginConf UIPluginsConfiguration, compatibilityInfo CompatibilityEntry) (*UIPluginInfo, error) {

image := pluginConf.Images[compatibilityInfo.ImageKey]
if image == "" {
Expand Down

0 comments on commit 41c578c

Please sign in to comment.