-
Notifications
You must be signed in to change notification settings - Fork 32
code restructuring #1106
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
code restructuring #1106
Conversation
f02cee4 to
86e5748
Compare
8efa3d2 to
9f42e39
Compare
21edca0 to
b6cc7b4
Compare
| | `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) | |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add explanation
| @@ -0,0 +1,102 @@ | |||
| package utils | |||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
internal/controller/utils/types.go
Outdated
| Namespace string | ||
| ReconcileInterval time.Duration | ||
| } | ||
|
|
||
| /*** controller internal ***/ | ||
| type ReconcileFunc func(context.Context, *olsv1alpha1.OLSConfig) error |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
},
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
the code looks good.
|
| // 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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
/approve |
|
[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 |
b6cc7b4 to
b21ab29
Compare
b21ab29 to
65fc6f4
Compare
65fc6f4 to
18e34be
Compare
|
@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. |
|
/lgtm |
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:
Type of change
Related Tickets & Documents
OLS-2251
OLS-2251
Checklist before requesting a review
Testing