Skip to content

Commit

Permalink
feat(provider/aws): Add a new stage task, to invoke the Clouddriver L…
Browse files Browse the repository at this point in the history
…ambda OnDemand caching agent. (spinnaker#3305)
  • Loading branch information
madhusarma authored and mergify[bot] committed Dec 4, 2019
1 parent 86b5fc2 commit 693527c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.netflix.spinnaker.orca.clouddriver.pipeline.providers.aws;

import com.netflix.spinnaker.orca.clouddriver.tasks.MonitorKatoTask;
import com.netflix.spinnaker.orca.clouddriver.tasks.providers.aws.lambda.LambdaFunctionForceRefreshTask;
import com.netflix.spinnaker.orca.clouddriver.tasks.providers.aws.lambda.LambdaFunctionTask;
import com.netflix.spinnaker.orca.pipeline.StageDefinitionBuilder;
import com.netflix.spinnaker.orca.pipeline.TaskNode;
Expand All @@ -31,6 +32,7 @@ public class LambdaFunctionStage implements StageDefinitionBuilder {
public void taskGraph(@Nonnull Stage stage, @Nonnull TaskNode.Builder builder) {
builder
.withTask(LambdaFunctionTask.TASK_NAME, LambdaFunctionTask.class)
.withTask("monitorLambdaFunction", MonitorKatoTask.class);
.withTask("monitorLambdaFunction", MonitorKatoTask.class)
.withTask(LambdaFunctionForceRefreshTask.TASK_NAME, LambdaFunctionForceRefreshTask.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2019 Netflix, Inc.
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.spinnaker.orca.clouddriver.tasks.providers.aws.lambda;

import com.netflix.spinnaker.orca.ExecutionStatus;
import com.netflix.spinnaker.orca.Task;
import com.netflix.spinnaker.orca.TaskResult;
import com.netflix.spinnaker.orca.clouddriver.CloudDriverCacheService;
import com.netflix.spinnaker.orca.clouddriver.tasks.AbstractCloudProviderAwareTask;
import com.netflix.spinnaker.orca.pipeline.model.Stage;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class LambdaFunctionForceRefreshTask extends AbstractCloudProviderAwareTask implements Task {

static final String REFRESH_TYPE = "Function";

public static final String TASK_NAME = "forceCacheRefresh";

@Autowired private CloudDriverCacheService cacheService;

@Override
public TaskResult execute(Stage stage) {
String cloudProvider = getCloudProvider(stage);

Map<String, Object> task = new HashMap<>(stage.getContext());
task.put("appName", stage.getExecution().getApplication());

cacheService.forceCacheUpdate(cloudProvider, REFRESH_TYPE, task);

return TaskResult.ofStatus(ExecutionStatus.SUCCEEDED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public TaskResult execute(@Nonnull Stage stage) {
String cloudProvider = getCloudProvider(stage);

Map<String, Object> task = new HashMap<>(stage.getContext());
task.put("appName", stage.getExecution().getApplication());

String operationName = (String) task.get("operation");
if (StringUtils.isBlank(operationName)) {
Expand Down

0 comments on commit 693527c

Please sign in to comment.