mirror of
https://github.com/niusmallnan/steve.git
synced 2025-07-17 16:11:15 +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) {
|
||||
result, err := s.byID(apiOp, schema, id)
|
||||
result, err := s.byID(apiOp, schema, apiOp.Namespace, id)
|
||||
return toAPI(schema, result), err
|
||||
}
|
||||
|
||||
@ -117,8 +117,8 @@ func toAPI(schema *types.APISchema, obj runtime.Object) types.APIObject {
|
||||
return apiObject
|
||||
}
|
||||
|
||||
func (s *Store) byID(apiOp *types.APIRequest, schema *types.APISchema, id string) (*unstructured.Unstructured, error) {
|
||||
k8sClient, err := s.clientGetter.TableClient(apiOp, schema, apiOp.Namespace)
|
||||
func (s *Store) byID(apiOp *types.APIRequest, schema *types.APISchema, namespace, id string) (*unstructured.Unstructured, error) {
|
||||
k8sClient, err := s.clientGetter.TableClient(apiOp, schema, namespace)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -312,7 +312,7 @@ func (s *Store) listAndWatch(apiOp *types.APIRequest, k8sClient dynamic.Resource
|
||||
if s.notifier != nil {
|
||||
eg.Go(func() error {
|
||||
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 {
|
||||
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
|
||||
}
|
||||
|
||||
obj, err := s.byID(apiOp, schema, id)
|
||||
obj, err := s.byID(apiOp, schema, apiOp.Namespace, id)
|
||||
if err != nil {
|
||||
// ignore lookup error
|
||||
return types.APIObject{}, validation.ErrorCode{
|
||||
|
@ -80,11 +80,10 @@ func (s *SummaryCache) OnInboundRelationshipChange(ctx context.Context, schema *
|
||||
s.cbs[id] = cb
|
||||
|
||||
go func() {
|
||||
defer close(ret)
|
||||
for rel := range cb {
|
||||
if rel.Kind == kind &&
|
||||
rel.APIVersion == apiVersion &&
|
||||
rel.Namespace == namespace {
|
||||
(namespace == "" || namespace == rel.Namespace) {
|
||||
ret <- rel
|
||||
}
|
||||
}
|
||||
@ -95,10 +94,11 @@ func (s *SummaryCache) OnInboundRelationshipChange(ctx context.Context, schema *
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
close(cb)
|
||||
defer close(ret)
|
||||
delete(s.cbs, id)
|
||||
}()
|
||||
|
||||
return cb
|
||||
return ret
|
||||
}
|
||||
|
||||
func (s *SummaryCache) SummaryAndRelationship(obj runtime.Object) (*summary.SummarizedObject, []Relationship) {
|
||||
|
Loading…
Reference in New Issue
Block a user