Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-10316

Add check to KinesisProducer that aws.region is set

    Details

      Description

      Related to: https://issues.apache.org/jira/browse/FLINK-9402

      A fix (Flink-9402) was introduced to force the configurations to have exactly one of "aws.region" or "aws.endpoint", but the underlying problem wasn't entirely fixed.

      If "aws.endpoint" is set and "aws.region" is unset, a different exception is thrown, instead.

      In KinesisConfigUtil.java, getValidatedProducerConfiguration() calls:

          validateAwsConfiguration(config)
      

      Where the original fix was introduced ("aws.region" XOR "aws.endpoint")
      But a couple of lines later, getValidatedProducerConfiguration() then calls:

          kpc.setRegion(config.getProperty(AWSConfigConstants.AWS_REGION));
      

      Which explicitly checks for the existence of "aws.region", and throws an exception if it is not set.
      Thus, this class needs to be fixed such that "aws.region" is only required if "aws.endpoint" is unset, as the original ticket indicated.

      Also, validateAwsConfiguration() has a minor bug where is labels the "aws.endpoint" incorrectly.
      Current:

      if (!(config.containsKey(AWSConfigConstants.AWS_REGION) ^ config.containsKey(ConsumerConfigConstants.AWS_ENDPOINT))) {
         // per validation in AwsClientBuilder
         throw new IllegalArgumentException(String.format("Either AWS region ('%s') or AWS endpoint ('%s') must be set in the config.",
            AWSConfigConstants.AWS_REGION, AWSConfigConstants.AWS_REGION));
      }
      

      But should be:

      if (!(config.containsKey(AWSConfigConstants.AWS_REGION) ^ config.containsKey(ConsumerConfigConstants.AWS_ENDPOINT))) {
         // per validation in AwsClientBuilder
         throw new IllegalArgumentException(String.format("Either AWS region ('%s') or AWS endpoint ('%s') must be set in the config.",
            AWSConfigConstants.AWS_REGION, ConsumerConfigConstants.AWS_ENDPOINT));
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                lazlolazarous Joseph Sims
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: