Skip to content

Conversation

@blublinsky
Copy link
Contributor

@blublinsky blublinsky commented Oct 31, 2025

Description

This is a massive PR restructuring operator code in the individual components. Not so much code changes, but a lot of moving code around.
Additionally:

  • increased code coverage
  • add comprehensive documentation
  • improved local testing

Type of change

  • [ x] Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up dependent library

Related Tickets & Documents

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

@blublinsky blublinsky force-pushed the restructuring branch 5 times, most recently from f02cee4 to 86e5748 Compare November 3, 2025 16:00
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 3, 2025
@blublinsky blublinsky force-pushed the restructuring branch 2 times, most recently from 8efa3d2 to 9f42e39 Compare November 3, 2025 19:19
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 3, 2025
@blublinsky blublinsky force-pushed the restructuring branch 2 times, most recently from 21edca0 to b6cc7b4 Compare November 5, 2025 16:30
| `OwnNamespace` | Operator watches its own namespace | Development/testing |
| `SingleNamespace` | Operator watches one namespace | Namespace isolation |
| `MultiNamespace` | Operator watches specific namespaces | Multi-tenant with selection |
| `AllNamespaces` | Operator watches cluster-wide | Cluster-scoped resources (like Lightspeed) |
Copy link
Contributor

Choose a reason for hiding this comment

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

Openshift lightspeed supports only OwnNamespace - to watch resources on the namespace its installed on . @blublinsky .
Also are these auto generated files in the docs folder ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes they are, but I went through and verified them. They are quite useful, at least for me

Copy link
Contributor

Choose a reason for hiding this comment

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

``AllNamespaces| Operator watches cluster-wide | Cluster-scoped resources (like Lightspeed) - that is not correct - OLS uses OwnNamespace --@blublinsky

Copy link
Contributor Author

Choose a reason for hiding this comment

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

add explanation

@blublinsky blublinsky mentioned this pull request Nov 7, 2025
7 tasks
@@ -0,0 +1,102 @@
package utils
Copy link
Contributor

Choose a reason for hiding this comment

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

this file will be compiled into the normal operator build.
These are test codes.
Let's rename it to something ending with _test.go postfix to make it only compiled into test build.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If renamed to testing_test.go:
Would only be compiled during testing (which is fine)
BUT: The _test suffix in Go typically means the file is in the package utils_test (external test package), not package utils
Current testing.go is in package utils, making helpers available to other packages' tests

Best practice: Keep it as testing.go. This is the standard Go convention for test helper/utility files that:
Live in the same package as the code being tested
Provide shared test fixtures, builders, and utilities
Are used by multiple *_test.go files
Examples from the Go standard library:
testing/testing.go - the testing framework itself
Many packages have example_test.go, export_test.go, or utility files without _test.go suffix
So no advantage - keep it as testing.go!

@@ -0,0 +1,452 @@
package utils
Copy link
Contributor

Choose a reason for hiding this comment

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

this file will be compiled into the normal operator build.
These are test codes.
Let's rename it to something ending with _test.go postfix to make it only compiled into test build.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see above

Namespace string
ReconcileInterval time.Duration
}

/*** controller internal ***/
type ReconcileFunc func(context.Context, *olsv1alpha1.OLSConfig) error
Copy link
Contributor

Choose a reason for hiding this comment

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

According to how the reconile functions are called, it may be more useful to declare it as type ReconcileFunc func(reconciler.Reconciler, context.Context, *olsv1alpha1.OLSConfig) error

Copy link
Contributor

@raptorsun raptorsun Nov 9, 2025

Choose a reason for hiding this comment

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

so that we can avoid the wrapper function like

	tasks := []utils.ReconcileTask{
		{
			Name: "reconcile Postgres ConfigMap",
			Task: func(ctx context.Context, cr *olsv1alpha1.OLSConfig) error {
				return reconcilePostgresConfigMap(r, ctx, cr)
			},
		},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@raptorsun
Copy link
Contributor

the code looks good.
2 suggestions:

  1. rename the files containing test codes only to *_test.go to avoid compile it into the released operator build.
  2. declare ReconcileFunc with 3 arguments, in order to avoid uneccessary wrapper functions in reconciliator functions.

// 1. Reconcile operator-level resources (service monitor, network policy)
// 2. Delegate LLM provider secret reconciliation to appserver.ReconcileLLMSecrets()
// 3. Reconcile PostgreSQL database (if conversation cache enabled)
// 4. Reconcile Console UI plugin (if enabled)
Copy link
Contributor

Choose a reason for hiding this comment

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

@reconcile Console UI plugin (if enabled) -- this will be always enabled @blublinsky

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@xrajesh
Copy link
Contributor

xrajesh commented Nov 10, 2025

/approve
@blublinsky Please address the comments - then its ready to merge

@openshift-ci
Copy link

openshift-ci bot commented Nov 10, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: xrajesh

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-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 10, 2025
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 11, 2025
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 11, 2025
@blublinsky blublinsky requested a review from raptorsun November 11, 2025 13:12
@openshift-ci
Copy link

openshift-ci bot commented Nov 11, 2025

@blublinsky: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@JoaoFula
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 11, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 006d07a into openshift:main Nov 11, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants