warningOnRetry shows up even with no retry/failure
### Expected Behavior

`warningOnRetry` should only shows a warning when an actual retry is done

### Actual Behaviour

The following Flow ends on warning state while there is no retry or failure

```
  - id: this-does-not-retry
    type: io.kestra.plugin.scripts.shell.Commands
    runner: PROCESS
    commands:
      - 'echo "foo"'
    retry:
      type: constant
      interval: PT0.25S
      maxAttempt: 2
      maxDuration: PT1M
      warningOnRetry: true
```
     
![image](https://github.com/kestra-io/kestra/assets/46634684/ee6cb4de-fb1f-4149-bfd8-462c88ef7390)


### Steps To Reproduce

_No response_

### Environment Information

- Kestra Version:
- Operating System (OS / Docker / Kubernetes):
- Java Version (If not docker):


### Example flow

_No response_
core/src/main/java/io/kestra/core/runners/Worker.java
core/src/main/java/io/kestra/core/runners/Worker.java
core/src/test/java/io/kestra/core/runners/RetryTest.java core/src/test/resources/flows/valids/retry-success-first-attempt.yaml
diff --git a/core/src/main/java/io/kestra/core/runners/Worker.java b/core/src/main/java/io/kestra/core/runners/Worker.java
index ef8264d86d..d748e79f22 100644
--- a/core/src/main/java/io/kestra/core/runners/Worker.java
+++ b/core/src/main/java/io/kestra/core/runners/Worker.java
@@ -355,7 +355,7 @@ private WorkerTaskResult run(WorkerTask workerTask, Boolean cleanUp) throws Queu
 
         if (workerTask.getTask().getRetry() != null &&
             workerTask.getTask().getRetry().getWarningOnRetry() &&
-            finalWorkerTask.getTaskRun().getAttempts().size() > 0 &&
+            finalWorkerTask.getTaskRun().attemptNumber() > 1 &&
             state == State.Type.SUCCESS
         ) {
             state = State.Type.WARNING;

diff --git a/core/src/test/java/io/kestra/core/runners/RetryTest.java b/core/src/test/java/io/kestra/core/runners/RetryTest.java
index de5b7f6a28..bc2c1d54d7 100644
--- a/core/src/test/java/io/kestra/core/runners/RetryTest.java
+++ b/core/src/test/java/io/kestra/core/runners/RetryTest.java
@@ -29,6 +29,15 @@ void retrySuccess() throws TimeoutException {
         assertThat(execution.getTaskRunList().get(0).getAttempts(), hasSize(5));
     }
 
+    @Test
+    void retrySuccessAtFirstAttempt() throws TimeoutException {
+        Execution execution = runnerUtils.runOne("io.kestra.tests", "retry-success-first-attempt");
+
+        assertThat(execution.getState().getCurrent(), is(State.Type.SUCCESS));
+        assertThat(execution.getTaskRunList(), hasSize(1));
+        assertThat(execution.getTaskRunList().get(0).getAttempts(), hasSize(1));
+    }
+
     @Test
     void retryFailed() throws TimeoutException {
         List<Execution> executions = new ArrayList<>();
diff --git a/core/src/test/resources/flows/valids/retry-success-first-attempt.yaml b/core/src/test/resources/flows/valids/retry-success-first-attempt.yaml
new file mode 100644
index 0000000000..d959f09e7b
--- /dev/null
+++ b/core/src/test/resources/flows/valids/retry-success-first-attempt.yaml
@@ -0,0 +1,18 @@
+id: retry-success-first-attempt
+namespace: io.kestra.tests
+
+tasks:
+- id: not-retry-and-no-warning
+  type: io.kestra.core.tasks.log.Log
+  message: "foo"
+  retry:
+    type: constant
+    interval: PT0.250S
+    maxAttempt: 5
+    maxDuration: PT15S
+    warningOnRetry: true
+
+errors:
+  - id: never-happen
+    type: io.kestra.core.tasks.log.Log
+    message: Never {{task.id}}
