mirror of
https://github.com/rancher/steve.git
synced 2025-09-13 05:49:16 +00:00
Ensure database is reset after an api-service change. (#785)
This commit is contained in:
@@ -52,6 +52,7 @@ type handler struct {
|
||||
changedIDs map[k8sapimachineryschema.GroupVersionKind]bool
|
||||
createdCRDs map[k8sapimachineryschema.GroupVersionKind]bool
|
||||
deletedCRDs map[k8sapimachineryschema.GroupVersionKind]bool
|
||||
apiServiceChanged bool
|
||||
gvksFromKeys map[string][]k8sapimachineryschema.GroupVersionKind
|
||||
}
|
||||
|
||||
@@ -123,6 +124,7 @@ func (h *handler) OnChangeCRD(key string, crd *apiextv1.CustomResourceDefinition
|
||||
}
|
||||
|
||||
func (h *handler) OnChangeAPIService(key string, api *apiv1.APIService) (*apiv1.APIService, error) {
|
||||
h.apiServiceChanged = true
|
||||
h.queueRefresh()
|
||||
return api, nil
|
||||
}
|
||||
@@ -136,6 +138,7 @@ func (h *handler) queueRefresh() {
|
||||
var changedIDs map[k8sapimachineryschema.GroupVersionKind]bool
|
||||
var deletedCRDs map[k8sapimachineryschema.GroupVersionKind]bool
|
||||
var createdCRDs map[k8sapimachineryschema.GroupVersionKind]bool
|
||||
var apiServiceChanged bool
|
||||
h.Lock()
|
||||
if len(h.createdCRDs) > 0 {
|
||||
createdCRDs = h.createdCRDs
|
||||
@@ -149,9 +152,13 @@ func (h *handler) queueRefresh() {
|
||||
changedIDs = h.changedIDs
|
||||
h.changedIDs = make(map[k8sapimachineryschema.GroupVersionKind]bool)
|
||||
}
|
||||
if h.apiServiceChanged {
|
||||
apiServiceChanged = true
|
||||
h.apiServiceChanged = false
|
||||
}
|
||||
h.Unlock()
|
||||
crdNumCountChanged := len(deletedCRDs) > 0 || len(createdCRDs) > 0
|
||||
if len(changedIDs) > 0 || crdNumCountChanged {
|
||||
if len(changedIDs) > 0 || apiServiceChanged || crdNumCountChanged {
|
||||
err = h.refreshAll(h.ctx, changedIDs, crdNumCountChanged)
|
||||
}
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user