Repository: provectus/kafka-ui
Issue: Connector "Restart All Tasks" button has no effect
Labels: type/enhancement
scope/backend
scope/frontend
status/accepted
status/confirmed

When choosing a specific connector there are several options you can choose:
<img width="1083" alt="image" src="https://user-images.githubusercontent.com/94184844/150494050-67a4692f-2133-4c78-94e3-c74857b65057.png">

Restart all tasks sends the next POST request that actually does do nothing.
https://xxx/api/clusters/local/connects/local/connectors/reddit-source-json/action/RESTART

According to the REST API documentation https://docs.confluent.io/platform/current/connect/references/restapi.html there is no such request available. And the correct one is this:
<img width="904" alt="image" src="https://user-images.githubusercontent.com/94184844/150494299-2cffab5d-abb7-4e05-af35-f3af1a57a050.png">

Restarting the specific task using the triple dot context menu works great tho.

Issue comments:
@5hin0bi we currently only restart **connector instance**, not tasks on this button click. I will change this to restart both connector and all its tasks. I think we will also need to rename this button to smth like "Restart connector". 
cc @Haarolean 
@5hin0bi can you please verify it works, and reopen issue if not
Checked on our dev environment. The button is now called "Restart Connector", but failed tasks themselves are not restarted.
To do: create 3 buttons
Need to implement frontend
I'm seeing a similar error with KafkaConnect where it's trying to hit an api endpoint:
```500 Server Error for HTTP GET "/api/clusters/local/connectors?search="```
that also doesn't seem to exist, per Confluent's API. 
> I'm seeing a similar error with KafkaConnect where it's trying to hit an api endpoint: `500 Server Error for HTTP GET "/api/clusters/local/connectors?search="` that also doesn't seem to exist, per Confluent's API.

That's our backend with our API, not confluent's. Please raise a new issue.

Pull request review comments:

Patch that resolved the issue:
diff --git a/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/KafkaConnectService.java b/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/KafkaConnectService.java
index 74730e29f68..2d82a54217b 100644
--- a/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/KafkaConnectService.java
+++ b/kafka-ui-api/src/main/java/com/provectus/kafka/ui/service/KafkaConnectService.java
@@ -266,7 +266,8 @@ public Mono<Void> updateConnectorState(KafkaCluster cluster, String connectName,
     switch (action) {
       case RESTART:
         kafkaClientCall =
-            connect -> KafkaConnectClients.withBaseUrl(connect).restartConnector(connectorName);
+            connect -> KafkaConnectClients.withBaseUrl(connect)
+                .restartConnector(connectorName, true, false);
         break;
       case PAUSE:
         kafkaClientCall =
diff --git a/kafka-ui-contract/src/main/resources/swagger/kafka-connect-api.yaml b/kafka-ui-contract/src/main/resources/swagger/kafka-connect-api.yaml
index 14c996ee545..bd96bf0c463 100644
--- a/kafka-ui-contract/src/main/resources/swagger/kafka-connect-api.yaml
+++ b/kafka-ui-contract/src/main/resources/swagger/kafka-connect-api.yaml
@@ -169,7 +169,7 @@ paths:
     post:
       tags:
         - KafkaConnectClient
-      summary: restart the connector
+      summary: restart the connector and its tasks
       operationId: restartConnector
       parameters:
         - name: connectorName
@@ -177,6 +177,21 @@ paths:
           required: true
           schema:
             type: string
+        - name: includeTasks
+          in: query
+          required: false
+          schema:
+            type: boolean
+            default: false
+          description: Specifies whether to restart the connector instance and task instances or just the connector instance
+        - name: onlyFailed
+          in: query
+          required: false
+          schema:
+            type: boolean
+            default: false
+          description: Specifies whether to restart just the instances with a FAILED status or all instances
+
       responses:
         200:
           description: OK
@@ -406,6 +421,7 @@ components:
             - RUNNING
             - FAILED
             - PAUSED
+            - RESTARTING
             - UNASSIGNED
         worker_id:
           type: string
diff --git a/kafka-ui-contract/src/main/resources/swagger/kafka-ui-api.yaml b/kafka-ui-contract/src/main/resources/swagger/kafka-ui-api.yaml
index 70af448952a..b0633f9b0b5 100644
--- a/kafka-ui-contract/src/main/resources/swagger/kafka-ui-api.yaml
+++ b/kafka-ui-contract/src/main/resources/swagger/kafka-ui-api.yaml
@@ -2396,6 +2396,7 @@ components:
         - RUNNING
         - FAILED
         - PAUSED
+        - RESTARTING
         - UNASSIGNED
 
     ConnectorState:
diff --git a/kafka-ui-react-app/src/components/Connect/Details/Actions/Actions.tsx b/kafka-ui-react-app/src/components/Connect/Details/Actions/Actions.tsx
index 0599c1a4cb5..7f8ce91852b 100644
--- a/kafka-ui-react-app/src/components/Connect/Details/Actions/Actions.tsx
+++ b/kafka-ui-react-app/src/components/Connect/Details/Actions/Actions.tsx
@@ -126,7 +126,7 @@ const Actions: React.FC<ActionsProps> = ({
         <span>
           <i className="fas fa-sync-alt" />
         </span>
-        <span>Restart All Tasks</span>
+        <span>Restart Connector</span>
       </Button>
       <Button
         buttonSize="M"
diff --git a/kafka-ui-react-app/src/components/Connect/Details/Actions/__tests__/Actions.spec.tsx b/kafka-ui-react-app/src/components/Connect/Details/Actions/__tests__/Actions.spec.tsx
index 0d31cc0a7a6..509bc5606c3 100644
--- a/kafka-ui-react-app/src/components/Connect/Details/Actions/__tests__/Actions.spec.tsx
+++ b/kafka-ui-react-app/src/components/Connect/Details/Actions/__tests__/Actions.spec.tsx
@@ -148,7 +148,7 @@ describe('Actions', () => {
     it('calls restartConnector when restart button clicked', () => {
       const restartConnector = jest.fn();
       const wrapper = mount(setupWrapper({ restartConnector }));
-      wrapper.find({ children: 'Restart All Tasks' }).simulate('click');
+      wrapper.find({ children: 'Restart Connector' }).simulate('click');
       expect(restartConnector).toHaveBeenCalledTimes(1);
       expect(restartConnector).toHaveBeenCalledWith(
         clusterName,
diff --git a/kafka-ui-react-app/src/components/Connect/Details/Actions/__tests__/__snapshots__/Actions.spec.tsx.snap b/kafka-ui-react-app/src/components/Connect/Details/Actions/__tests__/__snapshots__/Actions.spec.tsx.snap
index ee145bdf7c4..57c8cb4f906 100644
--- a/kafka-ui-react-app/src/components/Connect/Details/Actions/__tests__/__snapshots__/Actions.spec.tsx.snap
+++ b/kafka-ui-react-app/src/components/Connect/Details/Actions/__tests__/__snapshots__/Actions.spec.tsx.snap
@@ -141,7 +141,7 @@ exports[`Actions view matches snapshot 1`] = `
       />
     </span>
     <span>
-      Restart All Tasks
+      Restart Connector
     </span>
   </button>
   <a
@@ -334,7 +334,7 @@ exports[`Actions view matches snapshot when deleting connector 1`] = `
       />
     </span>
     <span>
-      Restart All Tasks
+      Restart Connector
     </span>
   </button>
   <a
@@ -512,7 +512,7 @@ exports[`Actions view matches snapshot when failed 1`] = `
       />
     </span>
     <span>
-      Restart All Tasks
+      Restart Connector
     </span>
   </button>
   <a
@@ -705,7 +705,7 @@ exports[`Actions view matches snapshot when paused 1`] = `
       />
     </span>
     <span>
-      Restart All Tasks
+      Restart Connector
     </span>
   </button>
   <a
@@ -898,7 +898,7 @@ exports[`Actions view matches snapshot when running connector action 1`] = `
       />
     </span>
     <span>
-      Restart All Tasks
+      Restart Connector
     </span>
   </button>
   <a
@@ -1076,7 +1076,7 @@ exports[`Actions view matches snapshot when unassigned 1`] = `
       />
     </span>
     <span>
-      Restart All Tasks
+      Restart Connector
     </span>
   </button>
   <a


Test patch: