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

Filter pools based on labels #817

Closed
wants to merge 5 commits into from

Conversation

sinhaashish
Copy link
Member

This will be used for the command
kubectl mayastor get pools --labels A=B,C=D

control-plane/grpc/proto/v1/pool/pool.proto Outdated Show resolved Hide resolved
control-plane/agents/src/bin/core/pool/registry.rs Outdated Show resolved Hide resolved
pool_labels: HashMap<String, String>,
labels: Labels,
) -> Result<bool, SvcError> {
for label in labels.split(',') {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused, doesn't the hashmap already have key and value? Why do we need further parsing?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, the query params comes as a string lie A=B,C=D and here it is parsed. The labels of the pool are a hashmap

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like that's an openapi limitation due to using query rather than body.
Let's change it from string to hashmap on the grpc proto.

control-plane/rest/openapi-specs/v0_api_spec.yaml Outdated Show resolved Hide resolved
name: topology_label
required: true
schema:
$ref: '#/components/schemas/TopologyLabel'
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be a map?

Copy link
Member Author

Choose a reason for hiding this comment

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

topology_label is a query param, and its passed as string A=B,C=D,E=F . Cant pass map as a query param .

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright, then let's label the type TopologyLabels and add comments to say how it's meant to be used

@@ -117,6 +117,7 @@ impl From<CtrlPoolState> for models::PoolState {

rpc_impl_string_id!(PoolId, "ID of a pool");
rpc_impl_string_uuid!(PoolUuid, "UUID of a pool");
rpc_impl_string_id!(Labels, "Labels of a pool");
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we adding labels as an identifier?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is used as a filter criteria here

Signed-off-by: sinhaashish <ashi.sinha.87@gmail.com>
Signed-off-by: sinhaashish <ashi.sinha.87@gmail.com>
Signed-off-by: sinhaashish <ashi.sinha.87@gmail.com>
Signed-off-by: sinhaashish <ashi.sinha.87@gmail.com>
…ator

Signed-off-by: sinhaashish <ashi.sinha.87@gmail.com>
@sinhaashish
Copy link
Member Author

closing this as PR #823 contains the same functionality and is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants