feat: Manage OpenVSX as Che operand#2130
Conversation
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: svor The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi! I'm che-ai-assistant — I help with your pull requests. Available commands:
|
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
The expose reconciler runs after the server reconciler, so Status.OpenVSXURL is empty on the first reconcile. Defer Job creation until the URL is available. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Kubernetes Jobs are immutable after creation. Instead of relying on deploy.Sync to update the Job (which would fail), compare the EXTENSIONS_HASH and delete the old Job before creating a new one. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Anatolii Bazko <abazko@redhat.com>
Co-authored-by: Anatolii Bazko <abazko@redhat.com>
Co-authored-by: Anatolii Bazko <abazko@redhat.com>
When OpenVSX.Enable=true, the managed operand provides the registry. Disable the embedded OpenVSX in the plugin registry and override the dashboard's OpenVSX URL with Status.OpenVSXURL. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rename secret keys to be more descriptive (e.g. user→db-user, userPAT→publisher-token). Add OpenVSXSecret field to allow users to provide their own credentials secret. Make JDBC database name configurable via PGDATABASE env var instead of hardcoded value. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The cached client only tracks operator-managed secrets, so user-created secrets were not visible during reconciliation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace shell variable interpolation with psql -v variables and heredoc input to prevent SQL injection from user-provided secret values. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
Signed-off-by: Anatolii Bazko <abazko@redhat.com>
|
/che-ai-assistant ok-pr-review Review is complete. Please check the review comments below. |
tolusha
left a comment
There was a problem hiding this comment.
Code Review Findings
This is an automated review covering standard code quality, design patterns, operational readiness, and system-level concerns.
Critical Issues (Must Fix Before Merge)
1. Missing owner reference on Ingress
File: pkg/deploy/openvsx/openvsx-server/openvsx_server_ingress.go (around line 114)
The Ingress resource is created without setting controllerutil.SetControllerReference. This means it won't be garbage-collected when the CheCluster CR is deleted. Compare with openvsx_server_service.go and openvsx_database_service.go which both set owner references.
Add before the Sync call:
if err := controllerutil.SetControllerReference(ctx.CheCluster, ingress, ctx.ClusterAPI.Scheme); err != nil {
return err
}2. Missing owner reference on ConfigMap
File: pkg/deploy/openvsx/openvsx-server/openvsx_server_config.go:41
The openvsx-server ConfigMap lacks an owner reference, preventing automatic cleanup.
Add before CreateIfNotExists:
if err := controllerutil.SetControllerReference(ctx.CheCluster, cm, ctx.ClusterAPI.Scheme); err != nil {
return err
}3. Init containers not covered by security standards
File: pkg/deploy/deployment.go:EnsurePodSecurityStandards
The function only iterates podSpec.Containers, skipping podSpec.InitContainers. The DB provisioning Job uses an init container that won't receive the required SecurityContext. On restricted clusters (OpenShift SCC, Pod Security Admission), the init container will be rejected.
Extend the function to also iterate init containers:
for i := range podSpec.InitContainers {
if podSpec.InitContainers[i].SecurityContext == nil {
podSpec.InitContainers[i].SecurityContext = &corev1.SecurityContext{}
}
podSpec.InitContainers[i].SecurityContext.AllowPrivilegeEscalation = ptr.To(false)
podSpec.InitContainers[i].SecurityContext.Capabilities = &corev1.Capabilities{Drop: []corev1.Capability{"ALL"}}
podSpec.InitContainers[i].SecurityContext.RunAsNonRoot = ptr.To(true)
}4. Missing Job deadline on database provisioning
File: pkg/deploy/openvsx/openvsx-database/openvsx_database_setup.go
The provisioning Job has no activeDeadlineSeconds. The init container loops indefinitely (sleep 5) waiting for migrations. If the server never starts, the Job runs forever.
Add to the Job spec:
ActiveDeadlineSeconds: ptr.To(int64(600)), // 10 minutes5. Missing Job deadline on extension publisher
File: pkg/deploy/openvsx/openvsx-server/openvsx_server_extentions.go
Same issue - no maximum runtime for the extension-publish Job.
Add to the Job spec:
ActiveDeadlineSeconds: ptr.To(int64(600)), // 10 minutesWarnings (Should Fix)
6. Typo in filename
File: pkg/deploy/openvsx/openvsx-server/openvsx_server_extentions.go
Filename should be openvsx_server_extensions.go (not "extentions").
7. Empty image string not guarded
File: pkg/common/operator-defaults/defaults.go
os.Getenv is used for OpenVSX images instead of ensureEnv. If the env vars are missing, empty image strings are returned, causing confusing errors later.
Consider adding validation in the reconciler:
image := defaults.GetOpenVSXImage(ctx.CheCluster)
if image == "" {
return reconcile.Result{}, false, fmt.Errorf("RELATED_IMAGE_openvsx environment variable not set")
}8. Typo in constant comment
File: pkg/common/constants/constants.go
Comment says OpenVSXRegsitry Common - should be OpenVSXRegistry Common.
Suggestions (Nice to Have)
9. Document in-memory state behavior (server)
File: pkg/deploy/openvsx/openvsx-server/openvsx_server.go
The extensionsVersion field resets to empty on operator restart. Add a comment explaining this is safe due to idempotency:
// extensionsVersion tracks the last synced ConfigMap version to avoid unnecessary Job churn.
// Resets on operator restart, which is safe - the Job is idempotent.
extensionsVersion string10. Document in-memory state behavior (database)
File: pkg/deploy/openvsx/openvsx-database/openvsx_database.go
Same for databaseProvisioned:
// databaseProvisioned prevents recreating the setup Job on every reconcile.
// Resets on operator restart, which is safe - the Job uses ON CONFLICT DO NOTHING.
databaseProvisioned bool11. Document destructive PVC deletion
File: pkg/deploy/openvsx/openvsx-database/openvsx_database.go:deleteResources
PVCs are deleted when enable=false, permanently destroying all data. This should be documented in the CRD field description or user docs. Consider adding a warning in the webhook when toggling from true to false.
12. Hostname prefix not configurable
File: pkg/common/constants/constants.go
The openvsx- prefix is hardcoded. Users cannot customize the hostname. Consider adding openVSXRegistry.server.hostname to the CRD for flexibility.
13. Add test for plugin registry interaction
File: api/v2/checluster_types_test.go (new test needed)
The new helper methods (IsInternalOpenVSXRegistryEnabled, IsExternalOpenVSXRegistryEnabled, IsInternalPluginRegistryWithOpenVSXEnabled) need a truth-table test covering all combinations of:
openVSXRegistry.enablepluginRegistry.openVSXURLpluginRegistry.disableInternalRegistry
Positive Highlights
Excellent work on:
- Security: SQL uses parameterized variables, secrets handled correctly, pods have proper SecurityContext
- Architecture: Clean reconciler decomposition with proper dependency ordering (Secret → Database → Server)
- K8s patterns: ConfigMap ResourceVersion triggering rollouts is elegant and Kubernetes-native
- Idempotency:
ON CONFLICT DO NOTHINGin SQL,CreateIfNotExistsfor user-editable resources - Test coverage: Good coverage of happy/sad paths for all reconcilers
The overall design is solid. The issues above are fixable polish items that will prevent operational problems.
Review generated by: ok-pr-review with Claude Sonnet 4.5
|
PR needs rebase. DetailsInstructions 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. |
What does this PR do?
enabled via
spec.components.openVSX.enableand Kubernetes
openvsx-extensionsConfigMapspec.components.openVSX.server.claimSize)openvsx-server-configConfigMap user-editable with automatic pod rollout onchanges
New CRD fields
spec.components.openVSX.enable— enables the OpenVSX operand (default is false)spec.components.openVSX.server.claimSize— PVC size for extension storage (default:3Gi)
spec.components.openVSX.server.deployment— deployment overridesspec.components.openVSX.database.claimSize— PVC size for PostgreSQL data (default:1Gi)
spec.components.openVSX.database.deployment— deployment overridesstatus.openVSXURL— URL of the managed OpenVSX instanceResources created when enabled
(extensions list)
All resources are cleaned up when
openVSX.enableis set to false.Screenshot/screencast of this PR
What issues does this PR fix or reference?
https://issues.redhat.com/browse/CRW-10323
How to test this PR?
OpenShift
or
on Minikube
Common Test Scenarios
openvsx-extensionsConfigMapopenvsx-server-configConfigMap and verify pod rolloutclaimSizeand verify expansionPR Checklist
As the author of this Pull Request I made sure that:
Reviewers
Reviewers, please comment how you tested the PR when approving it.