diff --git a/qa/qa/tools/test_resource_data_processor.rb b/qa/qa/tools/test_resource_data_processor.rb
index 3312285ecc488fd9303eb6842004d84fb229e60d..7c72aa9ee00e59710baab722a53077e652c58890 100644
--- a/qa/qa/tools/test_resource_data_processor.rb
+++ b/qa/qa/tools/test_resource_data_processor.rb
@@ -52,20 +52,31 @@ def collect(resource:, info:, fabrication_method:, fabrication_time:)
       def write_to_file(suite_failed)
         return if resources.empty?
 
-        start_str = suite_failed ? 'failed-test-resources' : 'test-resources'
+        start_str = mark_as_failed?(suite_failed) ? 'failed-test-resources' : 'test-resources'
         file_name = Runtime::Env.running_in_ci? ? "#{start_str}-#{SecureRandom.hex(3)}.json" : "#{start_str}.json"
         file = Pathname.new(File.join(Runtime::Path.qa_root, 'tmp', file_name))
         FileUtils.mkdir_p(file.dirname)
 
         data = resources.deep_dup
         # merge existing json if present
-        JSON.parse(File.read(file)).deep_merge!(data) { |key, val, other_val| val + other_val } if file.exist?
+        JSON.parse(File.read(file)).deep_merge!(data) { |_, val, other_val| val + other_val } if file.exist?
 
         File.write(file, JSON.pretty_generate(data))
       end
 
       private
 
+      # Check if resource file should be marked as failed
+      #
+      # @param [Boolean] suite_failed
+      # @return [Boolean]
+      def mark_as_failed?(suite_failed)
+        return suite_failed unless ::Gitlab::QA::Runtime::Env.retry_failed_specs?
+
+        # if suite ran in the initial run, do not mark resource as failed even if suite failed
+        Runtime::Env.rspec_retried? ? suite_failed : false
+      end
+
       # Determine resource api path or return default value
       # Some resources fabricated via UI can raise no attribute error
       #
diff --git a/qa/spec/tools/test_resources_data_processor_spec.rb b/qa/spec/tools/test_resources_data_processor_spec.rb
index 73fc2f6e8532ac63472b846a3134b78497ab9282..e5f6ccb35cb6eb5cf6f8c528fd4c314cd02f8c02 100644
--- a/qa/spec/tools/test_resources_data_processor_spec.rb
+++ b/qa/spec/tools/test_resources_data_processor_spec.rb
@@ -43,11 +43,13 @@
   describe '.write_to_file' do
     using RSpec::Parameterized::TableSyntax
 
-    where(:ci, :suite_failed, :file_path) do
-      true  | true  | 'root/tmp/failed-test-resources-random.json'
-      true  | false | 'root/tmp/test-resources-random.json'
-      false | true  | 'root/tmp/failed-test-resources.json'
-      false | false | 'root/tmp/test-resources.json'
+    where(:ci, :suite_failed, :retry_failed_specs, :rspec_retried, :file_path) do
+      true  | true  | false | false | 'root/tmp/failed-test-resources-random.json'
+      true  | false | false | false | 'root/tmp/test-resources-random.json'
+      false | true  | false | false | 'root/tmp/failed-test-resources.json'
+      false | false | false | false | 'root/tmp/test-resources.json'
+      false | true  | true  | false | 'root/tmp/test-resources.json'
+      false | true  | true  | true  | 'root/tmp/failed-test-resources.json'
     end
 
     with_them do
@@ -55,8 +57,10 @@
 
       before do
         allow(QA::Runtime::Env).to receive(:running_in_ci?).and_return(ci)
-        allow(File).to receive(:write)
+        allow(QA::Runtime::Env).to receive(:rspec_retried?).and_return(rspec_retried)
         allow(QA::Runtime::Path).to receive(:qa_root).and_return('root')
+        allow(::Gitlab::QA::Runtime::Env).to receive(:retry_failed_specs?).and_return(retry_failed_specs)
+        allow(File).to receive(:write)
         allow(SecureRandom).to receive(:hex).with(any_args).and_return('random')
       end