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

Start-TopicCommand not working is KNetPS #575

Closed
Rom4ig opened this issue Jul 30, 2024 · 3 comments · Fixed by #579
Closed

Start-TopicCommand not working is KNetPS #575

Rom4ig opened this issue Jul 30, 2024 · 3 comments · Fixed by #579
Assignees
Labels
bug Something isn't working KNetPS KNetPS related issue

Comments

@Rom4ig
Copy link

Rom4ig commented Jul 30, 2024

Describe the bug
Start-TopicCommand -Arguments "--list " doesn't work

To Reproduce
Steps to reproduce the behavior:

  1. Write is PowerShell Start-TopicCommand -Arguments "--list" -Verbose
  2. See errors in the start and end

Expected behavior
No errors

Screenshots
Start
image
Translate from RUS: Cannot find a positional parameter that takes an argument.

End
image

Desktop (please complete the following information):

  • OS: Windows
  • Version 10
  • PS v5.1

Additional context
Where I can find more info about KNetPS?
For example:
Syntax of Start-TopicCommand?
About creating topics?

@masesdevelopers masesdevelopers self-assigned this Jul 30, 2024
@masesdevelopers masesdevelopers added bug Something isn't working KNetPS KNetPS related issue labels Jul 30, 2024
@masesdevelopers
Copy link
Contributor

The problem is related to a name mismatch introduced with masesgroup/JNet#451, we don't have introduced yet an automatic test for PowerShell extension.
About your questions:

  • KNetPS mainly is a PowerShell wrapper for Apache Kafka command-line commands, plus can be used to create PowerShell scripts
  • Some information are available in https://knet.masesgroup.com/articles/usagePS.html
  • As stated in KNetPS module Arguments is a string containing the arguments accepted from the Java Main-Class so, in general, you can launch the command (e.g. Start-TopicCommand) and see the help of the command, otherwise you can browse the information available in official Apache Kafka site

@masesdevelopers
Copy link
Contributor

masesdevelopers commented Jul 31, 2024

Updating to JNet 2.5.8 the specific Start-TopicCommand raises other issues:
image
While other commands like Start-AclCommand works fine:
image

Looking at the code of both classes they are managed in different ways:

public static void Main(params Java.Lang.String[] arg0)

and
public static void Main(Java.Lang.String[] args)

Multiple classes follows the same behavior of TopicCommand:
image
and all of them are under package org.apache.kafka.tools. All the classes are managed using JNetReflector and the current version manages methods like the following one

public abstract class TopicCommand {
    private static final Logger LOG = LoggerFactory.getLogger(TopicCommand.class);

    public static void main(String... args) {
        Exit.exit(mainNoExit(args));
    }

creating a static method which manages the variable arguments. However the invocation of a main method expects something like:

object AclCommand extends Logging {

  val AuthorizerDeprecationMessage: String = "Warning: support for ACL configuration directly " +
    "through the authorizer is deprecated and will be removed in a future release. Please use " +
    "--bootstrap-server instead to set ACLs through the admin client."
  val ClusterResourceFilter = new ResourcePatternFilter(JResourceType.CLUSTER, JResource.CLUSTER_NAME, PatternType.LITERAL)

  private val Newline = scala.util.Properties.lineSeparator

  def main(args: Array[String]): Unit = {

or

public final class MetadataShell {
// other class code

    public static void main(String[] args) throws Exception {
        // main boby
    }

An enhancement shall be requested to JNetReflector to manage main method always as a single array input despite it is defined using variable arguments like in the case of TopicCommand.

Meanwhile, since the number of commands that contains variable arguments is limited, a manual update shall be done on the classes. Change from

        public static void Main(params Java.Lang.String[] arg0)
        {
            if (arg0.Length == 0) SExecuteWithSignature(LocalBridgeClazz, "main", "([Ljava/lang/String;)V"); else SExecuteWithSignature(LocalBridgeClazz, "main", "([Ljava/lang/String;)V", arg0);
        }

to

        public static void Main(Java.Lang.String[] arg0)
        {
            SExecuteWithSignature(LocalBridgeClazz, "main", "([Ljava/lang/String;)V", new object[] { arg0 });
        }

@masesdevelopers
Copy link
Contributor

With version 2.7.8 the issue raises is resolved, look at the test below:

image

In the test it is reported a possible usage of Start-TopicCommand cmdlet similar to the one reported when the bug was opened. The command used

Start-TopicCommand -Arguments "--bootstrap-server 192.168.0.101:9092 --list"

contains in the Arguments a string with arguments accepted from TopicCommand class and specifically the mandatory bootstrap-server which identify, at least, a broker to be contacted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working KNetPS KNetPS related issue
Projects
None yet
2 participants