mirror of https://github.com/hashicorp/consul
rpc: add errNotFound to all Get queries
Any query that returns a list of items is not part of this commit.pull/12110/head
parent
4b33bdf396
commit
8a6e75ac81
|
@ -322,6 +322,9 @@ func (a *ACL) TokenRead(args *structs.ACLTokenGetRequest, reply *structs.ACLToke
|
|||
|
||||
reply.Index, reply.Token = index, token
|
||||
reply.SourceDatacenter = args.Datacenter
|
||||
if token == nil {
|
||||
return errNotFound
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
@ -1045,6 +1048,9 @@ func (a *ACL) PolicyRead(args *structs.ACLPolicyGetRequest, reply *structs.ACLPo
|
|||
}
|
||||
|
||||
reply.Index, reply.Policy = index, policy
|
||||
if policy == nil {
|
||||
return errNotFound
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
@ -1428,6 +1434,9 @@ func (a *ACL) RoleRead(args *structs.ACLRoleGetRequest, reply *structs.ACLRoleRe
|
|||
}
|
||||
|
||||
reply.Index, reply.Role = index, role
|
||||
if role == nil {
|
||||
return errNotFound
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
@ -1795,12 +1804,14 @@ func (a *ACL) BindingRuleRead(args *structs.ACLBindingRuleGetRequest, reply *str
|
|||
return a.srv.blockingQuery(&args.QueryOptions, &reply.QueryMeta,
|
||||
func(ws memdb.WatchSet, state *state.Store) error {
|
||||
index, rule, err := state.ACLBindingRuleGetByID(ws, args.BindingRuleID, &args.EnterpriseMeta)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
reply.Index, reply.BindingRule = index, rule
|
||||
if rule == nil {
|
||||
return errNotFound
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
@ -2052,16 +2063,16 @@ func (a *ACL) AuthMethodRead(args *structs.ACLAuthMethodGetRequest, reply *struc
|
|||
return a.srv.blockingQuery(&args.QueryOptions, &reply.QueryMeta,
|
||||
func(ws memdb.WatchSet, state *state.Store) error {
|
||||
index, method, err := state.ACLAuthMethodGetByName(ws, args.AuthMethodName, &args.EnterpriseMeta)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if method != nil {
|
||||
_ = a.enterpriseAuthMethodTypeValidation(method.Type)
|
||||
reply.Index, reply.AuthMethod = index, method
|
||||
if method == nil {
|
||||
return errNotFound
|
||||
}
|
||||
|
||||
reply.Index, reply.AuthMethod = index, method
|
||||
_ = a.enterpriseAuthMethodTypeValidation(method.Type)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
|
|
@ -267,6 +267,7 @@ func (c *Coordinate) Node(args *structs.NodeSpecificRequest, reply *structs.Inde
|
|||
})
|
||||
}
|
||||
reply.Index, reply.Coordinates = index, coords
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ func (c *FederationState) Get(args *structs.FederationStateQuery, reply *structs
|
|||
|
||||
reply.Index = index
|
||||
if fedState == nil {
|
||||
return nil
|
||||
return errNotFound
|
||||
}
|
||||
|
||||
reply.State = fedState
|
||||
|
|
|
@ -160,18 +160,13 @@ func (k *KVS) Get(args *structs.KeyRequest, reply *structs.IndexedDirEntries) er
|
|||
}
|
||||
|
||||
if ent == nil {
|
||||
// Must provide non-zero index to prevent blocking
|
||||
// Index 1 is impossible anyways (due to Raft internals)
|
||||
if index == 0 {
|
||||
reply.Index = 1
|
||||
} else {
|
||||
reply.Index = index
|
||||
}
|
||||
reply.Index = index
|
||||
reply.Entries = nil
|
||||
} else {
|
||||
reply.Index = ent.ModifyIndex
|
||||
reply.Entries = structs.DirEntries{ent}
|
||||
return errNotFound
|
||||
}
|
||||
|
||||
reply.Index = ent.ModifyIndex
|
||||
reply.Entries = structs.DirEntries{ent}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
|
|
@ -198,6 +198,7 @@ func (s *Session) Get(args *structs.SessionSpecificRequest,
|
|||
reply.Sessions = structs.Sessions{session}
|
||||
} else {
|
||||
reply.Sessions = nil
|
||||
return errNotFound
|
||||
}
|
||||
s.srv.filterACLWithAuthorizer(authz, reply)
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue