-
Notifications
You must be signed in to change notification settings - Fork 103
WRKLDS-728: Disable apiservers #366
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
WRKLDS-728: Disable apiservers #366
Conversation
|
@ingvagabund: This pull request references WRKLDS-728 which is a valid jira issue. DetailsIn response to this:
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/test-infra repository. |
5320731 to
5899405
Compare
5899405 to
e713c26
Compare
e713c26 to
1f0c8c3
Compare
|
/retest-required |
1f0c8c3 to
bf1d15a
Compare
|
@ingvagabund: This pull request references WRKLDS-728 which is a valid jira issue. DetailsIn response to this:
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/test-infra repository. |
pkg/route/apis/route/types.go
Outdated
| // chain. Do not include a CA certificate. The secret referenced should | ||
| // be present in the same namespace as that of the Route. | ||
| // Forbidden when `certificate` is set. | ||
| ExternalCertificate LocalObjectReference `json:"externalCertificate,omitempty" protobuf:"bytes,7,opt,name=externalCertificate"` |
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.
Internal types do not need the json tags
|
I think we will need to touch some other parts of the codebase to truly be able to enable/disable APIs. The current change only stop serving the APIs, but the underneath logic will still be executed even when the APIs are disabled. The first one that I can see is the post start hooks: https://github.com/openshift/openshift-apiserver/blob/master/pkg/cmd/openshift-apiserver/openshiftapiserver/openshift_apiserver.go#L444-L473. Some of these will not be needed if their API is disabled. Another part that will need to be gated on the config are the various caches configurations in https://github.com/openshift/openshift-apiserver/blob/master/pkg/cmd/openshift-apiserver/openshiftapiserver/config.go. I don't think we should create the cache of an API that is disabled. Same goes for the controllers that are normally used to fill these cache and respond to the apiserver. There might be some other parts of the code that will need to be tweaked, but I generally think we should also try to enable/disable the logic behind the APIs. |
bf1d15a to
c7d3b21
Compare
|
When trying to disable an unsupported group: |
|
/retest-required |
1 similar comment
|
/retest-required |
|
I like the change to have an allow list with the API that can be disabled today. That said we still have the same problem as before from #366 (comment) where the inner logic (controller, cache, ...) will still be executed even if an API is disabled no? Also, I think it would be a great addition to add a log line and maybe even a metric telling which API is enabled and which one is disabled. |
Checking the PostStart hooks I don't see anything related to DCs/Builds under https://github.com/openshift/openshift-apiserver/blob/master/pkg/cmd/openshift-apiserver/openshiftapiserver/openshift_apiserver.go#L453-L484. There's also no DCs/Builds informer mentioned in https://github.com/openshift/openshift-apiserver/blob/master/pkg/cmd/openshift-apiserver/openshiftapiserver/openshift_apiserver.go#L98-L142 or https://github.com/openshift/openshift-apiserver/blob/master/pkg/cmd/openshift-apiserver/openshiftapiserver/informers.go#L90-L99. |
|
This looks good to me overall, but we might also want to disable these admission plugins https://github.com/openshift/openshift-apiserver/blob/master/pkg/cmd/openshift-apiserver/openshiftadmission/register.go#L37-L38 no? |
|
Those are registering handlers, which should not get invoked at all. Plus, |
|
We could maybe leverage the admission options to disable them? https://github.com/openshift/openshift-apiserver/blob/master/pkg/cmd/openshift-apiserver/openshiftapiserver/config.go#L212 But as you mentioned it should be impossible to invoke them so disabling them doesn't bring much value |
| apiServers := make(map[openshiftcontrolplanev1.OpenShiftAPIserverName]openshiftcontrolplanev1.PerGroupOptions) | ||
|
|
||
| // At the moment only Builds and DeploymentConfig API can be disabled. | ||
| // Other APIs will be added to the list as needed. | ||
| for _, group := range c.ExtraConfig.APIServers.PerGroupOptions { | ||
| if !configurableAPIList.Has(group.Name) { | ||
| return nil, fmt.Errorf("only %v APIs can be configured, %q is not supported", sets.List[openshiftcontrolplanev1.OpenShiftAPIserverName](configurableAPIList), group.Name) | ||
| } | ||
| if _, exists := apiServers[group.Name]; exists { | ||
| return nil, fmt.Errorf("list of enabled/disabled API servers contains a duplicated entry for %v", group.Name) | ||
| } | ||
| enabledVersions := sets.NewString(group.EnabledVersions...) | ||
| disabledVersions := sets.NewString(group.DisabledVersions...) | ||
|
|
||
| if enabledVersions.Intersection(disabledVersions).Len() > 0 { | ||
| return nil, fmt.Errorf("list of enabled and disabled versions for %q is not allowed to intersect: %v are in both lists", group.Name, enabledVersions.Intersection(disabledVersions).List()) | ||
| } | ||
| // Only v1 version is supported | ||
| for _, version := range enabledVersions.List() { | ||
| if version != "v1" { | ||
| return nil, fmt.Errorf("only v1 version is currently supported for %q: %v is not", group.Name, version) | ||
| } | ||
| } | ||
| for _, version := range disabledVersions.List() { | ||
| if version != "v1" { | ||
| return nil, fmt.Errorf("only v1 version is currently supported for %q: %v is not", group.Name, version) | ||
| } | ||
| } | ||
| apiServers[group.Name] = group | ||
| } | ||
|
|
||
| // All API servers are enabled by default (nothing new to enable -> ignore the list of enabled versions) | ||
| for name, initFnc := range apiServerInitializers { | ||
| if _, exists := apiServers[name]; exists { | ||
| // All API servers are serving v1 resources | ||
| if sets.NewString(apiServers[name].DisabledVersions...).Has("v1") { | ||
| continue | ||
| } | ||
| } | ||
| delegateAPIServer = addAPIServerOrDie(delegateAPIServer, initFnc) | ||
| } |
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.
nit: could you move that code inside a function to make New more readable?
dgrisonnet
left a comment
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.
/lgtm
/approve
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dgrisonnet, ingvagabund The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@ingvagabund: The following test failed, say
Full PR test history. Your PR dashboard. 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/test-infra repository. I understand the commands that are listed here. |
Extend the OA init code to explicitly disable individual apiservers. The change is important for explicitly disabling DeploymentConfigs and Builds API through capabilities. The controlplane configuration on-disk data type gets rendered by OA operator in openshift/cluster-openshift-apiserver-operator#532.