Skip to content

NETOBSERV-2701 handle plugin images from CSV#2598

Open
jpinsonneau wants to merge 1 commit intonetobserv:mainfrom
jpinsonneau:2701
Open

NETOBSERV-2701 handle plugin images from CSV#2598
jpinsonneau wants to merge 1 commit intonetobserv:mainfrom
jpinsonneau:2701

Conversation

@jpinsonneau
Copy link
Member

@jpinsonneau jpinsonneau commented Mar 27, 2026

Description

  • Handle multiple plugin images from CSV
  • Bind OpenShift version to each image directly from the controller flag

Dependencies

n/a

Checklist

  • Does the changes in PR need specific configuration or environment set up for testing?
    • if so please describe it in PR description.
  • I have added thorough unit tests for the change.
  • QE requirements (check 1 from the list):
    • Standard QE validation, with pre-merge tests unless stated otherwise.
    • Regression tests only (e.g. refactoring with no user-facing change).
    • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

Summary by CodeRabbit

Release Notes

  • New Features

    • The operator now automatically selects the appropriate console plugin image based on your OpenShift cluster version, improving compatibility across different versions.
  • Refactor

    • Redesigned console plugin image configuration from fixed values to a version-aware mapping system.

@openshift-ci
Copy link

openshift-ci bot commented Mar 27, 2026

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

@openshift-ci
Copy link

openshift-ci bot commented Mar 27, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

Details 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

@coderabbitai
Copy link

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

The PR refactors console plugin image management from a fixed single/compat image approach to a version-aware mapping system that selects plugin variants based on OpenShift version thresholds, replacing hardcoded image flags with a semicolon-separated configuration format.

Changes

Cohort / File(s) Summary
Build & Manifest Configuration
Makefile, bundle/manifests/netobserv-operator.clusterserviceversion.yaml, config/manager/manager.yaml
Updated image placeholder handling and deployment manifests to support multiple console plugin variants (PF4/PF5) via new --console-plugin-images flag with version-to-image mappings; replaced RELATED_IMAGE_CONSOLE_PLUGIN_COMPAT with separate RELATED_IMAGE_CONSOLE_PLUGIN_PF4 and RELATED_IMAGE_CONSOLE_PLUGIN_PF5 entries.
Configuration & Parsing
internal/pkg/manager/config.go, internal/pkg/manager/config_test.go, internal/pkg/test/envtest.go
Added ConsolePluginImageVariant type and list-based ConsolePluginImageVariants field; introduced ParseConsolePluginImages() parser for semicolon-separated minVersion=image format and ResolveConsolePluginImage() method for version-aware selection; replaced single image fields with variant list structure; added comprehensive test coverage.
Controller & Reconciler Updates
internal/controller/consoleplugin/consoleplugin_objects.go, internal/controller/flowcollector_controller.go, internal/controller/static/static_controller.go, internal/controller/reconcilers/common.go
Removed version-based conditional logic and ConsolePluginCompatImage constant; updated controllers to use ResolveConsolePluginImage() for dynamic image selection based on cluster info instead of static mappings.
Application Entry Point
main.go
Replaced dual console plugin image flags with single --console-plugin-images mapping flag; added parsing invocation with error handling before manager initialization.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references the Jira ticket (NETOBSERV-2701) and accurately describes the main change: handling multiple plugin images from CSV with version-specific mappings.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 69.38776% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.23%. Comparing base (046989f) to head (f3a8eac).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
main.go 0.00% 9 Missing ⚠️
internal/pkg/manager/config.go 80.64% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2598      +/-   ##
==========================================
- Coverage   72.39%   72.23%   -0.17%     
==========================================
  Files         105      105              
  Lines       10851    10883      +32     
==========================================
+ Hits         7856     7861       +5     
- Misses       2518     2538      +20     
- Partials      477      484       +7     
Flag Coverage Δ
unittests 72.23% <69.38%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
.../controller/consoleplugin/consoleplugin_objects.go 90.20% <100.00%> (-0.09%) ⬇️
internal/controller/flowcollector_controller.go 82.47% <100.00%> (+1.86%) ⬆️
internal/controller/reconcilers/common.go 88.23% <ø> (ø)
internal/controller/static/static_controller.go 76.78% <100.00%> (-0.41%) ⬇️
internal/pkg/test/envtest.go 96.92% <100.00%> (+0.03%) ⬆️
internal/pkg/manager/config.go 69.23% <80.64%> (+69.23%) ⬆️
main.go 0.00% <0.00%> (ø)

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jpinsonneau jpinsonneau added the ok-to-test To set manually when a PR is safe to test. Triggers image build on PR. label Mar 27, 2026
@github-actions
Copy link

New images:

quay.io/netobserv/network-observability-operator:919fc3c
quay.io/netobserv/network-observability-operator-bundle:v0.0.0-sha-919fc3c
quay.io/netobserv/network-observability-operator-catalog:v0.0.0-sha-919fc3c

They will expire in two weeks.

To deploy this build:

# Direct deployment, from operator repo
IMAGE=quay.io/netobserv/network-observability-operator:919fc3c make deploy

# Or using operator-sdk
operator-sdk run bundle quay.io/netobserv/network-observability-operator-bundle:v0.0.0-sha-919fc3c

Or as a Catalog Source:

apiVersion: operators.coreos.com/v1alpha1
kind: CatalogSource
metadata:
  name: netobserv-dev
  namespace: openshift-marketplace
spec:
  sourceType: grpc
  image: quay.io/netobserv/network-observability-operator-catalog:v0.0.0-sha-919fc3c
  displayName: NetObserv development catalog
  publisher: Me
  updateStrategy:
    registryPoll:
      interval: 1m

@jpinsonneau jpinsonneau marked this pull request as ready for review March 27, 2026 10:56
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/pkg/manager/config.go`:
- Around line 87-96: The validation for cfg.ConsolePluginImageVariants must
ensure each MinVersion is a valid OCP version and that the slice is strictly
ascending so ResolveConsolePluginImage behaves deterministically; in the loop in
config.go (where ConsolePluginImageVariants is checked) parse/validate each
v.MinVersion using the same version parser/semver logic used by
ResolveConsolePluginImage and return an error if parsing fails, and additionally
compare each parsed MinVersion to the previous one to ensure it is strictly
greater, returning a clear fmt.Errorf referencing the offending index (use the
same symbols ConsolePluginImageVariants and ResolveConsolePluginImage to locate
code).
- Around line 41-59: ParseConsolePluginImages mutates
cfg.ConsolePluginImageVariants incrementally, causing partial updates on errors
and retention across calls; fix by building a new local slice (e.g.,
newVariants) inside ParseConsolePluginImages, parse and validate all entries
into that slice without touching cfg, and only if parsing completes successfully
replace cfg.ConsolePluginImageVariants = newVariants so the update is atomic and
leaves the original slice intact on error.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: eb51c863-b3fa-448f-8866-77105b3e23e8

📥 Commits

Reviewing files that changed from the base of the PR and between 12e06e5 and f3a8eac.

📒 Files selected for processing (11)
  • Makefile
  • bundle/manifests/netobserv-operator.clusterserviceversion.yaml
  • config/manager/manager.yaml
  • internal/controller/consoleplugin/consoleplugin_objects.go
  • internal/controller/flowcollector_controller.go
  • internal/controller/reconcilers/common.go
  • internal/controller/static/static_controller.go
  • internal/pkg/manager/config.go
  • internal/pkg/manager/config_test.go
  • internal/pkg/test/envtest.go
  • main.go

Comment on lines +41 to +59
func (cfg *Config) ParseConsolePluginImages(raw string) error {
if raw == "" {
return nil
}
for _, entry := range strings.Split(raw, ";") {
entry = strings.TrimSpace(entry)
if entry == "" {
continue
}
eqIdx := strings.Index(entry, "=")
if eqIdx <= 0 || eqIdx >= len(entry)-1 {
return fmt.Errorf("invalid console plugin image entry %q: expected format minVersion=image", entry)
}
cfg.ConsolePluginImageVariants = append(cfg.ConsolePluginImageVariants, ConsolePluginImageVariant{
MinVersion: entry[:eqIdx],
Image: entry[eqIdx+1:],
})
}
return nil
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Replace the variant slice atomically.

This parser mutates ConsolePluginImageVariants as it goes. If it is called twice, old entries are retained, and a malformed later token leaves the config partially updated.

Suggested fix
func (cfg *Config) ParseConsolePluginImages(raw string) error {
-	if raw == "" {
+	var variants []ConsolePluginImageVariant
+	if strings.TrimSpace(raw) == "" {
+		cfg.ConsolePluginImageVariants = nil
 		return nil
 	}
 	for _, entry := range strings.Split(raw, ";") {
 		entry = strings.TrimSpace(entry)
 		if entry == "" {
@@
 		if eqIdx <= 0 || eqIdx >= len(entry)-1 {
 			return fmt.Errorf("invalid console plugin image entry %q: expected format minVersion=image", entry)
 		}
-		cfg.ConsolePluginImageVariants = append(cfg.ConsolePluginImageVariants, ConsolePluginImageVariant{
+		variants = append(variants, ConsolePluginImageVariant{
 			MinVersion: entry[:eqIdx],
 			Image:      entry[eqIdx+1:],
 		})
 	}
+	cfg.ConsolePluginImageVariants = variants
 	return nil
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
func (cfg *Config) ParseConsolePluginImages(raw string) error {
if raw == "" {
return nil
}
for _, entry := range strings.Split(raw, ";") {
entry = strings.TrimSpace(entry)
if entry == "" {
continue
}
eqIdx := strings.Index(entry, "=")
if eqIdx <= 0 || eqIdx >= len(entry)-1 {
return fmt.Errorf("invalid console plugin image entry %q: expected format minVersion=image", entry)
}
cfg.ConsolePluginImageVariants = append(cfg.ConsolePluginImageVariants, ConsolePluginImageVariant{
MinVersion: entry[:eqIdx],
Image: entry[eqIdx+1:],
})
}
return nil
func (cfg *Config) ParseConsolePluginImages(raw string) error {
var variants []ConsolePluginImageVariant
if strings.TrimSpace(raw) == "" {
cfg.ConsolePluginImageVariants = nil
return nil
}
for _, entry := range strings.Split(raw, ";") {
entry = strings.TrimSpace(entry)
if entry == "" {
continue
}
eqIdx := strings.Index(entry, "=")
if eqIdx <= 0 || eqIdx >= len(entry)-1 {
return fmt.Errorf("invalid console plugin image entry %q: expected format minVersion=image", entry)
}
variants = append(variants, ConsolePluginImageVariant{
MinVersion: entry[:eqIdx],
Image: entry[eqIdx+1:],
})
}
cfg.ConsolePluginImageVariants = variants
return nil
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/pkg/manager/config.go` around lines 41 - 59,
ParseConsolePluginImages mutates cfg.ConsolePluginImageVariants incrementally,
causing partial updates on errors and retention across calls; fix by building a
new local slice (e.g., newVariants) inside ParseConsolePluginImages, parse and
validate all entries into that slice without touching cfg, and only if parsing
completes successfully replace cfg.ConsolePluginImageVariants = newVariants so
the update is atomic and leaves the original slice intact on error.

Comment on lines +87 to +96
if len(cfg.ConsolePluginImageVariants) == 0 {
return errors.New("console plugin images can't be empty")
}
for i, v := range cfg.ConsolePluginImageVariants {
if v.Image == "" {
return fmt.Errorf("console plugin image variant %d has empty image", i)
}
if v.MinVersion == "" {
return fmt.Errorf("console plugin image variant %d has empty MinVersion", i)
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Reject misordered or invalid thresholds during validation.

ResolveConsolePluginImage only behaves correctly when every MinVersion is a valid OCP version and the slice is strictly ascending. Right now any non-empty string passes validation, so bad CSV content can silently resolve to the wrong plugin image.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/pkg/manager/config.go` around lines 87 - 96, The validation for
cfg.ConsolePluginImageVariants must ensure each MinVersion is a valid OCP
version and that the slice is strictly ascending so ResolveConsolePluginImage
behaves deterministically; in the loop in config.go (where
ConsolePluginImageVariants is checked) parse/validate each v.MinVersion using
the same version parser/semver logic used by ResolveConsolePluginImage and
return an error if parsing fails, and additionally compare each parsed
MinVersion to the previous one to ensure it is strictly greater, returning a
clear fmt.Errorf referencing the offending index (use the same symbols
ConsolePluginImageVariants and ResolveConsolePluginImage to locate code).

- --flowlogs-pipeline-image=$(RELATED_IMAGE_FLOWLOGS_PIPELINE)
- --console-plugin-image=$(RELATED_IMAGE_CONSOLE_PLUGIN)
- --console-plugin-compat-image=$(RELATED_IMAGE_CONSOLE_PLUGIN_COMPAT)
- --console-plugin-images=4.0.0=$(RELATED_IMAGE_CONSOLE_PLUGIN_PF4);4.15.0=$(RELATED_IMAGE_CONSOLE_PLUGIN_PF5);4.22.0=$(RELATED_IMAGE_CONSOLE_PLUGIN)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- --console-plugin-images=4.0.0=$(RELATED_IMAGE_CONSOLE_PLUGIN_PF4);4.15.0=$(RELATED_IMAGE_CONSOLE_PLUGIN_PF5);4.22.0=$(RELATED_IMAGE_CONSOLE_PLUGIN)
- --console-plugin-images=4.14.0=$(RELATED_IMAGE_CONSOLE_PLUGIN_PF4);4.15.0=$(RELATED_IMAGE_CONSOLE_PLUGIN_PF5);4.22.0=$(RELATED_IMAGE_CONSOLE_PLUGIN)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test To set manually when a PR is safe to test. Triggers image build on PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants