Skip to content

Commit 01a69b0

Browse files
authored
Fixed max replicas value (#212)
source and sink have been updated successfully, but there is an issue with the return value, fix this issue
1 parent fa46a09 commit 01a69b0

5 files changed

Lines changed: 14 additions & 2 deletions

File tree

mesh-worker-service/src/main/java/io/functionmesh/compute/util/FunctionsUtil.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,10 @@ public static FunctionConfig createFunctionConfigFromV1alpha1Function(String ten
302302
customRuntimeOptions.setClusterName(v1alpha1FunctionSpec.getClusterName());
303303
}
304304

305+
if (v1alpha1FunctionSpec.getMaxReplicas() != null && v1alpha1FunctionSpec.getMaxReplicas() > 0) {
306+
customRuntimeOptions.setMaxReplicas(v1alpha1FunctionSpec.getMaxReplicas());
307+
}
308+
305309
if (v1alpha1FunctionSpecInput.getTopics() != null) {
306310
for (String topic : v1alpha1FunctionSpecInput.getTopics()) {
307311
ConsumerConfig consumerConfig = new ConsumerConfig();

mesh-worker-service/src/main/java/io/functionmesh/compute/util/SinksUtil.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,9 @@ public static SinkConfig createSinkConfigFromV1alpha1Sink(
298298
if (Strings.isNotEmpty(v1alpha1SinkSpec.getClusterName())) {
299299
customRuntimeOptions.setClusterName(v1alpha1SinkSpec.getClusterName());
300300
}
301+
if (v1alpha1SinkSpec.getMaxReplicas() != null && v1alpha1SinkSpec.getMaxReplicas() > 0) {
302+
customRuntimeOptions.setMaxReplicas(v1alpha1SinkSpec.getMaxReplicas());
303+
}
301304

302305
if (v1alpha1SinkSpecInput.getTopics() != null) {
303306
for (String topic : v1alpha1SinkSpecInput.getTopics()) {

mesh-worker-service/src/main/java/io/functionmesh/compute/util/SourcesUtil.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ public static SourceConfig createSourceConfigFromV1alpha1Source(String tenant, S
279279
customRuntimeOptions.setClusterName(v1alpha1SourceSpec.getClusterName());
280280
}
281281

282+
if (v1alpha1SourceSpec.getMaxReplicas() != null && v1alpha1SourceSpec.getMaxReplicas() > 0) {
283+
customRuntimeOptions.setMaxReplicas(v1alpha1SourceSpec.getMaxReplicas());
284+
}
285+
282286
if (v1alpha1SourceSpec.getSourceConfig() != null) {
283287
sourceConfig.setConfigs(new HashMap<>(v1alpha1SourceSpec.getSourceConfig()));
284288
}
@@ -300,6 +304,7 @@ public static SourceConfig createSourceConfigFromV1alpha1Source(String tenant, S
300304
sourceConfig.setRuntimeFlags(v1alpha1SourceSpec.getRuntimeFlags());
301305
}
302306

307+
303308
if (v1alpha1SourceSpec.getJava() != null && Strings.isNotEmpty(v1alpha1SourceSpec.getJava().getJar())) {
304309
sourceConfig.setArchive(v1alpha1SourceSpec.getJava().getJar());
305310
}

mesh-worker-service/src/test/java/io/functionmesh/compute/rest/api/SinksImpTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ public void testGetSinkInfo() throws ApiException, IOException {
729729
Double cpu = 0.1;
730730
Long ram = 1L;
731731
String clusterName = "test-pulsar";
732-
String customRuntimeOptions = "{\"clusterName\":\"" + clusterName + "\",\"maxReplicas\":0}";
732+
String customRuntimeOptions = "{\"clusterName\":\"" + clusterName + "\",\"maxReplicas\":1}";
733733
Map<String, Object> configs = new HashMap<>();
734734
configs.put("elasticSearchUrl", "https://testing-es.app");
735735

mesh-worker-service/src/test/java/io/functionmesh/compute/rest/api/SourcesImpTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ public void testGetSourceInfo()
756756
Double cpu = 0.1;
757757
Long ram = 1L;
758758
String clusterName = "test-pulsar";
759-
String customRuntimeOptions = "{\"clusterName\":\"" + clusterName + "\",\"maxReplicas\":0}";
759+
String customRuntimeOptions = "{\"clusterName\":\"" + clusterName + "\",\"maxReplicas\":1}";
760760
Map<String, Object> configs = new HashMap<>();
761761
String configsName = "test-sourceConfig";
762762
configs.put("name", configsName);

0 commit comments

Comments
 (0)