-
Notifications
You must be signed in to change notification settings - Fork 23
feat: add auto-detect for OpenShift platform #1421
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
Conversation
Reviewer's GuideIntroduce auto-detection of OpenShift at startup by querying aggregated APIService resources, remove previous manual configuration, and update RBAC, configuration schema, and CI/build files accordingly. Sequence diagram for OpenShift platform auto-detection at startupsequenceDiagram
participant main as "main()"
participant utils as "utils.IsFlagProvided()"
participant k8s as "kubernetes.DetectOpenShiftPlatform()"
participant apiserver as "APIServiceList"
participant config as "appconfig"
main->>utils: Check if 'openshift' flag/env is provided
alt Flag/env not provided
main->>k8s: Call DetectOpenShiftPlatform()
k8s->>apiserver: Query APIService resources
apiserver-->>k8s: Return APIServiceList
k8s-->>main: Return detected platform (true/false)
main->>config: Set appconfig.Openshift
else Flag/env provided
main->>config: Use explicit appconfig.Openshift value
end
main->>main: Log platform detection result
Entity relationship diagram for RBAC changes to APIService accesserDiagram
ROLE ||--o{ APIService : grants
ROLE {
string apiGroups
string resources
string verbs
}
APIService {
string name
string namespace
}
Class diagram for new and updated configuration and detection typesclassDiagram
class appconfig {
+int64 CreateTreeDeadline
+bool Openshift
+string OpenshiftAPIServerName
}
class kubernetes {
+DetectOpenShiftPlatform(log logr.Logger, apiServiceName string) bool, error
}
class utils {
+IsFlagProvided(name string, envName string) bool
}
appconfig <.. utils : uses
appconfig <.. kubernetes : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
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.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `config/rbac/role.yaml:71-78` </location>
<code_context>
- persistentvolumeclaims/finalizers
verbs:
- update
+- apiGroups:
+ - apiregistration.k8s.io
+ resources:
+ - apiservices
+ verbs:
+ - get
+ - list
+ - watch
- apiGroups:
- apps
</code_context>
<issue_to_address>
**🚨 suggestion (security):** RBAC permissions for apiservices may be broader than necessary.
If platform detection only needs get or list, restrict the RBAC verbs accordingly to minimize permissions.
```suggestion
- apiGroups:
- apiregistration.k8s.io
resources:
- apiservices
verbs:
- get
- list
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||
Signed-off-by: Kevin Conner <[email protected]>
|
Moving this PR to the |
This replaces #1418, implementing auto detection based on the registered API Services.
The original race condition was caused by kubernetes aggregated API servers, with the resources chosen by the original detection method supported by the openshift-apiserver. Since the openshift-apiserver was not guaranteed to have been running at the start of the operator, this led to the race.
If a
Localresource had been chosen instead, i.e. one supported by kube-apiserver, there would have been no race.This PR removes the config CRD proposed in #1418, and implements a detection method based on the APIServices. The detection will query all APIServices and search for one which has an associated service (i.e. aggregated endpoint) with the openshift-apiserver name or namespace.
I checked this behaviour on a number of OCP versions, and also on kind. The versions and APIServices are
-- AWS 4.12
-- AWS 4.20
-- rosa 4.16
-- hypershift 4.19
-- hypershift 4.20
Summary by Sourcery
Add APIService-based auto-detection for OpenShift platform, replacing manual flag configuration and outdated overlays, while updating RBAC, flags, CI workflows, and build dependencies.
New Features:
Bug Fixes:
Enhancements:
Build:
CI:
Chores: