mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Make local APIService objects available on create
This commit is contained in:
parent
9a8b111c9c
commit
d353adc467
@ -20,6 +20,7 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
@ -85,6 +86,17 @@ func APIServiceNameToGroupVersion(apiServiceName string) schema.GroupVersion {
|
||||
return schema.GroupVersion{Group: tokens[1], Version: tokens[0]}
|
||||
}
|
||||
|
||||
// NewLocalAvailableAPIServiceCondition returns a condition for an available local APIService.
|
||||
func NewLocalAvailableAPIServiceCondition() APIServiceCondition {
|
||||
return APIServiceCondition{
|
||||
Type: Available,
|
||||
Status: ConditionTrue,
|
||||
LastTransitionTime: metav1.Now(),
|
||||
Reason: "Local",
|
||||
Message: "Local APIServices are always available",
|
||||
}
|
||||
}
|
||||
|
||||
// SetAPIServiceCondition sets the status condition. It either overwrites the existing one or
|
||||
// creates a new one
|
||||
func SetAPIServiceCondition(apiService *APIService, newCondition APIServiceCondition) {
|
||||
|
@ -120,10 +120,7 @@ func (c *AvailableConditionController) sync(key string) error {
|
||||
|
||||
// local API services are always considered available
|
||||
if apiService.Spec.Service == nil {
|
||||
availableCondition.Status = apiregistration.ConditionTrue
|
||||
availableCondition.Reason = "Local"
|
||||
availableCondition.Message = "Local APIServices are always available"
|
||||
apiregistration.SetAPIServiceCondition(apiService, availableCondition)
|
||||
apiregistration.SetAPIServiceCondition(apiService, apiregistration.NewLocalAvailableAPIServiceCondition())
|
||||
_, err := c.apiServiceClient.APIServices().UpdateStatus(apiService)
|
||||
return err
|
||||
}
|
||||
|
@ -48,6 +48,11 @@ func (apiServerStrategy) NamespaceScoped() bool {
|
||||
func (apiServerStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) {
|
||||
apiservice := obj.(*apiregistration.APIService)
|
||||
apiservice.Status = apiregistration.APIServiceStatus{}
|
||||
|
||||
// mark local API services as immediately available on create
|
||||
if apiservice.Spec.Service == nil {
|
||||
apiregistration.SetAPIServiceCondition(apiservice, apiregistration.NewLocalAvailableAPIServiceCondition())
|
||||
}
|
||||
}
|
||||
|
||||
func (apiServerStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) {
|
||||
|
Loading…
Reference in New Issue
Block a user