mirror of
https://github.com/niusmallnan/steve.git
synced 2025-07-18 00:21:12 +00:00
Fixed errors in obtaining object relationships
Issue: https://github.com/harvester/harvester/issues/1857
This commit is contained in:
parent
e7119828b8
commit
42c575a009
@ -80,7 +80,7 @@ func NewProxyStore(clientGetter ClientGetter, notifier RelationshipNotifier, loo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) ByID(apiOp *types.APIRequest, schema *types.APISchema, id string) (types.APIObject, error) {
|
func (s *Store) ByID(apiOp *types.APIRequest, schema *types.APISchema, id string) (types.APIObject, error) {
|
||||||
result, err := s.byID(apiOp, schema, id)
|
result, err := s.byID(apiOp, schema, apiOp.Namespace, id)
|
||||||
return toAPI(schema, result), err
|
return toAPI(schema, result), err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,8 +117,8 @@ func toAPI(schema *types.APISchema, obj runtime.Object) types.APIObject {
|
|||||||
return apiObject
|
return apiObject
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Store) byID(apiOp *types.APIRequest, schema *types.APISchema, id string) (*unstructured.Unstructured, error) {
|
func (s *Store) byID(apiOp *types.APIRequest, schema *types.APISchema, namespace, id string) (*unstructured.Unstructured, error) {
|
||||||
k8sClient, err := s.clientGetter.TableClient(apiOp, schema, apiOp.Namespace)
|
k8sClient, err := s.clientGetter.TableClient(apiOp, schema, namespace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -312,7 +312,7 @@ func (s *Store) listAndWatch(apiOp *types.APIRequest, k8sClient dynamic.Resource
|
|||||||
if s.notifier != nil {
|
if s.notifier != nil {
|
||||||
eg.Go(func() error {
|
eg.Go(func() error {
|
||||||
for rel := range s.notifier.OnInboundRelationshipChange(ctx, schema, apiOp.Namespace) {
|
for rel := range s.notifier.OnInboundRelationshipChange(ctx, schema, apiOp.Namespace) {
|
||||||
obj, err := s.byID(apiOp, schema, rel.Name)
|
obj, err := s.byID(apiOp, schema, rel.Namespace, rel.Name)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
result <- s.toAPIEvent(apiOp, schema, watch.Modified, obj)
|
result <- s.toAPIEvent(apiOp, schema, watch.Modified, obj)
|
||||||
}
|
}
|
||||||
@ -524,7 +524,7 @@ func (s *Store) Delete(apiOp *types.APIRequest, schema *types.APISchema, id stri
|
|||||||
return types.APIObject{}, err
|
return types.APIObject{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
obj, err := s.byID(apiOp, schema, id)
|
obj, err := s.byID(apiOp, schema, apiOp.Namespace, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// ignore lookup error
|
// ignore lookup error
|
||||||
return types.APIObject{}, validation.ErrorCode{
|
return types.APIObject{}, validation.ErrorCode{
|
||||||
|
@ -80,11 +80,10 @@ func (s *SummaryCache) OnInboundRelationshipChange(ctx context.Context, schema *
|
|||||||
s.cbs[id] = cb
|
s.cbs[id] = cb
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer close(ret)
|
|
||||||
for rel := range cb {
|
for rel := range cb {
|
||||||
if rel.Kind == kind &&
|
if rel.Kind == kind &&
|
||||||
rel.APIVersion == apiVersion &&
|
rel.APIVersion == apiVersion &&
|
||||||
rel.Namespace == namespace {
|
(namespace == "" || namespace == rel.Namespace) {
|
||||||
ret <- rel
|
ret <- rel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,10 +94,11 @@ func (s *SummaryCache) OnInboundRelationshipChange(ctx context.Context, schema *
|
|||||||
s.Lock()
|
s.Lock()
|
||||||
defer s.Unlock()
|
defer s.Unlock()
|
||||||
close(cb)
|
close(cb)
|
||||||
|
defer close(ret)
|
||||||
delete(s.cbs, id)
|
delete(s.cbs, id)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return cb
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SummaryCache) SummaryAndRelationship(obj runtime.Object) (*summary.SummarizedObject, []Relationship) {
|
func (s *SummaryCache) SummaryAndRelationship(obj runtime.Object) (*summary.SummarizedObject, []Relationship) {
|
||||||
|
Loading…
Reference in New Issue
Block a user