From 343ad64a07bebe0d85de6ba8b59f8003134b8bb3 Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 11:46:58 +0200 Subject: [PATCH 01/26] updated swagger --- core/api-server/api/rest-api/swagger.json | 62 ++++++++++++++++++- .../api/rest-api/swagger.json | 62 ++++++++++++++++++- core/gc-service/api/rest-api/swagger.json | 62 ++++++++++++++++++- core/openapi-spec/swagger.json | 62 ++++++++++++++++++- .../definitions/pipelines/pipeline.yaml | 3 + .../api/rest-api/swagger.json | 62 ++++++++++++++++++- 6 files changed, 308 insertions(+), 5 deletions(-) diff --git a/core/api-server/api/rest-api/swagger.json b/core/api-server/api/rest-api/swagger.json index b36dc9550..88866b6dd 100644 --- a/core/api-server/api/rest-api/swagger.json +++ b/core/api-server/api/rest-api/swagger.json @@ -3,7 +3,7 @@ "info": { "title": "HKube API", "description": "HKube RESTful API", - "version": "2.8.7", + "version": "2.8.8", "contact": { "email": "hkube.dev@gmail.com" }, @@ -515,6 +515,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -1022,6 +1026,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -2569,6 +2577,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -3075,6 +3087,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -10742,6 +10758,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -11447,6 +11467,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -12207,6 +12231,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -12682,6 +12710,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -13123,6 +13155,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -13625,6 +13661,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -14066,6 +14106,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -19263,6 +19307,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -19795,6 +19843,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -26490,6 +26542,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -26994,6 +27050,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ diff --git a/core/datasources-service/api/rest-api/swagger.json b/core/datasources-service/api/rest-api/swagger.json index b36dc9550..88866b6dd 100644 --- a/core/datasources-service/api/rest-api/swagger.json +++ b/core/datasources-service/api/rest-api/swagger.json @@ -3,7 +3,7 @@ "info": { "title": "HKube API", "description": "HKube RESTful API", - "version": "2.8.7", + "version": "2.8.8", "contact": { "email": "hkube.dev@gmail.com" }, @@ -515,6 +515,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -1022,6 +1026,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -2569,6 +2577,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -3075,6 +3087,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -10742,6 +10758,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -11447,6 +11467,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -12207,6 +12231,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -12682,6 +12710,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -13123,6 +13155,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -13625,6 +13661,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -14066,6 +14106,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -19263,6 +19307,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -19795,6 +19843,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -26490,6 +26542,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -26994,6 +27050,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ diff --git a/core/gc-service/api/rest-api/swagger.json b/core/gc-service/api/rest-api/swagger.json index b36dc9550..88866b6dd 100644 --- a/core/gc-service/api/rest-api/swagger.json +++ b/core/gc-service/api/rest-api/swagger.json @@ -3,7 +3,7 @@ "info": { "title": "HKube API", "description": "HKube RESTful API", - "version": "2.8.7", + "version": "2.8.8", "contact": { "email": "hkube.dev@gmail.com" }, @@ -515,6 +515,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -1022,6 +1026,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -2569,6 +2577,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -3075,6 +3087,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -10742,6 +10758,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -11447,6 +11467,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -12207,6 +12231,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -12682,6 +12710,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -13123,6 +13155,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -13625,6 +13661,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -14066,6 +14106,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -19263,6 +19307,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -19795,6 +19843,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -26490,6 +26542,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -26994,6 +27050,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ diff --git a/core/openapi-spec/swagger.json b/core/openapi-spec/swagger.json index b36dc9550..88866b6dd 100644 --- a/core/openapi-spec/swagger.json +++ b/core/openapi-spec/swagger.json @@ -3,7 +3,7 @@ "info": { "title": "HKube API", "description": "HKube RESTful API", - "version": "2.8.7", + "version": "2.8.8", "contact": { "email": "hkube.dev@gmail.com" }, @@ -515,6 +515,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -1022,6 +1026,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -2569,6 +2577,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -3075,6 +3087,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -10742,6 +10758,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -11447,6 +11467,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -12207,6 +12231,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -12682,6 +12710,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -13123,6 +13155,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -13625,6 +13661,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -14066,6 +14106,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -19263,6 +19307,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -19795,6 +19843,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -26490,6 +26542,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -26994,6 +27050,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ diff --git a/core/openapi-spec/swagger/definitions/pipelines/pipeline.yaml b/core/openapi-spec/swagger/definitions/pipelines/pipeline.yaml index 81223eb0d..e87f79acc 100644 --- a/core/openapi-spec/swagger/definitions/pipelines/pipeline.yaml +++ b/core/openapi-spec/swagger/definitions/pipelines/pipeline.yaml @@ -57,5 +57,8 @@ properties: description: edges define relation between nodes items: {} example: [{ source: A, target: B }] + version: + type: string + description: pipeline version required: - name diff --git a/core/pipeline-driver-queue/api/rest-api/swagger.json b/core/pipeline-driver-queue/api/rest-api/swagger.json index b36dc9550..88866b6dd 100644 --- a/core/pipeline-driver-queue/api/rest-api/swagger.json +++ b/core/pipeline-driver-queue/api/rest-api/swagger.json @@ -3,7 +3,7 @@ "info": { "title": "HKube API", "description": "HKube RESTful API", - "version": "2.8.7", + "version": "2.8.8", "contact": { "email": "hkube.dev@gmail.com" }, @@ -515,6 +515,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -1022,6 +1026,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -2569,6 +2577,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -3075,6 +3087,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -10742,6 +10758,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -11447,6 +11467,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -12207,6 +12231,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -12682,6 +12710,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -13123,6 +13155,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -13625,6 +13661,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -14066,6 +14106,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -19263,6 +19307,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -19795,6 +19843,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -26490,6 +26542,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ @@ -26994,6 +27050,10 @@ "target": "B" } ] + }, + "version": { + "type": "string", + "description": "pipeline version" } }, "required": [ From a5ae124e3de62a47ece8bb8afd76a5ef5e545ef6 Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 11:53:24 +0200 Subject: [PATCH 02/26] organised file + added version to pipeline --- .../api/graphql/schemas/pipeline-schema.js | 198 ++++++++++-------- 1 file changed, 111 insertions(+), 87 deletions(-) diff --git a/core/api-server/api/graphql/schemas/pipeline-schema.js b/core/api-server/api/graphql/schemas/pipeline-schema.js index 6e1beed1a..530abea2a 100644 --- a/core/api-server/api/graphql/schemas/pipeline-schema.js +++ b/core/api-server/api/graphql/schemas/pipeline-schema.js @@ -1,94 +1,118 @@ const { gql } = require('apollo-server'); const pipelineTypeDefs = gql` -type Cron { enabled: Boolean pattern: String } - -type Triggers { cron: Cron ,pipelines: [String]} - -type ConcurrentPipelines { amount: Int rejectOnFailure: Boolean } - -type Webhooks { progress:String, result:String } - -type Streaming { flows:Object, defaultFlow:String } - -type Options { batchTolerance: Int - ttl: Int - progressVerbosityLevel: String - concurrentPipelines: ConcurrentPipelines - activeTtl: Int - devMode: Boolean - devFolder: String -} - -type Metrics { tensorboard: Boolean } -type Snapshot{ - name: String -} - -type Sampler{ - search_space: Object -} - -type HyperParams{ - name: String - suggest: String - high: String - low: String - choices: [String] - sampler: Sampler -} -type Spec { - name: String - id: String - snapshot: Snapshot - description: String - mem: String - cpu: String - objectivePipeline: String - numberOfTrials: Int - hyperParams: [HyperParams] - sampler: Sampler - } -type Retry { policy: String limit: Int } - -type PipelineNodes { - nodeName: String - algorithmName: String - ttl: Int - includeInResult: Boolean - batchOperation: String - metrics: Metrics - retry: Retry - spec: Spec - kind: String - stateType: String - input: [Object] - } - - - -type Pipeline { - modified: Float - kind: String - name: String - description: String - priority: Int - experimentName: String - triggers: Triggers - options: Options - webhooks: Webhooks - streaming: Streaming - nodes: [PipelineNodes ] - flowInput: Object -} -type Metrics { tensorboard: Boolean } - -type AutogeneratedPipelines { list: [Object],pipelinesCount:Int } - -extend type Query { - pipelines:AutogeneratedPipelines -} + type Cron { + enabled: Boolean + pattern: String + } + + type Triggers { + cron: Cron + pipelines: [String] + } + + type ConcurrentPipelines { + amount: Int + rejectOnFailure: Boolean + } + + type Webhooks { + progress: String + result: String + } + + type Streaming { + flows: Object + defaultFlow: String + } + + type Options { + batchTolerance: Int + ttl: Int + progressVerbosityLevel: String + concurrentPipelines: ConcurrentPipelines + activeTtl: Int + devMode: Boolean + devFolder: String + } + + type Metrics { + tensorboard: Boolean + } + + type Snapshot { + name: String + } + type Sampler { + search_space: Object + } + + type HyperParams { + name: String + suggest: String + high: String + low: String + choices: [String] + sampler: Sampler + } + + type Spec { + name: String + id: String + snapshot: Snapshot + description: String + mem: String + cpu: String + objectivePipeline: String + numberOfTrials: Int + hyperParams: [HyperParams] + sampler: Sampler + } + + type Retry { + policy: String + limit: Int + } + + type PipelineNodes { + nodeName: String + algorithmName: String + ttl: Int + includeInResult: Boolean + batchOperation: String + metrics: Metrics + retry: Retry + spec: Spec + kind: String + stateType: String + input: [Object] + } + + type Pipeline { + modified: Float + kind: String + name: String + description: String + priority: Int + experimentName: String + triggers: Triggers + options: Options + webhooks: Webhooks + streaming: Streaming + nodes: [PipelineNodes] + flowInput: Object + version: String + } + + type AutogeneratedPipelines { + list: [Object] + pipelinesCount: Int + } + + extend type Query { + pipelines: AutogeneratedPipelines + } `; module.exports = pipelineTypeDefs; From 26abde408cceb5ca8071792fe33665834de058e5 Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 11:54:37 +0200 Subject: [PATCH 03/26] added explanation --- core/api-server/lib/validation/inner-validator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/api-server/lib/validation/inner-validator.js b/core/api-server/lib/validation/inner-validator.js index 74f60091a..b4b10c4bc 100644 --- a/core/api-server/lib/validation/inner-validator.js +++ b/core/api-server/lib/validation/inner-validator.js @@ -8,7 +8,7 @@ const defaulter = new Validator({ useDefaults: true, coerceTypes: true, nullable class ApiValidator { init(schemas) { - this.definitions = schemas; + this.definitions = schemas; // Schemas are taken from swagger schemas customFormats.init(schemas, validator, defaulter); } From e1cd10a410ff4a456e0c66f5e79584ca53b4cd24 Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 12:03:38 +0200 Subject: [PATCH 04/26] updated swagger --- core/api-server/api/rest-api/swagger.json | 32 +++++++++++++++++++ .../api/rest-api/swagger.json | 32 +++++++++++++++++++ core/gc-service/api/rest-api/swagger.json | 32 +++++++++++++++++++ core/openapi-spec/swagger.json | 32 +++++++++++++++++++ .../swagger/definitions/index.yaml | 4 +++ .../pipelines/applyPipelineVersion.yaml | 13 ++++++++ .../pipelines/pipelineVersionId.yaml | 4 +++ .../api/rest-api/swagger.json | 32 +++++++++++++++++++ 8 files changed, 181 insertions(+) create mode 100644 core/openapi-spec/swagger/definitions/pipelines/applyPipelineVersion.yaml create mode 100644 core/openapi-spec/swagger/definitions/pipelines/pipelineVersionId.yaml diff --git a/core/api-server/api/rest-api/swagger.json b/core/api-server/api/rest-api/swagger.json index 88866b6dd..d997c2df7 100644 --- a/core/api-server/api/rest-api/swagger.json +++ b/core/api-server/api/rest-api/swagger.json @@ -27349,6 +27349,38 @@ } } }, + "pipelineVersionId": { + "type": "string", + "description": "Unique identifier representing version id", + "minLength": 1, + "maxLength": 10 + }, + "applyPipelineVersion": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Unique identifier representing a specific pipeline", + "minLength": 1, + "format": "pipeline-name" + }, + "version": { + "type": "string", + "description": "Unique identifier representing version id", + "minLength": 1, + "maxLength": 10 + }, + "force": { + "type": "boolean", + "description": "should replace or not current pipeline version, if pipeline is running", + "default": false + } + }, + "required": [ + "name", + "version" + ] + }, "priority": { "type": "integer", "minimum": 1, diff --git a/core/datasources-service/api/rest-api/swagger.json b/core/datasources-service/api/rest-api/swagger.json index 88866b6dd..d997c2df7 100644 --- a/core/datasources-service/api/rest-api/swagger.json +++ b/core/datasources-service/api/rest-api/swagger.json @@ -27349,6 +27349,38 @@ } } }, + "pipelineVersionId": { + "type": "string", + "description": "Unique identifier representing version id", + "minLength": 1, + "maxLength": 10 + }, + "applyPipelineVersion": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Unique identifier representing a specific pipeline", + "minLength": 1, + "format": "pipeline-name" + }, + "version": { + "type": "string", + "description": "Unique identifier representing version id", + "minLength": 1, + "maxLength": 10 + }, + "force": { + "type": "boolean", + "description": "should replace or not current pipeline version, if pipeline is running", + "default": false + } + }, + "required": [ + "name", + "version" + ] + }, "priority": { "type": "integer", "minimum": 1, diff --git a/core/gc-service/api/rest-api/swagger.json b/core/gc-service/api/rest-api/swagger.json index 88866b6dd..d997c2df7 100644 --- a/core/gc-service/api/rest-api/swagger.json +++ b/core/gc-service/api/rest-api/swagger.json @@ -27349,6 +27349,38 @@ } } }, + "pipelineVersionId": { + "type": "string", + "description": "Unique identifier representing version id", + "minLength": 1, + "maxLength": 10 + }, + "applyPipelineVersion": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Unique identifier representing a specific pipeline", + "minLength": 1, + "format": "pipeline-name" + }, + "version": { + "type": "string", + "description": "Unique identifier representing version id", + "minLength": 1, + "maxLength": 10 + }, + "force": { + "type": "boolean", + "description": "should replace or not current pipeline version, if pipeline is running", + "default": false + } + }, + "required": [ + "name", + "version" + ] + }, "priority": { "type": "integer", "minimum": 1, diff --git a/core/openapi-spec/swagger.json b/core/openapi-spec/swagger.json index 88866b6dd..d997c2df7 100644 --- a/core/openapi-spec/swagger.json +++ b/core/openapi-spec/swagger.json @@ -27349,6 +27349,38 @@ } } }, + "pipelineVersionId": { + "type": "string", + "description": "Unique identifier representing version id", + "minLength": 1, + "maxLength": 10 + }, + "applyPipelineVersion": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Unique identifier representing a specific pipeline", + "minLength": 1, + "format": "pipeline-name" + }, + "version": { + "type": "string", + "description": "Unique identifier representing version id", + "minLength": 1, + "maxLength": 10 + }, + "force": { + "type": "boolean", + "description": "should replace or not current pipeline version, if pipeline is running", + "default": false + } + }, + "required": [ + "name", + "version" + ] + }, "priority": { "type": "integer", "minimum": 1, diff --git a/core/openapi-spec/swagger/definitions/index.yaml b/core/openapi-spec/swagger/definitions/index.yaml index a36e3b94f..c731191c2 100644 --- a/core/openapi-spec/swagger/definitions/index.yaml +++ b/core/openapi-spec/swagger/definitions/index.yaml @@ -249,6 +249,10 @@ pipelineNode: $ref: ./pipelines/pipelineNode.yaml pipelineResult: $ref: ./pipelines/pipelineResult.yaml +pipelineVersionId: + $ref: ./pipelines/pipelineVersionId.yaml +applyPipelineVersion: + $ref: ./pipelines/applyPipelineVersion.yaml priority: $ref: ./pipelines/priority.yaml triggers: diff --git a/core/openapi-spec/swagger/definitions/pipelines/applyPipelineVersion.yaml b/core/openapi-spec/swagger/definitions/pipelines/applyPipelineVersion.yaml new file mode 100644 index 000000000..6381a4fa5 --- /dev/null +++ b/core/openapi-spec/swagger/definitions/pipelines/applyPipelineVersion.yaml @@ -0,0 +1,13 @@ +type: object +properties: + name: + $ref: "#/components/schemas/pipelineName" + version: + $ref: "#/components/schemas/pipelineVersionId" + force: + type: boolean + description: should replace or not current pipeline version, if pipeline is running + default: false +required: + - name + - version diff --git a/core/openapi-spec/swagger/definitions/pipelines/pipelineVersionId.yaml b/core/openapi-spec/swagger/definitions/pipelines/pipelineVersionId.yaml new file mode 100644 index 000000000..bd4ee1d71 --- /dev/null +++ b/core/openapi-spec/swagger/definitions/pipelines/pipelineVersionId.yaml @@ -0,0 +1,4 @@ +type: string +description: Unique identifier representing version id +minLength: 1 +maxLength: 10 diff --git a/core/pipeline-driver-queue/api/rest-api/swagger.json b/core/pipeline-driver-queue/api/rest-api/swagger.json index 88866b6dd..d997c2df7 100644 --- a/core/pipeline-driver-queue/api/rest-api/swagger.json +++ b/core/pipeline-driver-queue/api/rest-api/swagger.json @@ -27349,6 +27349,38 @@ } } }, + "pipelineVersionId": { + "type": "string", + "description": "Unique identifier representing version id", + "minLength": 1, + "maxLength": 10 + }, + "applyPipelineVersion": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Unique identifier representing a specific pipeline", + "minLength": 1, + "format": "pipeline-name" + }, + "version": { + "type": "string", + "description": "Unique identifier representing version id", + "minLength": 1, + "maxLength": 10 + }, + "force": { + "type": "boolean", + "description": "should replace or not current pipeline version, if pipeline is running", + "default": false + } + }, + "required": [ + "name", + "version" + ] + }, "priority": { "type": "integer", "minimum": 1, From 64b26542ce8b3e96bb304896c10a155a9ecf4f60 Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 13:57:00 +0200 Subject: [PATCH 05/26] updated swagger, now support deletion and changing version of pipeline --- core/api-server/api/rest-api/swagger.json | 221 ++++++++++++++++++ .../api/rest-api/swagger.json | 221 ++++++++++++++++++ core/gc-service/api/rest-api/swagger.json | 221 ++++++++++++++++++ core/openapi-spec/swagger.json | 221 ++++++++++++++++++ core/openapi-spec/swagger/paths/index.yaml | 2 + .../paths/versions/pipelines/apply.yaml | 37 +++ .../paths/versions/pipelines/version_id.yaml | 43 ++++ .../api/rest-api/swagger.json | 221 ++++++++++++++++++ 8 files changed, 1187 insertions(+) create mode 100644 core/openapi-spec/swagger/paths/versions/pipelines/apply.yaml diff --git a/core/api-server/api/rest-api/swagger.json b/core/api-server/api/rest-api/swagger.json index d997c2df7..c0f45dfe1 100644 --- a/core/api-server/api/rest-api/swagger.json +++ b/core/api-server/api/rest-api/swagger.json @@ -19915,6 +19915,227 @@ } } } + }, + "delete": { + "tags": [ + "Pipeline Versions" + ], + "summary": "Delete version", + "description": "Delete existing pipeline version.", + "parameters": [ + { + "name": "name", + "in": "path", + "description": "pipeline name", + "required": true, + "schema": { + "type": "string", + "description": "Unique identifier representing a specific pipeline", + "minLength": 1, + "format": "pipeline-name" + } + }, + { + "name": "version", + "in": "path", + "description": "pipeline version", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "action summary", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + } + }, + "400": { + "description": "bad request", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "404": { + "description": "algorithm Not Found", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/versions/pipelines/apply": { + "post": { + "tags": [ + "Pipeline Versions" + ], + "summary": "Apply pipeline version", + "description": "Change the current pipeline version", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Unique identifier representing a specific pipeline", + "minLength": 1, + "format": "pipeline-name" + }, + "version": { + "type": "string", + "description": "Unique identifier representing version id", + "minLength": 1, + "maxLength": 10 + }, + "force": { + "type": "boolean", + "description": "should replace or not current pipeline version, if pipeline is running", + "default": false + } + }, + "required": [ + "name", + "version" + ] + } + } + }, + "description": "an object representing the pipeline name, the version to change to, and force flag (when forced, pipeline execution stops)", + "required": true + }, + "responses": { + "200": { + "description": "the OK string", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + } + }, + "400": { + "description": "bad request", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "404": { + "description": "jobId Not Found", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } } }, "/experiment/{name}": { diff --git a/core/datasources-service/api/rest-api/swagger.json b/core/datasources-service/api/rest-api/swagger.json index d997c2df7..c0f45dfe1 100644 --- a/core/datasources-service/api/rest-api/swagger.json +++ b/core/datasources-service/api/rest-api/swagger.json @@ -19915,6 +19915,227 @@ } } } + }, + "delete": { + "tags": [ + "Pipeline Versions" + ], + "summary": "Delete version", + "description": "Delete existing pipeline version.", + "parameters": [ + { + "name": "name", + "in": "path", + "description": "pipeline name", + "required": true, + "schema": { + "type": "string", + "description": "Unique identifier representing a specific pipeline", + "minLength": 1, + "format": "pipeline-name" + } + }, + { + "name": "version", + "in": "path", + "description": "pipeline version", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "action summary", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + } + }, + "400": { + "description": "bad request", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "404": { + "description": "algorithm Not Found", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/versions/pipelines/apply": { + "post": { + "tags": [ + "Pipeline Versions" + ], + "summary": "Apply pipeline version", + "description": "Change the current pipeline version", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Unique identifier representing a specific pipeline", + "minLength": 1, + "format": "pipeline-name" + }, + "version": { + "type": "string", + "description": "Unique identifier representing version id", + "minLength": 1, + "maxLength": 10 + }, + "force": { + "type": "boolean", + "description": "should replace or not current pipeline version, if pipeline is running", + "default": false + } + }, + "required": [ + "name", + "version" + ] + } + } + }, + "description": "an object representing the pipeline name, the version to change to, and force flag (when forced, pipeline execution stops)", + "required": true + }, + "responses": { + "200": { + "description": "the OK string", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + } + }, + "400": { + "description": "bad request", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "404": { + "description": "jobId Not Found", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } } }, "/experiment/{name}": { diff --git a/core/gc-service/api/rest-api/swagger.json b/core/gc-service/api/rest-api/swagger.json index d997c2df7..c0f45dfe1 100644 --- a/core/gc-service/api/rest-api/swagger.json +++ b/core/gc-service/api/rest-api/swagger.json @@ -19915,6 +19915,227 @@ } } } + }, + "delete": { + "tags": [ + "Pipeline Versions" + ], + "summary": "Delete version", + "description": "Delete existing pipeline version.", + "parameters": [ + { + "name": "name", + "in": "path", + "description": "pipeline name", + "required": true, + "schema": { + "type": "string", + "description": "Unique identifier representing a specific pipeline", + "minLength": 1, + "format": "pipeline-name" + } + }, + { + "name": "version", + "in": "path", + "description": "pipeline version", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "action summary", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + } + }, + "400": { + "description": "bad request", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "404": { + "description": "algorithm Not Found", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/versions/pipelines/apply": { + "post": { + "tags": [ + "Pipeline Versions" + ], + "summary": "Apply pipeline version", + "description": "Change the current pipeline version", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Unique identifier representing a specific pipeline", + "minLength": 1, + "format": "pipeline-name" + }, + "version": { + "type": "string", + "description": "Unique identifier representing version id", + "minLength": 1, + "maxLength": 10 + }, + "force": { + "type": "boolean", + "description": "should replace or not current pipeline version, if pipeline is running", + "default": false + } + }, + "required": [ + "name", + "version" + ] + } + } + }, + "description": "an object representing the pipeline name, the version to change to, and force flag (when forced, pipeline execution stops)", + "required": true + }, + "responses": { + "200": { + "description": "the OK string", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + } + }, + "400": { + "description": "bad request", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "404": { + "description": "jobId Not Found", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } } }, "/experiment/{name}": { diff --git a/core/openapi-spec/swagger.json b/core/openapi-spec/swagger.json index d997c2df7..c0f45dfe1 100644 --- a/core/openapi-spec/swagger.json +++ b/core/openapi-spec/swagger.json @@ -19915,6 +19915,227 @@ } } } + }, + "delete": { + "tags": [ + "Pipeline Versions" + ], + "summary": "Delete version", + "description": "Delete existing pipeline version.", + "parameters": [ + { + "name": "name", + "in": "path", + "description": "pipeline name", + "required": true, + "schema": { + "type": "string", + "description": "Unique identifier representing a specific pipeline", + "minLength": 1, + "format": "pipeline-name" + } + }, + { + "name": "version", + "in": "path", + "description": "pipeline version", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "action summary", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + } + }, + "400": { + "description": "bad request", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "404": { + "description": "algorithm Not Found", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/versions/pipelines/apply": { + "post": { + "tags": [ + "Pipeline Versions" + ], + "summary": "Apply pipeline version", + "description": "Change the current pipeline version", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Unique identifier representing a specific pipeline", + "minLength": 1, + "format": "pipeline-name" + }, + "version": { + "type": "string", + "description": "Unique identifier representing version id", + "minLength": 1, + "maxLength": 10 + }, + "force": { + "type": "boolean", + "description": "should replace or not current pipeline version, if pipeline is running", + "default": false + } + }, + "required": [ + "name", + "version" + ] + } + } + }, + "description": "an object representing the pipeline name, the version to change to, and force flag (when forced, pipeline execution stops)", + "required": true + }, + "responses": { + "200": { + "description": "the OK string", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + } + }, + "400": { + "description": "bad request", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "404": { + "description": "jobId Not Found", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } } }, "/experiment/{name}": { diff --git a/core/openapi-spec/swagger/paths/index.yaml b/core/openapi-spec/swagger/paths/index.yaml index 5c5610390..4f052d834 100644 --- a/core/openapi-spec/swagger/paths/index.yaml +++ b/core/openapi-spec/swagger/paths/index.yaml @@ -172,6 +172,8 @@ $ref: ./versions/pipelines/version.yaml /versions/pipelines/{name}/{version}: $ref: ./versions/pipelines/version_id.yaml +/versions/pipelines/apply: + $ref: ./versions/pipelines/apply.yaml # experiment /experiment/{name}: diff --git a/core/openapi-spec/swagger/paths/versions/pipelines/apply.yaml b/core/openapi-spec/swagger/paths/versions/pipelines/apply.yaml new file mode 100644 index 000000000..aab4265d4 --- /dev/null +++ b/core/openapi-spec/swagger/paths/versions/pipelines/apply.yaml @@ -0,0 +1,37 @@ +post: + tags: + - Pipeline Versions + summary: Apply pipeline version + description: Change the current pipeline version + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/applyPipelineVersion" + description: an object representing the pipeline name, the version to change to, and force flag (when forced, pipeline execution stops) + required: true + responses: + "200": + description: the OK string + content: + application/json: + schema: + $ref: "#/components/schemas/defaultResponse" + "400": + description: bad request + content: + application/json: + schema: + $ref: "#/components/schemas/error" + "404": + description: jobId Not Found + content: + application/json: + schema: + $ref: "#/components/schemas/error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/error" diff --git a/core/openapi-spec/swagger/paths/versions/pipelines/version_id.yaml b/core/openapi-spec/swagger/paths/versions/pipelines/version_id.yaml index caadc02f3..654af2ef2 100644 --- a/core/openapi-spec/swagger/paths/versions/pipelines/version_id.yaml +++ b/core/openapi-spec/swagger/paths/versions/pipelines/version_id.yaml @@ -37,6 +37,49 @@ get: application/json: schema: $ref: "#/components/schemas/error" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/error" +delete: + tags: + - Pipeline Versions + summary: Delete version + description: Delete existing pipeline version. + parameters: + - name: name + in: path + description: pipeline name + required: true + schema: + $ref: "#/components/schemas/pipelineName" + - name: version + in: path + description: pipeline version + required: true + schema: + type: string + responses: + "200": + description: action summary + content: + application/json: + schema: + $ref: "#/components/schemas/defaultResponse" + "400": + description: bad request + content: + application/json: + schema: + $ref: "#/components/schemas/error" + "404": + description: algorithm Not Found + content: + application/json: + schema: + $ref: "#/components/schemas/error" default: description: Unexpected error content: diff --git a/core/pipeline-driver-queue/api/rest-api/swagger.json b/core/pipeline-driver-queue/api/rest-api/swagger.json index d997c2df7..c0f45dfe1 100644 --- a/core/pipeline-driver-queue/api/rest-api/swagger.json +++ b/core/pipeline-driver-queue/api/rest-api/swagger.json @@ -19915,6 +19915,227 @@ } } } + }, + "delete": { + "tags": [ + "Pipeline Versions" + ], + "summary": "Delete version", + "description": "Delete existing pipeline version.", + "parameters": [ + { + "name": "name", + "in": "path", + "description": "pipeline name", + "required": true, + "schema": { + "type": "string", + "description": "Unique identifier representing a specific pipeline", + "minLength": 1, + "format": "pipeline-name" + } + }, + { + "name": "version", + "in": "path", + "description": "pipeline version", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "action summary", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + } + }, + "400": { + "description": "bad request", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "404": { + "description": "algorithm Not Found", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/versions/pipelines/apply": { + "post": { + "tags": [ + "Pipeline Versions" + ], + "summary": "Apply pipeline version", + "description": "Change the current pipeline version", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Unique identifier representing a specific pipeline", + "minLength": 1, + "format": "pipeline-name" + }, + "version": { + "type": "string", + "description": "Unique identifier representing version id", + "minLength": 1, + "maxLength": 10 + }, + "force": { + "type": "boolean", + "description": "should replace or not current pipeline version, if pipeline is running", + "default": false + } + }, + "required": [ + "name", + "version" + ] + } + } + }, + "description": "an object representing the pipeline name, the version to change to, and force flag (when forced, pipeline execution stops)", + "required": true + }, + "responses": { + "200": { + "description": "the OK string", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + } + }, + "400": { + "description": "bad request", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "404": { + "description": "jobId Not Found", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "default": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } } }, "/experiment/{name}": { From 169e6f70023ec2aa9330b275e55c3faa9ea1328b Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 14:08:01 +0200 Subject: [PATCH 06/26] added validator for pipeline version --- core/api-server/lib/validation/pipelines.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/api-server/lib/validation/pipelines.js b/core/api-server/lib/validation/pipelines.js index 0a0a0cd8a..ef0be1d1a 100644 --- a/core/api-server/lib/validation/pipelines.js +++ b/core/api-server/lib/validation/pipelines.js @@ -15,6 +15,10 @@ class ApiValidator { this._validator.validate(this._validator.definitions.pipelineName, name, false); } + validatePipelineVersion(pipeline) { + this._validator.validate(this._validator.definitions.applyPipelineVersion, pipeline, false); + } + validatePipelineNodes(pipeline) { if (!pipeline.nodes?.length) { throw new InvalidDataError('pipeline must have at least one node'); From 1eb2c182ce96827ce97a76e63044b4b374ea3308 Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 14:08:55 +0200 Subject: [PATCH 07/26] added pipeline appyl and delete support for rest --- .../api/rest-api/routes/v1/versions.js | 8 ++++ .../lib/service/pipeline-versions.js | 38 ++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/core/api-server/api/rest-api/routes/v1/versions.js b/core/api-server/api/rest-api/routes/v1/versions.js index b44c41354..d13e7aa68 100644 --- a/core/api-server/api/rest-api/routes/v1/versions.js +++ b/core/api-server/api/rest-api/routes/v1/versions.js @@ -45,6 +45,14 @@ const routes = (options) => { const response = await pipelineVersionsService.getVersion(req.params); res.json(response); }); + router.post('/pipelines/apply', keycloak.getProtect(keycloakRoles.API_EDIT), async (req, res) => { + const response = await pipelineVersionsService.applyVersion(req.body); + res.status(HttpStatus.StatusCodes.CREATED).json(response); + }); + router.delete('/pipelines/:name/:version', keycloak.getProtect(keycloakRoles.API_DELETE), async (req, res) => { + const response = await pipelineVersionsService.deleteVersion(req.params); + res.json(response); + }); return router; }; diff --git a/core/api-server/lib/service/pipeline-versions.js b/core/api-server/lib/service/pipeline-versions.js index 8756dc7ea..51526e396 100644 --- a/core/api-server/lib/service/pipeline-versions.js +++ b/core/api-server/lib/service/pipeline-versions.js @@ -2,7 +2,7 @@ const asyncQueue = require('async.queue'); const versioning = require('./versioning'); const validator = require('../validation/api-validator'); const stateManager = require('../state/state-manager'); -const { ResourceNotFoundError } = require('../errors'); +const { ResourceNotFoundError, ActionNotAllowed } = require('../errors'); class PipelineVersions { constructor() { @@ -30,6 +30,42 @@ class PipelineVersions { return pipelineVersion; } + async applyVersion(options) { + const { name, version, force } = options; + validator.pipelines.validatePipelineVersion(options); + const pipelineVersion = await this.getVersion({ name, version }); + + // check if pipeline is running + if (!force) { + const runningPipelines = await stateManager.searchJobs({ pipelineName: name, hasResult: false, fields: { jobId: true } }); + if (runningPipelines.length > 0) { + throw new ActionNotAllowed(`The selected pipeline ${name} is running.`); + } + } + + await stateManager.updatePipeline(pipelineVersion.pipeline); + return pipelineVersion; + } + + async deleteVersion(options) { + const { version, name } = options; + validator.pipelines.validatePipelineVersion({ name, version }); + const pipeline = await stateManager.getPipeline({ name }); + if (!pipeline) { + throw new ResourceNotFoundError('pipeline', name); + } + if (pipeline.version === version) { + throw new ActionNotAllowed('unable to remove used version'); + } + const pipelineVersion = await versioning.getVersion({ version }, true); + if (!pipelineVersion) { + throw new ResourceNotFoundError('version', version); + } + const res = await stateManager.deleteVersion({ name, version }, true); + const deleted = parseInt(res.deleted, 10); + return { deleted }; + } + /** * This method creates new pipeline version. * Version is created for any change in pipeline. From 91dc191aef14000fd29ed8b447f65db70aed8f1a Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 15:13:49 +0200 Subject: [PATCH 08/26] formatted message --- core/api-server/lib/service/algorithm-versions.js | 8 +++++++- core/api-server/tests/algorithms-versions.js | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/api-server/lib/service/algorithm-versions.js b/core/api-server/lib/service/algorithm-versions.js index 98e134503..dd6dd574a 100644 --- a/core/api-server/lib/service/algorithm-versions.js +++ b/core/api-server/lib/service/algorithm-versions.js @@ -48,7 +48,13 @@ class AlgorithmVersions { if (!force) { const runningPipelines = await stateManager.searchJobs({ algorithmName: name, hasResult: false, fields: { jobId: true } }); if (runningPipelines.length > 0) { - throw new ActionNotAllowed(`there are ${runningPipelines.length} running pipelines which dependent on "${options.name}" algorithm`, runningPipelines.map(p => p.jobId)); + throw new ActionNotAllowed( + `there ${runningPipelines.length === 1 ? 'is' : 'are'}` + + ` ${runningPipelines.length === 1 ? 'a' : runningPipelines.length} running pipeline` + + `${runningPipelines.length === 1 ? '' : 's'} which depend` + + `${runningPipelines.length === 1 ? 's' : ''} on "${options.name}" algorithm`, + runningPipelines.map(p => p.jobId) + ); } } // Deleting the error check "not last version algorithm" diff --git a/core/api-server/tests/algorithms-versions.js b/core/api-server/tests/algorithms-versions.js index 246c4cb55..a67dc893f 100644 --- a/core/api-server/tests/algorithms-versions.js +++ b/core/api-server/tests/algorithms-versions.js @@ -170,7 +170,7 @@ describe('Versions/Algorithms', () => { const res2 = await request(versionReq); expect(res2.body).to.have.property('error'); expect(res2.body.error.code).to.equal(HttpStatus.StatusCodes.BAD_REQUEST); - expect(res2.body.error.message).to.equal(`there are 1 running pipelines which dependent on "${name}" algorithm`); + expect(res2.body.error.message).to.equal(`there is a running pipeline which depends on "${name}" algorithm`); }); it('should not throw error of running pipelines dependent on algorithm', async () => { const name = `my-alg-${uuid()}`; From e50d5c02072e64b4c3fbe143ddf24c805636c15b Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 15:29:29 +0200 Subject: [PATCH 09/26] better readability --- core/api-server/lib/service/algorithm-versions.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/api-server/lib/service/algorithm-versions.js b/core/api-server/lib/service/algorithm-versions.js index dd6dd574a..be6664ad7 100644 --- a/core/api-server/lib/service/algorithm-versions.js +++ b/core/api-server/lib/service/algorithm-versions.js @@ -48,11 +48,9 @@ class AlgorithmVersions { if (!force) { const runningPipelines = await stateManager.searchJobs({ algorithmName: name, hasResult: false, fields: { jobId: true } }); if (runningPipelines.length > 0) { + const { length } = runningPipelines; throw new ActionNotAllowed( - `there ${runningPipelines.length === 1 ? 'is' : 'are'}` - + ` ${runningPipelines.length === 1 ? 'a' : runningPipelines.length} running pipeline` - + `${runningPipelines.length === 1 ? '' : 's'} which depend` - + `${runningPipelines.length === 1 ? 's' : ''} on "${options.name}" algorithm`, + `there ${length === 1 ? 'is a' : `are ${length}`} running pipeline${length === 1 ? '' : 's'} which depend${length === 1 ? 's' : ''} on "${options.name}" algorithm`, runningPipelines.map(p => p.jobId) ); } From 95dfb0152d18181010e4ec55780ebe9e642be27c Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 15:30:30 +0200 Subject: [PATCH 10/26] . --- core/api-server/lib/service/algorithm-versions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/api-server/lib/service/algorithm-versions.js b/core/api-server/lib/service/algorithm-versions.js index be6664ad7..379e66cd2 100644 --- a/core/api-server/lib/service/algorithm-versions.js +++ b/core/api-server/lib/service/algorithm-versions.js @@ -47,8 +47,8 @@ class AlgorithmVersions { // check if running pipelines if (!force) { const runningPipelines = await stateManager.searchJobs({ algorithmName: name, hasResult: false, fields: { jobId: true } }); - if (runningPipelines.length > 0) { - const { length } = runningPipelines; + const { length } = runningPipelines; + if (length > 0) { throw new ActionNotAllowed( `there ${length === 1 ? 'is a' : `are ${length}`} running pipeline${length === 1 ? '' : 's'} which depend${length === 1 ? 's' : ''} on "${options.name}" algorithm`, runningPipelines.map(p => p.jobId) From 11d58bdbd335547d2e24cb2d300349c438091123 Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 15:36:33 +0200 Subject: [PATCH 11/26] added _ (incorrect method name) --- core/api-server/api/rest-api/routes/v1/exec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/api-server/api/rest-api/routes/v1/exec.js b/core/api-server/api/rest-api/routes/v1/exec.js index 23186baf4..7b2fa2e24 100644 --- a/core/api-server/api/rest-api/routes/v1/exec.js +++ b/core/api-server/api/rest-api/routes/v1/exec.js @@ -40,7 +40,7 @@ const routes = (options) => { res.json({ jobId, gateways }); }); router.post('/getGraphByStreamingFlow', keycloak.getProtect(keycloakRoles.API_VIEW), async (req, res) => { - const { nodes, edges } = await Execution.getGraphByStreamingFlow(req.body); + const { nodes, edges } = await Execution._getGraphByStreamingFlow(req.body); res.json({ nodes, edges }); }); router.post('/stop', keycloak.getProtect(keycloakRoles.API_VIEW), async (req, res) => { From faa469cc9f2bf6c1b505007488bcc5b81bc20516 Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 16:10:05 +0200 Subject: [PATCH 12/26] when applying new pipeline version, stopping the execution of the current ones which use this pipeline. --- core/api-server/lib/service/pipeline-versions.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/api-server/lib/service/pipeline-versions.js b/core/api-server/lib/service/pipeline-versions.js index 51526e396..751fc6212 100644 --- a/core/api-server/lib/service/pipeline-versions.js +++ b/core/api-server/lib/service/pipeline-versions.js @@ -1,6 +1,7 @@ const asyncQueue = require('async.queue'); const versioning = require('./versioning'); const validator = require('../validation/api-validator'); +const Execution = require('./execution'); const stateManager = require('../state/state-manager'); const { ResourceNotFoundError, ActionNotAllowed } = require('../errors'); @@ -35,13 +36,20 @@ class PipelineVersions { validator.pipelines.validatePipelineVersion(options); const pipelineVersion = await this.getVersion({ name, version }); - // check if pipeline is running + // check if the pipeline is running + const runningJobs = await stateManager.searchJobs({ pipelineName: name, hasResult: false, fields: { jobId: true } }); if (!force) { - const runningPipelines = await stateManager.searchJobs({ pipelineName: name, hasResult: false, fields: { jobId: true } }); - if (runningPipelines.length > 0) { - throw new ActionNotAllowed(`The selected pipeline ${name} is running.`); + const { length } = runningJobs; + if (length > 0) { + throw new ActionNotAllowed(`The selected pipeline "${name}" is currently running on ${length} job${length === 1 ? '' : 's'}.`); } } + else { + runningJobs.forEach(element => { + const { jobId } = element; + Execution.stopJob({ jobId, reason: 'Pipeline version has been changed.' }); + }); + } await stateManager.updatePipeline(pipelineVersion.pipeline); return pipelineVersion; From dc1c4cb892279e038e2d5f0418215be4e92d2e59 Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 16:52:13 +0200 Subject: [PATCH 13/26] updated error message --- core/api-server/lib/service/algorithm-versions.js | 2 +- core/api-server/lib/service/pipeline-versions.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/api-server/lib/service/algorithm-versions.js b/core/api-server/lib/service/algorithm-versions.js index 379e66cd2..a8f4532d4 100644 --- a/core/api-server/lib/service/algorithm-versions.js +++ b/core/api-server/lib/service/algorithm-versions.js @@ -72,7 +72,7 @@ class AlgorithmVersions { throw new ResourceNotFoundError('algorithm', name); } if (algorithm.version === version) { - throw new ActionNotAllowed('unable to remove used version'); + throw new ActionNotAllowed('unable to remove the currently used version'); } const algorithmVersion = await versioning.getVersion({ version }); if (!algorithmVersion) { diff --git a/core/api-server/lib/service/pipeline-versions.js b/core/api-server/lib/service/pipeline-versions.js index 751fc6212..763d021a9 100644 --- a/core/api-server/lib/service/pipeline-versions.js +++ b/core/api-server/lib/service/pipeline-versions.js @@ -41,7 +41,7 @@ class PipelineVersions { if (!force) { const { length } = runningJobs; if (length > 0) { - throw new ActionNotAllowed(`The selected pipeline "${name}" is currently running on ${length} job${length === 1 ? '' : 's'}.`); + throw new ActionNotAllowed(`The selected pipeline ${name} is currently running on ${length} job${length === 1 ? '' : 's'}.`); } } else { @@ -63,7 +63,7 @@ class PipelineVersions { throw new ResourceNotFoundError('pipeline', name); } if (pipeline.version === version) { - throw new ActionNotAllowed('unable to remove used version'); + throw new ActionNotAllowed('unable to remove the currently used version'); } const pipelineVersion = await versioning.getVersion({ version }, true); if (!pipelineVersion) { From 502030bc6b983c00cf905652ab24ef34676f25db Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 16:53:06 +0200 Subject: [PATCH 14/26] updated error message --- core/api-server/tests/algorithms-versions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/api-server/tests/algorithms-versions.js b/core/api-server/tests/algorithms-versions.js index a67dc893f..c34269f9d 100644 --- a/core/api-server/tests/algorithms-versions.js +++ b/core/api-server/tests/algorithms-versions.js @@ -64,7 +64,7 @@ describe('Versions/Algorithms', () => { expect(res.body).to.have.property('error'); expect(res.body.error.code).to.equal(HttpStatus.StatusCodes.BAD_REQUEST); - expect(res.body.error.message).to.equal('unable to remove used version'); + expect(res.body.error.message).to.equal('unable to remove the currently used version'); }); it('should succeed to delete specific version', async () => { const algorithmImage1 = 'test-algorithmImage-1'; From c572b0f2d28e69e017a5020a6106d305f23a6e67 Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 16:53:35 +0200 Subject: [PATCH 15/26] now updating pipeline modified date when updating pipeline --- core/api-server/lib/state/state-manager.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/api-server/lib/state/state-manager.js b/core/api-server/lib/state/state-manager.js index 4fd2cb45f..f06b80850 100644 --- a/core/api-server/lib/state/state-manager.js +++ b/core/api-server/lib/state/state-manager.js @@ -259,6 +259,11 @@ class StateManager extends EventEmitter { } async updatePipeline(options) { + const pipeline = options; + if (!pipeline.created) { + pipeline.created = Date.now(); + } + pipeline.modified = Date.now(); return this._db.pipelines.update(options); } From a0f162b4a5f799f181284fbc76662fcecea81f26 Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 17:13:18 +0200 Subject: [PATCH 16/26] changed login to be only the token itself. --- core/api-server/api/rest-api/swagger.json | 16 ++++------------ .../api/rest-api/swagger.json | 16 ++++------------ core/gc-service/api/rest-api/swagger.json | 16 ++++------------ core/openapi-spec/swagger.json | 16 ++++------------ .../swagger/definitions/auth/loginResponse.yaml | 6 ++---- .../api/rest-api/swagger.json | 16 ++++------------ 6 files changed, 22 insertions(+), 64 deletions(-) diff --git a/core/api-server/api/rest-api/swagger.json b/core/api-server/api/rest-api/swagger.json index c0f45dfe1..4c2b55b3e 100644 --- a/core/api-server/api/rest-api/swagger.json +++ b/core/api-server/api/rest-api/swagger.json @@ -22803,12 +22803,8 @@ "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "token": { - "type": "string" - } - } + "type": "string", + "description": "The authentication token" } } } @@ -27833,12 +27829,8 @@ } }, "loginResponse": { - "type": "object", - "properties": { - "token": { - "type": "string" - } - } + "type": "string", + "description": "The authentication token" }, "loginRequest": { "type": "object", diff --git a/core/datasources-service/api/rest-api/swagger.json b/core/datasources-service/api/rest-api/swagger.json index c0f45dfe1..4c2b55b3e 100644 --- a/core/datasources-service/api/rest-api/swagger.json +++ b/core/datasources-service/api/rest-api/swagger.json @@ -22803,12 +22803,8 @@ "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "token": { - "type": "string" - } - } + "type": "string", + "description": "The authentication token" } } } @@ -27833,12 +27829,8 @@ } }, "loginResponse": { - "type": "object", - "properties": { - "token": { - "type": "string" - } - } + "type": "string", + "description": "The authentication token" }, "loginRequest": { "type": "object", diff --git a/core/gc-service/api/rest-api/swagger.json b/core/gc-service/api/rest-api/swagger.json index c0f45dfe1..4c2b55b3e 100644 --- a/core/gc-service/api/rest-api/swagger.json +++ b/core/gc-service/api/rest-api/swagger.json @@ -22803,12 +22803,8 @@ "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "token": { - "type": "string" - } - } + "type": "string", + "description": "The authentication token" } } } @@ -27833,12 +27829,8 @@ } }, "loginResponse": { - "type": "object", - "properties": { - "token": { - "type": "string" - } - } + "type": "string", + "description": "The authentication token" }, "loginRequest": { "type": "object", diff --git a/core/openapi-spec/swagger.json b/core/openapi-spec/swagger.json index c0f45dfe1..4c2b55b3e 100644 --- a/core/openapi-spec/swagger.json +++ b/core/openapi-spec/swagger.json @@ -22803,12 +22803,8 @@ "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "token": { - "type": "string" - } - } + "type": "string", + "description": "The authentication token" } } } @@ -27833,12 +27829,8 @@ } }, "loginResponse": { - "type": "object", - "properties": { - "token": { - "type": "string" - } - } + "type": "string", + "description": "The authentication token" }, "loginRequest": { "type": "object", diff --git a/core/openapi-spec/swagger/definitions/auth/loginResponse.yaml b/core/openapi-spec/swagger/definitions/auth/loginResponse.yaml index 976657ff4..90adcd342 100644 --- a/core/openapi-spec/swagger/definitions/auth/loginResponse.yaml +++ b/core/openapi-spec/swagger/definitions/auth/loginResponse.yaml @@ -1,4 +1,2 @@ -type: object -properties: - token: - type: string +type: string +description: "The authentication token" diff --git a/core/pipeline-driver-queue/api/rest-api/swagger.json b/core/pipeline-driver-queue/api/rest-api/swagger.json index c0f45dfe1..4c2b55b3e 100644 --- a/core/pipeline-driver-queue/api/rest-api/swagger.json +++ b/core/pipeline-driver-queue/api/rest-api/swagger.json @@ -22803,12 +22803,8 @@ "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "token": { - "type": "string" - } - } + "type": "string", + "description": "The authentication token" } } } @@ -27833,12 +27829,8 @@ } }, "loginResponse": { - "type": "object", - "properties": { - "token": { - "type": "string" - } - } + "type": "string", + "description": "The authentication token" }, "loginRequest": { "type": "object", From b0b98cdc692956eb7ea7267a0f2ec8e4b105c37a Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 17:27:03 +0200 Subject: [PATCH 17/26] added dependency --- core/openapi-spec/package-lock.json | 13 ++++++++++++- core/openapi-spec/package.json | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/core/openapi-spec/package-lock.json b/core/openapi-spec/package-lock.json index ddf970980..8ee3b8d22 100644 --- a/core/openapi-spec/package-lock.json +++ b/core/openapi-spec/package-lock.json @@ -9,7 +9,8 @@ "version": "2.8.8", "license": "MIT", "dependencies": { - "@hkube/rest-server": "^1.0.18" + "@hkube/rest-server": "^1.0.18", + "swagger-ui-dist": "^3.34.0" } }, "node_modules/@apidevtools/json-schema-ref-parser": { @@ -854,6 +855,11 @@ "node": ">=10" } }, + "node_modules/swagger-ui-dist": { + "version": "3.34.0", + "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.34.0.tgz", + "integrity": "sha512-xk5CMbwoQVI53rTq9o/iMojAqXP5NT4/+TMeTP4uXWDIH18pB9AXgO5Olqt0RXuf3jH032DA4DS4qzem6XdXAw==" + }, "node_modules/toidentifier": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", @@ -1642,6 +1648,11 @@ "@apidevtools/swagger-parser": "10.0.2" } }, + "swagger-ui-dist": { + "version": "3.34.0", + "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.34.0.tgz", + "integrity": "sha512-xk5CMbwoQVI53rTq9o/iMojAqXP5NT4/+TMeTP4uXWDIH18pB9AXgO5Olqt0RXuf3jH032DA4DS4qzem6XdXAw==" + }, "toidentifier": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", diff --git a/core/openapi-spec/package.json b/core/openapi-spec/package.json index 2ef1ea5f0..c6ba65d96 100644 --- a/core/openapi-spec/package.json +++ b/core/openapi-spec/package.json @@ -4,7 +4,8 @@ "description": "Hkube openapi-spec", "main": "app.js", "dependencies": { - "@hkube/rest-server": "^1.0.18" + "@hkube/rest-server": "^1.0.18", + "swagger-ui-dist": "^3.34.0" }, "scripts": { "build-swagger": "node ./swagger-builder.js && echo ../api-server/api/rest-api ../gc-service/api/rest-api ../datasources-service/api/rest-api ../pipeline-driver-queue/api/rest-api | xargs -n 1 cp swagger.json", From 3ec5153360ced79ddee5bf54f8ef73d17093ce4a Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 17:49:39 +0200 Subject: [PATCH 18/26] undo dependency addition --- core/openapi-spec/package-lock.json | 13 +------------ core/openapi-spec/package.json | 3 +-- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/core/openapi-spec/package-lock.json b/core/openapi-spec/package-lock.json index 8ee3b8d22..ddf970980 100644 --- a/core/openapi-spec/package-lock.json +++ b/core/openapi-spec/package-lock.json @@ -9,8 +9,7 @@ "version": "2.8.8", "license": "MIT", "dependencies": { - "@hkube/rest-server": "^1.0.18", - "swagger-ui-dist": "^3.34.0" + "@hkube/rest-server": "^1.0.18" } }, "node_modules/@apidevtools/json-schema-ref-parser": { @@ -855,11 +854,6 @@ "node": ">=10" } }, - "node_modules/swagger-ui-dist": { - "version": "3.34.0", - "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.34.0.tgz", - "integrity": "sha512-xk5CMbwoQVI53rTq9o/iMojAqXP5NT4/+TMeTP4uXWDIH18pB9AXgO5Olqt0RXuf3jH032DA4DS4qzem6XdXAw==" - }, "node_modules/toidentifier": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", @@ -1648,11 +1642,6 @@ "@apidevtools/swagger-parser": "10.0.2" } }, - "swagger-ui-dist": { - "version": "3.34.0", - "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.34.0.tgz", - "integrity": "sha512-xk5CMbwoQVI53rTq9o/iMojAqXP5NT4/+TMeTP4uXWDIH18pB9AXgO5Olqt0RXuf3jH032DA4DS4qzem6XdXAw==" - }, "toidentifier": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", diff --git a/core/openapi-spec/package.json b/core/openapi-spec/package.json index c6ba65d96..2ef1ea5f0 100644 --- a/core/openapi-spec/package.json +++ b/core/openapi-spec/package.json @@ -4,8 +4,7 @@ "description": "Hkube openapi-spec", "main": "app.js", "dependencies": { - "@hkube/rest-server": "^1.0.18", - "swagger-ui-dist": "^3.34.0" + "@hkube/rest-server": "^1.0.18" }, "scripts": { "build-swagger": "node ./swagger-builder.js && echo ../api-server/api/rest-api ../gc-service/api/rest-api ../datasources-service/api/rest-api ../pipeline-driver-queue/api/rest-api | xargs -n 1 cp swagger.json", From 74b0df3eabe6efeb0d02ad110ba6ea7edc41691d Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 17:51:44 +0200 Subject: [PATCH 19/26] sending back only the token itself --- core/api-server/api/rest-api/routes/v1/auth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/api-server/api/rest-api/routes/v1/auth.js b/core/api-server/api/rest-api/routes/v1/auth.js index 29366c6e9..9620f81fc 100644 --- a/core/api-server/api/rest-api/routes/v1/auth.js +++ b/core/api-server/api/rest-api/routes/v1/auth.js @@ -7,7 +7,7 @@ const routes = () => { try { // const { username, password } = req.body; const token = await auth.login(req.body); - res.json({ token }); + res.json(token); } catch (e) { next(e); From 85a8e249b0f110bb1af28ce88e25e07cdc59233e Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 18:14:01 +0200 Subject: [PATCH 20/26] undo login changes (not needed) --- core/api-server/api/rest-api/routes/v1/auth.js | 2 +- core/api-server/api/rest-api/swagger.json | 16 ++++++++++++---- .../api/rest-api/swagger.json | 16 ++++++++++++---- core/gc-service/api/rest-api/swagger.json | 16 ++++++++++++---- core/openapi-spec/swagger.json | 16 ++++++++++++---- .../swagger/definitions/auth/loginResponse.yaml | 6 ++++-- .../api/rest-api/swagger.json | 16 ++++++++++++---- 7 files changed, 65 insertions(+), 23 deletions(-) diff --git a/core/api-server/api/rest-api/routes/v1/auth.js b/core/api-server/api/rest-api/routes/v1/auth.js index 9620f81fc..29366c6e9 100644 --- a/core/api-server/api/rest-api/routes/v1/auth.js +++ b/core/api-server/api/rest-api/routes/v1/auth.js @@ -7,7 +7,7 @@ const routes = () => { try { // const { username, password } = req.body; const token = await auth.login(req.body); - res.json(token); + res.json({ token }); } catch (e) { next(e); diff --git a/core/api-server/api/rest-api/swagger.json b/core/api-server/api/rest-api/swagger.json index 4c2b55b3e..c0f45dfe1 100644 --- a/core/api-server/api/rest-api/swagger.json +++ b/core/api-server/api/rest-api/swagger.json @@ -22803,8 +22803,12 @@ "content": { "application/json": { "schema": { - "type": "string", - "description": "The authentication token" + "type": "object", + "properties": { + "token": { + "type": "string" + } + } } } } @@ -27829,8 +27833,12 @@ } }, "loginResponse": { - "type": "string", - "description": "The authentication token" + "type": "object", + "properties": { + "token": { + "type": "string" + } + } }, "loginRequest": { "type": "object", diff --git a/core/datasources-service/api/rest-api/swagger.json b/core/datasources-service/api/rest-api/swagger.json index 4c2b55b3e..c0f45dfe1 100644 --- a/core/datasources-service/api/rest-api/swagger.json +++ b/core/datasources-service/api/rest-api/swagger.json @@ -22803,8 +22803,12 @@ "content": { "application/json": { "schema": { - "type": "string", - "description": "The authentication token" + "type": "object", + "properties": { + "token": { + "type": "string" + } + } } } } @@ -27829,8 +27833,12 @@ } }, "loginResponse": { - "type": "string", - "description": "The authentication token" + "type": "object", + "properties": { + "token": { + "type": "string" + } + } }, "loginRequest": { "type": "object", diff --git a/core/gc-service/api/rest-api/swagger.json b/core/gc-service/api/rest-api/swagger.json index 4c2b55b3e..c0f45dfe1 100644 --- a/core/gc-service/api/rest-api/swagger.json +++ b/core/gc-service/api/rest-api/swagger.json @@ -22803,8 +22803,12 @@ "content": { "application/json": { "schema": { - "type": "string", - "description": "The authentication token" + "type": "object", + "properties": { + "token": { + "type": "string" + } + } } } } @@ -27829,8 +27833,12 @@ } }, "loginResponse": { - "type": "string", - "description": "The authentication token" + "type": "object", + "properties": { + "token": { + "type": "string" + } + } }, "loginRequest": { "type": "object", diff --git a/core/openapi-spec/swagger.json b/core/openapi-spec/swagger.json index 4c2b55b3e..c0f45dfe1 100644 --- a/core/openapi-spec/swagger.json +++ b/core/openapi-spec/swagger.json @@ -22803,8 +22803,12 @@ "content": { "application/json": { "schema": { - "type": "string", - "description": "The authentication token" + "type": "object", + "properties": { + "token": { + "type": "string" + } + } } } } @@ -27829,8 +27833,12 @@ } }, "loginResponse": { - "type": "string", - "description": "The authentication token" + "type": "object", + "properties": { + "token": { + "type": "string" + } + } }, "loginRequest": { "type": "object", diff --git a/core/openapi-spec/swagger/definitions/auth/loginResponse.yaml b/core/openapi-spec/swagger/definitions/auth/loginResponse.yaml index 90adcd342..976657ff4 100644 --- a/core/openapi-spec/swagger/definitions/auth/loginResponse.yaml +++ b/core/openapi-spec/swagger/definitions/auth/loginResponse.yaml @@ -1,2 +1,4 @@ -type: string -description: "The authentication token" +type: object +properties: + token: + type: string diff --git a/core/pipeline-driver-queue/api/rest-api/swagger.json b/core/pipeline-driver-queue/api/rest-api/swagger.json index 4c2b55b3e..c0f45dfe1 100644 --- a/core/pipeline-driver-queue/api/rest-api/swagger.json +++ b/core/pipeline-driver-queue/api/rest-api/swagger.json @@ -22803,8 +22803,12 @@ "content": { "application/json": { "schema": { - "type": "string", - "description": "The authentication token" + "type": "object", + "properties": { + "token": { + "type": "string" + } + } } } } @@ -27829,8 +27833,12 @@ } }, "loginResponse": { - "type": "string", - "description": "The authentication token" + "type": "object", + "properties": { + "token": { + "type": "string" + } + } }, "loginRequest": { "type": "object", From 8a2e834ebadb9160bb328d1f0265937b20867767 Mon Sep 17 00:00:00 2001 From: Adir111 Date: Mon, 24 Feb 2025 19:03:50 +0200 Subject: [PATCH 21/26] updated test suite --- core/api-server/tests/pipelines-versions.js | 100 ++++++++++++++------ 1 file changed, 73 insertions(+), 27 deletions(-) diff --git a/core/api-server/tests/pipelines-versions.js b/core/api-server/tests/pipelines-versions.js index 0e2437ace..aac29215b 100644 --- a/core/api-server/tests/pipelines-versions.js +++ b/core/api-server/tests/pipelines-versions.js @@ -4,19 +4,23 @@ const { uid: uuid } = require('@hkube/uid'); const { pipelines } = require('./mocks'); const { request } = require('./utils'); const stateManager = require('../lib/state/state-manager'); +const HttpStatus = require('http-status-codes'); let restUrl, restPath; describe('Versions/Pipelines', () => { - const pipeline = clone(pipelines[0]); + let pipeline; + beforeEach (() => { + pipeline = clone(pipelines[0]); + }); const addPipeline = async (pipeline) => { const name = `pipe-test-${uuid()}`; await stateManager.deletePipeline({ name, keepOldVersions: false }) - const addRequest = { uri: `${restUrl}/store/pipelines`, method: 'POST', body: pipeline }; pipeline.name = name; + const addRequest = { uri: `${restUrl}/store/pipelines`, method: 'POST', body: pipeline }; const res = await request(addRequest); - return { name, version: res.body.version }; + return res.body; } const updatePipeline = async (pipeline) => { @@ -34,7 +38,7 @@ describe('Versions/Pipelines', () => { const getSpecificVersion = async (name, version) => { const versionReq = { uri: `${restPath}/${name}/${version}`, method: 'GET' }; const res = await request(versionReq); - return res.body.version; + return res.body; } before(() => { @@ -42,35 +46,77 @@ describe('Versions/Pipelines', () => { restPath = `${restUrl}/versions/pipelines`; }); - describe('get', () => { - it('should succeed to get list of the new pipeline version', async () => { - const { name } = await addPipeline(pipeline); - const versionsList = await getAllVersions(name); - expect(versionsList).to.have.lengthOf(1); + describe('get methods', () => { + describe('getVersions method', () => { + it('should succeed to get list of the new pipeline version', async () => { + const { name, version: oldVersion } = await addPipeline(pipeline); + const versionsList1 = await getAllVersions(name); + expect(versionsList1).to.have.lengthOf(1); + pipeline.priority = 2; + const newVersion = await updatePipeline(pipeline); + expect(newVersion).to.not.equal(oldVersion); + const versionsList2 = await getAllVersions(name); + expect(versionsList2).to.have.lengthOf(2); + }); + + it('should return empty versions list for pipeline name which doesnt exist', async () => { + const versions = await getAllVersions('non-exist'); + expect(versions).to.be.an('array').that.is.empty; + }); }); - it('should succeed to get version', async () => { - const { name, version } = await addPipeline(pipeline); - const specificVersion = await getSpecificVersion(name, version); - expect(specificVersion).to.eql(version); + describe('getVersion method', () => { + it('should succeed to get version', async () => { + const { name, version } = await addPipeline(pipeline); + const { version: specificVersion } = await getSpecificVersion(name, version); + expect(specificVersion).to.eql(version); + }); + + it('should throw ResourceNotFoundError if pipeline is not found', async () => { + const { error } = await getSpecificVersion('non-exist', '6'); + expect(error.code).to.equal(HttpStatus.StatusCodes.NOT_FOUND); + expect(error.message).to.equal('pipeline non-exist Not Found'); + }); + + it('should throw ResourceNotFoundError if version is not found', async () => { + const { name } = await addPipeline(pipeline); + const { error } = await getSpecificVersion(name, '6'); + expect(error.code).to.equal(HttpStatus.StatusCodes.NOT_FOUND); + expect(error.message).to.equal('version 6 Not Found'); + }); }); - - it('should succeed to get versions and change version to latest', async () => { - const { name, version: oldVersion } = await addPipeline(pipeline); - const pipeline2 = clone(pipeline); - pipeline2.options.ttl = 6666; - const newVersion = await updatePipeline(pipeline2); - const versionsList = await getAllVersions(name) - const semver = versionsList.map((v) => v.semver); - expect(versionsList).to.have.lengthOf(2); - expect(semver).to.eql(['1.0.1', '1.0.0']); - expect(oldVersion).to.be.not.equal(newVersion); - expect(newVersion).to.be.equal(versionsList[0].version); - expect(versionsList[0].semver).to.be.equal('1.0.1'); + }); + + describe('update methods', () => { + describe('updating the pipeline itself', () => { + it('should succeed to get versions and change version to latest, plus change semver', async () => { + const { name, version: oldVersion } = await addPipeline(pipeline); + pipeline.options.ttl = 6666; + const newVersion = await updatePipeline(pipeline); + const versionsList = await getAllVersions(name) + const semver = versionsList.map((v) => v.semver); + expect(versionsList).to.have.lengthOf(2); + expect(semver).to.eql(['1.0.1', '1.0.0']); + expect(oldVersion).to.be.not.equal(newVersion); + expect(newVersion).to.be.equal(versionsList[0].version); + expect(versionsList[0].semver).to.be.equal('1.0.1'); + }); + + it('should not change version if the same pipeline has been inserted, without any update', async () => { + const addedPipeline = await addPipeline(pipeline); + const { name, version } = addedPipeline; + const versionAfterUpdate = await updatePipeline(addedPipeline); + const versionsList = await getAllVersions(name); + const semver = versionsList.map((v) => v.semver); + expect(versionsList).to.have.lengthOf(1); + expect(semver).to.eql(['1.0.0']); + expect(version).to.eql(versionAfterUpdate); + expect(version).to.be.equal(versionsList[0].version); + }); }); }); - describe('versions when pipeline is deleted', () => { + describe('versions handling when pipeline is deleted', () => { it('should return empty list after pipeline deleted', async () => { const { name } = await addPipeline(pipeline); await stateManager.deletePipeline({ name, keepOldVersions: false }); From c1553abf96bdf4d30a3f1e39ceaf1242e67154cf Mon Sep 17 00:00:00 2001 From: Adir111 Date: Tue, 25 Feb 2025 09:57:23 +0200 Subject: [PATCH 22/26] not needed --- .../lib/service/pipeline-versions.js | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/core/api-server/lib/service/pipeline-versions.js b/core/api-server/lib/service/pipeline-versions.js index 763d021a9..de14ab578 100644 --- a/core/api-server/lib/service/pipeline-versions.js +++ b/core/api-server/lib/service/pipeline-versions.js @@ -1,7 +1,6 @@ const asyncQueue = require('async.queue'); const versioning = require('./versioning'); const validator = require('../validation/api-validator'); -const Execution = require('./execution'); const stateManager = require('../state/state-manager'); const { ResourceNotFoundError, ActionNotAllowed } = require('../errors'); @@ -32,25 +31,10 @@ class PipelineVersions { } async applyVersion(options) { - const { name, version, force } = options; + const { name, version } = options; validator.pipelines.validatePipelineVersion(options); const pipelineVersion = await this.getVersion({ name, version }); - // check if the pipeline is running - const runningJobs = await stateManager.searchJobs({ pipelineName: name, hasResult: false, fields: { jobId: true } }); - if (!force) { - const { length } = runningJobs; - if (length > 0) { - throw new ActionNotAllowed(`The selected pipeline ${name} is currently running on ${length} job${length === 1 ? '' : 's'}.`); - } - } - else { - runningJobs.forEach(element => { - const { jobId } = element; - Execution.stopJob({ jobId, reason: 'Pipeline version has been changed.' }); - }); - } - await stateManager.updatePipeline(pipelineVersion.pipeline); return pipelineVersion; } From 817d22df5fcc37f1cff6b6b9898429b7cf930aef Mon Sep 17 00:00:00 2001 From: Adir111 Date: Tue, 25 Feb 2025 09:57:46 +0200 Subject: [PATCH 23/26] added applying tests --- core/api-server/tests/pipelines-versions.js | 57 ++++++++++++++++++--- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/core/api-server/tests/pipelines-versions.js b/core/api-server/tests/pipelines-versions.js index aac29215b..703a8bc56 100644 --- a/core/api-server/tests/pipelines-versions.js +++ b/core/api-server/tests/pipelines-versions.js @@ -5,15 +5,20 @@ const { pipelines } = require('./mocks'); const { request } = require('./utils'); const stateManager = require('../lib/state/state-manager'); const HttpStatus = require('http-status-codes'); -let restUrl, restPath; -describe('Versions/Pipelines', () => { +describe.only('Versions/Pipelines', () => { let pipeline; + let restUrl, restPath; beforeEach (() => { pipeline = clone(pipelines[0]); }); + before(() => { + restUrl = global.testParams.restUrl; + restPath = `${restUrl}/versions/pipelines`; + }); + const addPipeline = async (pipeline) => { const name = `pipe-test-${uuid()}`; await stateManager.deletePipeline({ name, keepOldVersions: false }) @@ -29,6 +34,12 @@ describe('Versions/Pipelines', () => { return res.body.version; } + const getPipelineCurrentVersion = async (name) => { + const getRequest = { uri: `${restUrl}/store/pipelines/${name}`, method: 'GET' }; + const res = await request(getRequest); + return res.body.version; + } + const getAllVersions = async (name) => { const versionReq = { uri: `${restPath}/${name}`, method: 'GET' }; const res = await request(versionReq); @@ -41,10 +52,11 @@ describe('Versions/Pipelines', () => { return res.body; } - before(() => { - restUrl = global.testParams.restUrl; - restPath = `${restUrl}/versions/pipelines`; - }); + const updatePipelineVersion = async (name, version) => { + const updateRequest = { uri: `${restPath}/apply`, method: 'POST', body: { name, version, force: true } }; + const res = await request(updateRequest); + return res.body; + } describe('get methods', () => { describe('getVersions method', () => { @@ -52,9 +64,11 @@ describe('Versions/Pipelines', () => { const { name, version: oldVersion } = await addPipeline(pipeline); const versionsList1 = await getAllVersions(name); expect(versionsList1).to.have.lengthOf(1); + pipeline.priority = 2; const newVersion = await updatePipeline(pipeline); expect(newVersion).to.not.equal(oldVersion); + const versionsList2 = await getAllVersions(name); expect(versionsList2).to.have.lengthOf(2); }); @@ -95,6 +109,7 @@ describe('Versions/Pipelines', () => { const newVersion = await updatePipeline(pipeline); const versionsList = await getAllVersions(name) const semver = versionsList.map((v) => v.semver); + expect(versionsList).to.have.lengthOf(2); expect(semver).to.eql(['1.0.1', '1.0.0']); expect(oldVersion).to.be.not.equal(newVersion); @@ -108,12 +123,42 @@ describe('Versions/Pipelines', () => { const versionAfterUpdate = await updatePipeline(addedPipeline); const versionsList = await getAllVersions(name); const semver = versionsList.map((v) => v.semver); + expect(versionsList).to.have.lengthOf(1); expect(semver).to.eql(['1.0.0']); expect(version).to.eql(versionAfterUpdate); expect(version).to.be.equal(versionsList[0].version); }); }); + + describe('applying pipeline version (change to other version)', () => { + it('should succeed to apply version', async () => { + const { name, version: version1 } = await addPipeline(pipeline); + pipeline.priority = 2; + const version2 = await updatePipeline(pipeline); + const currentVersion2 = await getPipelineCurrentVersion(name); + expect(version1).to.not.equal(version2); + expect(version2).to.equal(currentVersion2); + + await updatePipelineVersion(name, version1); + const currentVersion1 = await getPipelineCurrentVersion(name); + + expect(currentVersion1).to.equal(version1); + }); + + it('should throw ResourceNotFoundError if pipeline is not found', async () => { + const { error } = await updatePipelineVersion('non-exist', '6'); + expect(error.code).to.equal(HttpStatus.StatusCodes.NOT_FOUND); + expect(error.message).to.equal('pipeline non-exist Not Found'); + }); + + it('should throw ResourceNotFoundError if version is not found', async () => { + const { name } = await addPipeline(pipeline); + const { error } = await updatePipelineVersion(name, '6'); + expect(error.code).to.equal(HttpStatus.StatusCodes.NOT_FOUND); + expect(error.message).to.equal('version 6 Not Found'); + }); + }); }); describe('versions handling when pipeline is deleted', () => { From fd43ec0a2320cf0e0c5aa5596b5963db7611ae08 Mon Sep 17 00:00:00 2001 From: Adir111 Date: Tue, 25 Feb 2025 10:18:42 +0200 Subject: [PATCH 24/26] finished get and update tests --- core/api-server/tests/pipelines-versions.js | 32 ++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/core/api-server/tests/pipelines-versions.js b/core/api-server/tests/pipelines-versions.js index 703a8bc56..4f7bb3ea9 100644 --- a/core/api-server/tests/pipelines-versions.js +++ b/core/api-server/tests/pipelines-versions.js @@ -7,7 +7,7 @@ const stateManager = require('../lib/state/state-manager'); const HttpStatus = require('http-status-codes'); -describe.only('Versions/Pipelines', () => { +describe('Versions/Pipelines', () => { let pipeline; let restUrl, restPath; beforeEach (() => { @@ -77,6 +77,12 @@ describe.only('Versions/Pipelines', () => { const versions = await getAllVersions('non-exist'); expect(versions).to.be.an('array').that.is.empty; }); + + it('should fail validation since name is not a string', async () => { + const { error } = await getAllVersions({}); + expect(error.code).to.equal(HttpStatus.StatusCodes.BAD_REQUEST); + expect(error.message).to.equal('pipeline name must contain only alphanumeric, dash, dot or underscore'); + }); }); describe('getVersion method', () => { @@ -158,6 +164,30 @@ describe.only('Versions/Pipelines', () => { expect(error.code).to.equal(HttpStatus.StatusCodes.NOT_FOUND); expect(error.message).to.equal('version 6 Not Found'); }); + + it('should throw validation error of data.name should be string', async () => { + const { error } = await updatePipelineVersion({}, '6'); + expect(error.code).to.equal(HttpStatus.StatusCodes.BAD_REQUEST); + expect(error.message).to.equal('data.name should be string'); + }); + + it('should throw validation error of data.version should be string', async () => { + const { error } = await updatePipelineVersion('pipename', {}); + expect(error.code).to.equal(HttpStatus.StatusCodes.BAD_REQUEST); + expect(error.message).to.equal('data.version should be string'); + }); + + it('should throw validation error of required property name', async () => { + const { error } = await updatePipelineVersion(undefined, {}); + expect(error.code).to.equal(HttpStatus.StatusCodes.BAD_REQUEST); + expect(error.message).to.equal("data should have required property 'name'"); + }); + + it('should throw validation error of required property version', async () => { + const { error } = await updatePipelineVersion('pipename', undefined); + expect(error.code).to.equal(HttpStatus.StatusCodes.BAD_REQUEST); + expect(error.message).to.equal("data should have required property 'version'"); + }); }); }); From 679a0b2822becf9051d642f7852e965d86b597cc Mon Sep 17 00:00:00 2001 From: Adir111 Date: Tue, 25 Feb 2025 10:35:38 +0200 Subject: [PATCH 25/26] added deletion unit tests --- core/api-server/tests/pipelines-versions.js | 74 ++++++++++++++++++--- 1 file changed, 63 insertions(+), 11 deletions(-) diff --git a/core/api-server/tests/pipelines-versions.js b/core/api-server/tests/pipelines-versions.js index 4f7bb3ea9..3b5319fbc 100644 --- a/core/api-server/tests/pipelines-versions.js +++ b/core/api-server/tests/pipelines-versions.js @@ -58,6 +58,12 @@ describe('Versions/Pipelines', () => { return res.body; } + const deleteVersion = async (name, version) => { + const deleteRequest = { uri: `${restPath}/${name}/${version}`, method: 'DELETE' }; + const res = await request(deleteRequest); + return res.body; + } + describe('get methods', () => { describe('getVersions method', () => { it('should succeed to get list of the new pipeline version', async () => { @@ -191,19 +197,65 @@ describe('Versions/Pipelines', () => { }); }); - describe('versions handling when pipeline is deleted', () => { - it('should return empty list after pipeline deleted', async () => { - const { name } = await addPipeline(pipeline); - await stateManager.deletePipeline({ name, keepOldVersions: false }); - const versionsList = await getAllVersions(name); - expect(versionsList).to.have.lengthOf(0); + describe('delete methods', () => { + describe('versions handling when pipeline is deleted', () => { + it('should return empty list after pipeline deleted', async () => { + const { name } = await addPipeline(pipeline); + await stateManager.deletePipeline({ name, keepOldVersions: false }); + const versionsList = await getAllVersions(name); + expect(versionsList).to.have.lengthOf(0); + }); + + it('should return the versions of the deleted pipeline', async () => { + const { name } = await addPipeline(pipeline); + await stateManager.deletePipeline({ name, keepOldVersions: true }); + const versionsList = await getAllVersions(name); + expect(versionsList).to.have.lengthOf(1); + }); }); - it('should return the versions of the deleted pipeline', async () => { - const { name } = await addPipeline(pipeline); - await stateManager.deletePipeline({ name, keepOldVersions: true }); - const versionsList = await getAllVersions(name); - expect(versionsList).to.have.lengthOf(1); + describe('deleting versions test', () => { + it('should delete version', async () => { + const { name, version: version1 } = await addPipeline(pipeline); + pipeline.priority = 2; + const version2 = await updatePipeline(pipeline); + expect(version1).to.not.equal(version2); + + const versionsList1 = await getAllVersions(name); + const { deleted } = await deleteVersion(name, version1); + const versionsList2 = await getAllVersions(name); + expect(deleted).to.equal(1); + expect(versionsList1).to.have.lengthOf(2); + expect(versionsList2).to.have.lengthOf(1); + }); + + it('should throw ActionNotAllowed when trying to delete the currently used version of pipeline', async () => { + const { name, version: version1 } = await addPipeline(pipeline); + pipeline.priority = 2; + const version2 = await updatePipeline(pipeline); + expect(version1).to.not.equal(version2); + + const versionsList1 = await getAllVersions(name); + const { error } = await deleteVersion(name, version2); + const versionsList2 = await getAllVersions(name); + expect(error.code).to.equal(HttpStatus.StatusCodes.BAD_REQUEST); + expect(error.message).to.equal('unable to remove the currently used version'); + expect(versionsList1).to.have.lengthOf(2); + expect(versionsList2).to.have.lengthOf(2); + }); + + it('should throw ResourceNotFoundError non-existing pipeline', async () => { + const { error } = await deleteVersion('non-exist', '6'); + expect(error.code).to.equal(HttpStatus.StatusCodes.NOT_FOUND); + expect(error.message).to.equal('pipeline non-exist Not Found'); + }); + + it('should throw ResourceNotFoundError non-existing version of an existing pipeline', async () => { + const { name } = await addPipeline(pipeline); + const { error } = await deleteVersion(name, 'non-exist'); + expect(error.code).to.equal(HttpStatus.StatusCodes.NOT_FOUND); + expect(error.message).to.equal('version non-exist Not Found'); + }); }); }); }); From 6a867fa1aa62122937a675c799303f4e5cc6c8c4 Mon Sep 17 00:00:00 2001 From: Adir111 Date: Tue, 25 Feb 2025 11:30:09 +0200 Subject: [PATCH 26/26] removed 'force' from swagger for pipeline --- core/api-server/api/rest-api/swagger.json | 12 +----------- core/api-server/tests/pipelines-versions.js | 2 +- core/datasources-service/api/rest-api/swagger.json | 12 +----------- core/gc-service/api/rest-api/swagger.json | 12 +----------- core/openapi-spec/swagger.json | 12 +----------- .../definitions/pipelines/applyPipelineVersion.yaml | 4 ---- .../swagger/paths/versions/pipelines/apply.yaml | 2 +- core/pipeline-driver-queue/api/rest-api/swagger.json | 12 +----------- 8 files changed, 7 insertions(+), 61 deletions(-) diff --git a/core/api-server/api/rest-api/swagger.json b/core/api-server/api/rest-api/swagger.json index c0f45dfe1..c4938f4b6 100644 --- a/core/api-server/api/rest-api/swagger.json +++ b/core/api-server/api/rest-api/swagger.json @@ -20045,11 +20045,6 @@ "description": "Unique identifier representing version id", "minLength": 1, "maxLength": 10 - }, - "force": { - "type": "boolean", - "description": "should replace or not current pipeline version, if pipeline is running", - "default": false } }, "required": [ @@ -20059,7 +20054,7 @@ } } }, - "description": "an object representing the pipeline name, the version to change to, and force flag (when forced, pipeline execution stops)", + "description": "an object representing the pipeline name and the version to change to", "required": true }, "responses": { @@ -27590,11 +27585,6 @@ "description": "Unique identifier representing version id", "minLength": 1, "maxLength": 10 - }, - "force": { - "type": "boolean", - "description": "should replace or not current pipeline version, if pipeline is running", - "default": false } }, "required": [ diff --git a/core/api-server/tests/pipelines-versions.js b/core/api-server/tests/pipelines-versions.js index 3b5319fbc..1cb494c42 100644 --- a/core/api-server/tests/pipelines-versions.js +++ b/core/api-server/tests/pipelines-versions.js @@ -53,7 +53,7 @@ describe('Versions/Pipelines', () => { } const updatePipelineVersion = async (name, version) => { - const updateRequest = { uri: `${restPath}/apply`, method: 'POST', body: { name, version, force: true } }; + const updateRequest = { uri: `${restPath}/apply`, method: 'POST', body: { name, version } }; const res = await request(updateRequest); return res.body; } diff --git a/core/datasources-service/api/rest-api/swagger.json b/core/datasources-service/api/rest-api/swagger.json index c0f45dfe1..c4938f4b6 100644 --- a/core/datasources-service/api/rest-api/swagger.json +++ b/core/datasources-service/api/rest-api/swagger.json @@ -20045,11 +20045,6 @@ "description": "Unique identifier representing version id", "minLength": 1, "maxLength": 10 - }, - "force": { - "type": "boolean", - "description": "should replace or not current pipeline version, if pipeline is running", - "default": false } }, "required": [ @@ -20059,7 +20054,7 @@ } } }, - "description": "an object representing the pipeline name, the version to change to, and force flag (when forced, pipeline execution stops)", + "description": "an object representing the pipeline name and the version to change to", "required": true }, "responses": { @@ -27590,11 +27585,6 @@ "description": "Unique identifier representing version id", "minLength": 1, "maxLength": 10 - }, - "force": { - "type": "boolean", - "description": "should replace or not current pipeline version, if pipeline is running", - "default": false } }, "required": [ diff --git a/core/gc-service/api/rest-api/swagger.json b/core/gc-service/api/rest-api/swagger.json index c0f45dfe1..c4938f4b6 100644 --- a/core/gc-service/api/rest-api/swagger.json +++ b/core/gc-service/api/rest-api/swagger.json @@ -20045,11 +20045,6 @@ "description": "Unique identifier representing version id", "minLength": 1, "maxLength": 10 - }, - "force": { - "type": "boolean", - "description": "should replace or not current pipeline version, if pipeline is running", - "default": false } }, "required": [ @@ -20059,7 +20054,7 @@ } } }, - "description": "an object representing the pipeline name, the version to change to, and force flag (when forced, pipeline execution stops)", + "description": "an object representing the pipeline name and the version to change to", "required": true }, "responses": { @@ -27590,11 +27585,6 @@ "description": "Unique identifier representing version id", "minLength": 1, "maxLength": 10 - }, - "force": { - "type": "boolean", - "description": "should replace or not current pipeline version, if pipeline is running", - "default": false } }, "required": [ diff --git a/core/openapi-spec/swagger.json b/core/openapi-spec/swagger.json index c0f45dfe1..c4938f4b6 100644 --- a/core/openapi-spec/swagger.json +++ b/core/openapi-spec/swagger.json @@ -20045,11 +20045,6 @@ "description": "Unique identifier representing version id", "minLength": 1, "maxLength": 10 - }, - "force": { - "type": "boolean", - "description": "should replace or not current pipeline version, if pipeline is running", - "default": false } }, "required": [ @@ -20059,7 +20054,7 @@ } } }, - "description": "an object representing the pipeline name, the version to change to, and force flag (when forced, pipeline execution stops)", + "description": "an object representing the pipeline name and the version to change to", "required": true }, "responses": { @@ -27590,11 +27585,6 @@ "description": "Unique identifier representing version id", "minLength": 1, "maxLength": 10 - }, - "force": { - "type": "boolean", - "description": "should replace or not current pipeline version, if pipeline is running", - "default": false } }, "required": [ diff --git a/core/openapi-spec/swagger/definitions/pipelines/applyPipelineVersion.yaml b/core/openapi-spec/swagger/definitions/pipelines/applyPipelineVersion.yaml index 6381a4fa5..6de313c0e 100644 --- a/core/openapi-spec/swagger/definitions/pipelines/applyPipelineVersion.yaml +++ b/core/openapi-spec/swagger/definitions/pipelines/applyPipelineVersion.yaml @@ -4,10 +4,6 @@ properties: $ref: "#/components/schemas/pipelineName" version: $ref: "#/components/schemas/pipelineVersionId" - force: - type: boolean - description: should replace or not current pipeline version, if pipeline is running - default: false required: - name - version diff --git a/core/openapi-spec/swagger/paths/versions/pipelines/apply.yaml b/core/openapi-spec/swagger/paths/versions/pipelines/apply.yaml index aab4265d4..b8bcdf4e8 100644 --- a/core/openapi-spec/swagger/paths/versions/pipelines/apply.yaml +++ b/core/openapi-spec/swagger/paths/versions/pipelines/apply.yaml @@ -8,7 +8,7 @@ post: application/json: schema: $ref: "#/components/schemas/applyPipelineVersion" - description: an object representing the pipeline name, the version to change to, and force flag (when forced, pipeline execution stops) + description: an object representing the pipeline name and the version to change to required: true responses: "200": diff --git a/core/pipeline-driver-queue/api/rest-api/swagger.json b/core/pipeline-driver-queue/api/rest-api/swagger.json index c0f45dfe1..c4938f4b6 100644 --- a/core/pipeline-driver-queue/api/rest-api/swagger.json +++ b/core/pipeline-driver-queue/api/rest-api/swagger.json @@ -20045,11 +20045,6 @@ "description": "Unique identifier representing version id", "minLength": 1, "maxLength": 10 - }, - "force": { - "type": "boolean", - "description": "should replace or not current pipeline version, if pipeline is running", - "default": false } }, "required": [ @@ -20059,7 +20054,7 @@ } } }, - "description": "an object representing the pipeline name, the version to change to, and force flag (when forced, pipeline execution stops)", + "description": "an object representing the pipeline name and the version to change to", "required": true }, "responses": { @@ -27590,11 +27585,6 @@ "description": "Unique identifier representing version id", "minLength": 1, "maxLength": 10 - }, - "force": { - "type": "boolean", - "description": "should replace or not current pipeline version, if pipeline is running", - "default": false } }, "required": [