mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 09:49:50 +00:00
Make local APIService objects available on create
This commit is contained in:
parent
9a8b111c9c
commit
d353adc467
@ -20,6 +20,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"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]}
|
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
|
// SetAPIServiceCondition sets the status condition. It either overwrites the existing one or
|
||||||
// creates a new one
|
// creates a new one
|
||||||
func SetAPIServiceCondition(apiService *APIService, newCondition APIServiceCondition) {
|
func SetAPIServiceCondition(apiService *APIService, newCondition APIServiceCondition) {
|
||||||
|
@ -120,10 +120,7 @@ func (c *AvailableConditionController) sync(key string) error {
|
|||||||
|
|
||||||
// local API services are always considered available
|
// local API services are always considered available
|
||||||
if apiService.Spec.Service == nil {
|
if apiService.Spec.Service == nil {
|
||||||
availableCondition.Status = apiregistration.ConditionTrue
|
apiregistration.SetAPIServiceCondition(apiService, apiregistration.NewLocalAvailableAPIServiceCondition())
|
||||||
availableCondition.Reason = "Local"
|
|
||||||
availableCondition.Message = "Local APIServices are always available"
|
|
||||||
apiregistration.SetAPIServiceCondition(apiService, availableCondition)
|
|
||||||
_, err := c.apiServiceClient.APIServices().UpdateStatus(apiService)
|
_, err := c.apiServiceClient.APIServices().UpdateStatus(apiService)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,11 @@ func (apiServerStrategy) NamespaceScoped() bool {
|
|||||||
func (apiServerStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) {
|
func (apiServerStrategy) PrepareForCreate(ctx genericapirequest.Context, obj runtime.Object) {
|
||||||
apiservice := obj.(*apiregistration.APIService)
|
apiservice := obj.(*apiregistration.APIService)
|
||||||
apiservice.Status = apiregistration.APIServiceStatus{}
|
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) {
|
func (apiServerStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runtime.Object) {
|
||||||
|
Loading…
Reference in New Issue
Block a user