void removeKafkaTopics()

in src/com/epam/digital/data/platform/pipelines/registrycomponents/regular/Kafka.groovy [54:79]


    void removeKafkaTopics() {
        int attempt = 0
        int maxAttempts = 12
        Boolean kafkaTopicsRemoved = false
        while (!kafkaTopicsRemoved) {
            init()
            attempt++
            if (attempt > maxAttempts) {
                context.script.error("Attempts limit is reached and kafka topics were not removed yet!")
                kafkaTopicsRemoved = true
            }
            if (kafkaTopics.length() > 1) {
                try {
                    context.script.sh(script: "oc exec $KAFKA_BROKER_POD -c kafka -- bin/kafka-topics.sh " +
                            "--bootstrap-server $KAFKA_BOOTSTRAP_SERVER --delete --topic ${kafkaTopics.substring(0, kafkaTopics.length() - 1)}")
                } catch (any) {
                    kafkaTopicsRemoved = false
                    context.logger.info("Removing of kafka topics failed. Retrying (attempt $attempt/12)")
                }
            } else {
                kafkaTopicsRemoved = true
                context.logger.info("Kafka topics were successfully removed.")
            }

        }
    }