Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api Refactor: Implement List Agents #1674

Merged
merged 2 commits into from
Jun 26, 2020

Conversation

MarcosDY
Copy link
Collaborator

  • Implement list agent
  • Refactor datastore.ListAttestedNodes to allow filtering and returns
    selectors on demand.

Which issue this PR fixes
fixes #1634

Id: ProtoFromID(spiffeID),
X509SvidExpiresAt: n.CertNotAfter,
X509SvidSerialNumber: n.CertSerialNumber,
Banned: n.CertSerialNumber == "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a function to detect if an agent is banned or not in the BanAgent PR.
If that PR get merged first, maybe we could use that method here: nodeutil.IsAgentBanned(...)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I was waiting for that merge to use it

pkg/server/api/agent/v1/service.go Outdated Show resolved Hide resolved
pkg/server/api/agent/v1/service_test.go Outdated Show resolved Hide resolved
pkg/server/api/agent/v1/service_test.go Outdated Show resolved Hide resolved
pkg/server/api/agent/v1/service_test.go Outdated Show resolved Hide resolved
pkg/server/api/agent_test.go Outdated Show resolved Hide resolved
pkg/server/api/agent_test.go Outdated Show resolved Hide resolved
pkg/server/api/agent/v1/service.go Outdated Show resolved Hide resolved
tx, err = applyPagination(p, tx)
func listAttestedNodes(ctx context.Context, db *sqlDB, req *datastore.ListAttestedNodesRequest) (*datastore.ListAttestedNodesResponse, error) {
if req.Pagination != nil && req.Pagination.PageSize == 0 {
return nil, status.Error(codes.InvalidArgument, "cannot paginate with pagesize = 0")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return nil, status.Error(codes.InvalidArgument, "cannot paginate with pagesize = 0")
return nil, status.Error(codes.InvalidArgument, "cannot paginate with zero length page size")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have the same message for all pagination uses, may we update all of them?

pkg/server/plugin/datastore/sql/sql_test.go Show resolved Hide resolved
pkg/server/plugin/datastore/sql/sql.go Outdated Show resolved Hide resolved
pkg/server/plugin/datastore/sql/sql.go Outdated Show resolved Hide resolved
pkg/server/plugin/datastore/sql/sql.go Outdated Show resolved Hide resolved
pkg/server/plugin/datastore/sql/sql.go Outdated Show resolved Hide resolved
pkg/server/plugin/datastore/sql/sql.go Outdated Show resolved Hide resolved
pkg/server/plugin/datastore/sql/sql.go Outdated Show resolved Hide resolved
pkg/server/plugin/datastore/sql/sql.go Outdated Show resolved Hide resolved
pkg/server/plugin/datastore/sql/sql.go Outdated Show resolved Hide resolved
pkg/server/plugin/datastore/sql/sql.go Outdated Show resolved Hide resolved
pkg/server/plugin/datastore/sql/sql.go Outdated Show resolved Hide resolved
pkg/server/api/agent/v1/service.go Outdated Show resolved Hide resolved
pkg/server/api/agent/v1/service_test.go Outdated Show resolved Hide resolved
azdagron
azdagron previously approved these changes Jun 26, 2020
Copy link
Member

@azdagron azdagron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with one nit

_, err = s.ds.CreateAttestedNode(ctx, &datastore.CreateAttestedNodeRequest{Node: aNode5})
s.Require().NoError(err)

aNode1WithSelectors := proto.Clone(aNode1).(*common.AttestedNode)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add helper function to clone attested node. It minimizes the number of type assertions one has to look at :)

@azdagron
Copy link
Member

Thanks for taking this on @MarcosDY :) That SQL plugin is a monster to work with :)

- Implement list agent
- Refactor datastore.ListAttestedNodes to allow filtering and returns
selectors on demand.

Signed-off-by: Marcos Yacob <marcos@scytale.io>
@amartinezfayo amartinezfayo merged commit df253c8 into spiffe:master Jun 26, 2020
@MarcosDY MarcosDY deleted the api-refactor-list-agents branch August 2, 2022 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API Refactor: Implement Agent.ListAgents RPC
4 participants