Skip to content

Commit

Permalink
Merge pull request #227 from orkes-io/workflow_upgrade
Browse files Browse the repository at this point in the history
Upgrade api
  • Loading branch information
manan164 authored Sep 18, 2023
2 parents 482bf5e + 213cb32 commit b59bd2c
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2023 Netflix, Inc.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.netflix.conductor.common.metadata.workflow;

import java.util.Map;

import javax.validation.constraints.NotNull;

import com.netflix.conductor.annotations.protogen.ProtoField;
import com.netflix.conductor.annotations.protogen.ProtoMessage;

@ProtoMessage
public class UpgradeWorkflowRequest {

public Map<String, Object> getTaskOutput() {
return taskOutput;
}

public void setTaskOutput(Map<String, Object> taskOutput) {
this.taskOutput = taskOutput;
}

public Map<String, Object> getWorkflowInput() {
return workflowInput;
}

public void setWorkflowInput(Map<String, Object> workflowInput) {
this.workflowInput = workflowInput;
}

@ProtoField(id = 4)
private Map<String, Object> taskOutput;

@ProtoField(id = 3)
private Map<String, Object> workflowInput;

@ProtoField(id = 2)
private Integer version;

@NotNull(message = "Workflow name cannot be null or empty")
@ProtoField(id = 1)
private String name;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Integer getVersion() {
return version;
}

public void setVersion(Integer version) {
this.version = version;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
import com.netflix.conductor.annotations.Trace;
import com.netflix.conductor.annotations.VisibleForTesting;
import com.netflix.conductor.common.metadata.tasks.*;
import com.netflix.conductor.common.metadata.workflow.RerunWorkflowRequest;
import com.netflix.conductor.common.metadata.workflow.SkipTaskRequest;
import com.netflix.conductor.common.metadata.workflow.WorkflowDef;
import com.netflix.conductor.common.metadata.workflow.WorkflowTask;
import com.netflix.conductor.common.metadata.workflow.*;
import com.netflix.conductor.common.run.Workflow;
import com.netflix.conductor.common.utils.TaskUtils;
import com.netflix.conductor.core.WorkflowContext;
Expand Down Expand Up @@ -2155,4 +2152,7 @@ public WorkflowModel jumpWorkflowExecutionToTask(
String workflowId, String taskReferenceName, Map<String, Object> input) {
return executionDAOFacade.getWorkflowModel(workflowId, true);
}

public void upgradeRunningWorkflowToVersion(
String workflowId, UpgradeWorkflowRequest upgradeWorkflowRequest) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@

import org.springframework.validation.annotation.Validated;

import com.netflix.conductor.common.metadata.workflow.RerunWorkflowRequest;
import com.netflix.conductor.common.metadata.workflow.SkipTaskRequest;
import com.netflix.conductor.common.metadata.workflow.StartWorkflowRequest;
import com.netflix.conductor.common.metadata.workflow.WorkflowDef;
import com.netflix.conductor.common.metadata.workflow.*;
import com.netflix.conductor.common.run.ExternalStorageLocation;
import com.netflix.conductor.common.run.SearchResult;
import com.netflix.conductor.common.run.Workflow;
Expand Down Expand Up @@ -434,4 +431,7 @@ SearchResult<Workflow> searchWorkflowsByTasksV2(
*/
ExternalStorageLocation getExternalStorageLocation(
String path, String operation, String payloadType);

void upgradeRunningWorkflowToVersion(
String workflowId, UpgradeWorkflowRequest upgradeWorkflowRequest);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@

import com.netflix.conductor.annotations.Audit;
import com.netflix.conductor.annotations.Trace;
import com.netflix.conductor.common.metadata.workflow.RerunWorkflowRequest;
import com.netflix.conductor.common.metadata.workflow.SkipTaskRequest;
import com.netflix.conductor.common.metadata.workflow.StartWorkflowRequest;
import com.netflix.conductor.common.metadata.workflow.WorkflowDef;
import com.netflix.conductor.common.metadata.workflow.*;
import com.netflix.conductor.common.run.ExternalStorageLocation;
import com.netflix.conductor.common.run.SearchResult;
import com.netflix.conductor.common.run.Workflow;
Expand Down Expand Up @@ -600,4 +597,10 @@ public ExternalStorageLocation getExternalStorageLocation(
path);
}
}

@Override
public void upgradeRunningWorkflowToVersion(
String workflowId, UpgradeWorkflowRequest upgradeWorkflowRequest) {
workflowExecutor.upgradeRunningWorkflowToVersion(workflowId, upgradeWorkflowRequest);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.netflix.conductor.common.metadata.workflow.RerunWorkflowRequest;
import com.netflix.conductor.common.metadata.workflow.SkipTaskRequest;
import com.netflix.conductor.common.metadata.workflow.StartWorkflowRequest;
import com.netflix.conductor.common.metadata.workflow.UpgradeWorkflowRequest;
import com.netflix.conductor.common.run.*;
import com.netflix.conductor.service.WorkflowService;
import com.netflix.conductor.service.WorkflowTestService;
Expand Down Expand Up @@ -283,4 +284,14 @@ public ExternalStorageLocation getExternalStorageLocation(
public Workflow testWorkflow(@RequestBody WorkflowTestRequest request) {
return workflowTestService.testWorkflow(request);
}

@PostMapping("/{workflowId}/upgrade")
@Operation(
summary = "Upgrade running workflow to newer version",
description = "Upgrade running workflow to newer version")
public void upgradeRunningWorkflowToVersion(
@PathVariable("workflowId") String workflowId,
@RequestBody UpgradeWorkflowRequest upgradeWorkflowRequest) {
workflowService.upgradeRunningWorkflowToVersion(workflowId, upgradeWorkflowRequest);
}
}

0 comments on commit b59bd2c

Please sign in to comment.