Skip to content

feat(kafka acl): add instance-id flag and use all alias#1217

Merged
rkpattnaik780 merged 2 commits intomainfrom
acl_instance_id
Oct 13, 2021
Merged

feat(kafka acl): add instance-id flag and use all alias#1217
rkpattnaik780 merged 2 commits intomainfrom
acl_instance_id

Conversation

@rkpattnaik780
Copy link
Contributor

  • User should be able to explicitly provide a Kafka instance ID for ACL commands.
  • all alias for kafka acl grant-permissions.

Closes #1203 , #1200

Verification Steps

  1. The following command should grant all users permission to write to topic "random-topic" in the specified Kafka instance.
./rhoas kafka acl grant-permissions --producer --user all --topic random-topic --instance-id c5hv7iru4an1g84pogp0

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation change
  • Other (please specify)

Checklist

  • Documentation added for the feature
  • CI and all relevant tests are passing
  • Code Review completed
  • Verified independently by reviewer

Copy link
Collaborator

@wtrocki wtrocki left a comment

Choose a reason for hiding this comment

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

Looks and works good. Putting giberish into instance-id will return 404. Maybe we can have some message for it (but not required to merge)

@rkpattnaik780
Copy link
Contributor Author

Looks and works good. Putting giberish into instance-id will return 404. Maybe we can have some message for it (but not required to merge)

We are getiing a ❌ Kafka instance with ID "c5hsdjsdjksdjfjf" not found. Run the command in verbose mode using the -v flag to see more information

@rkpattnaik780 rkpattnaik780 requested a review from wtrocki October 13, 2021 06:51
Copy link
Contributor

@craicoverflow craicoverflow left a comment

Choose a reason for hiding this comment

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

This is great. We are missing dynamic auto completions though for loading the instance IDs from the server. It would be great to add this either now or in a follow up PR.


# Grant access to principal for producing messages to all topics
$ rhoas kafka acl grant-permissions --producer --user user_name --topic "*"
$ rhoas kafka acl grant-permissions --producer --user user_name --topic all
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have an example for both?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure myself. @rkpattnaik780 feel free to make call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Won't prefer having asterisk as an example.

cmd.Flags().BoolVar(&opts.producer, "producer", false, opts.localizer.MustLocalize("kafka.acl.grantPermissions.flag.producer.description"))
cmd.Flags().StringVar(&opts.topicPrefix, "topic-prefix", "", opts.localizer.MustLocalize("kafka.acl.common.flag.topicPrefix.description"))
cmd.Flags().StringVar(&opts.groupPrefix, "group-prefix", "", opts.localizer.MustLocalize("kafka.acl.common.flag.groupPrefix.description"))
cmd.Flags().StringVar(&opts.kafkaID, "instance-id", "", opts.localizer.MustLocalize("kafka.acl.common.flag.instance.id"))
Copy link
Contributor

Choose a reason for hiding this comment

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

What would your thoughts be if we make this a persistent flag at the acl command level? This would save having to add it to every acl subcommand.

Copy link
Collaborator

@wtrocki wtrocki Oct 13, 2021

Choose a reason for hiding this comment

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

Can we create persistent flag without redefiniing it to set opts.kafkaID in the cmd?
That will probably require some packaged scoped variable that all commands will read?

Not sure if there is clever way that is as clean as defining that flag in every command

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, we could have something similar for registry commands as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually @wtrocki is probably correct, we would need to have the value set in memory via a pointer like the debug flag for this work.

Feel free to explore the idea, but it may not be worth it.

Copy link
Collaborator

@wtrocki wtrocki Oct 13, 2021

Choose a reason for hiding this comment

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

Ideally we can apply instance-id to numerous commands as in #685 so we can think about this clever way and then change it across CLI. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

skipping, to be addressed along with 685

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@craicoverflow , filtering by id column seems to be unsupported in Admin API. Should we raise it to admin api team, this would enable completions at multiple places.

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 not sure what you mean, why does the admin API require ID filtering?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I meant for auto completions of --instance-id

Copy link
Contributor

Choose a reason for hiding this comment

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

You mean the control plane API?

You could fetch all IDs and cache them. I don't think we need to have filtering in the API for it for this one use case.

@rkpattnaik780 rkpattnaik780 merged commit e5671ba into main Oct 13, 2021
@rkpattnaik780 rkpattnaik780 deleted the acl_instance_id branch October 13, 2021 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants