class Gitlab::QA::Component::Base

def instance_no_teardown # rubocop:disable Metrics/AbcSize

rubocop:disable Metrics/AbcSize
def instance_no_teardown # rubocop:disable Metrics/AbcSize
  begin
    retries ||= 0
    prepare
    start
    reconfigure
    wait_until_ready
    process_exec_commands
  rescue Support::ShellCommand::StatusError => e
    reconfigure_log_file = get_reconfigure_log_file_from_artefact
    # for scenarios where a service fails during startup, attempt to retry to avoid flaky failures
    if (retries += 1) < 3
      unless reconfigure_log_file.nil?
        Runtime::Logger.info(
          "Follow the document " \
          "https://gitlab.com/gitlab-org/quality/runbooks/-/blob/main/debug_orchestrated_test_locally/ " \
          "for debugging the test failure locally.")
        # Tailing the reconfigure logs after retries are over and before raising exception
        Runtime::Logger.info("Tail of the reconfigure log file, see artifacts for full log: #{reconfigure_log_file}")
        Support::ShellCommand.new("tail -n 100 #{reconfigure_log_file}", stream_output: true).execute!
      end
      Runtime::Logger.warn(
        "Retry instance_no_teardown due to Support::ShellCommand::StatusError -- attempt #{retries}"
      )
      teardown!
      retry
    end
    # Printing logs to stdout for last retry failure
    if !reconfigure_log_file.nil? && retries == 3
      # Tailing the reconfigure logs after retries are over and before raising exception
      Runtime::Logger.info("Tail of the reconfigure log file, see artifacts for full log: #{reconfigure_log_file}")
      Support::ShellCommand.new("tail -n 100 #{reconfigure_log_file}", stream_output: true).execute!
    end
    raise e
  end
  yield self if block_given?
end