forked from spinnaker/orca
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(after stages): Always dynamically build after stages
- Loading branch information
1 parent
b97d741
commit 7e843cd
Showing
36 changed files
with
964 additions
and
639 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 0 additions & 66 deletions
66
.../groovy/com/netflix/spinnaker/orca/clouddriver/pipeline/cluster/ShrinkClusterStage.groovy
This file was deleted.
Oops, something went wrong.
77 changes: 77 additions & 0 deletions
77
...in/groovy/com/netflix/spinnaker/orca/clouddriver/pipeline/cluster/ShrinkClusterStage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright 2015 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.pipeline.cluster; | ||
|
||
import com.netflix.spinnaker.orca.clouddriver.tasks.cluster.AbstractClusterWideClouddriverTask; | ||
import com.netflix.spinnaker.orca.clouddriver.tasks.cluster.AbstractWaitForClusterWideClouddriverTask; | ||
import com.netflix.spinnaker.orca.clouddriver.tasks.cluster.ShrinkClusterTask; | ||
import com.netflix.spinnaker.orca.clouddriver.tasks.cluster.WaitForClusterShrinkTask; | ||
import com.netflix.spinnaker.orca.pipeline.graph.StageGraphBuilder; | ||
import com.netflix.spinnaker.orca.pipeline.model.Stage; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
@Component | ||
public class ShrinkClusterStage extends AbstractClusterWideClouddriverOperationStage { | ||
|
||
private final DisableClusterStage disableClusterStage; | ||
|
||
@Autowired | ||
public ShrinkClusterStage(DisableClusterStage disableClusterStage) { | ||
this.disableClusterStage = disableClusterStage; | ||
} | ||
|
||
@Override | ||
public Class<? extends AbstractClusterWideClouddriverTask> getClusterOperationTask() { | ||
return ShrinkClusterTask.class; | ||
} | ||
|
||
@Override | ||
public Class<? extends AbstractWaitForClusterWideClouddriverTask> getWaitForTask() { | ||
return WaitForClusterShrinkTask.class; | ||
} | ||
|
||
@Override | ||
public void beforeStages( | ||
@Nonnull Stage parent, | ||
@Nonnull StageGraphBuilder graph | ||
) { | ||
if (Objects.equals(parent.getContext().get("allowDeleteActive"), true)) { | ||
Map<String, Object> context = new HashMap<>(parent.getContext()); | ||
context.put("remainingEnabledServerGroups", parent.getContext().get("shrinkToSize")); | ||
context.put("preferLargerOverNewer", parent.getContext().get("retainLargerOverNewer")); | ||
context.put("continueIfClusterNotFound", Objects.equals(parent.getContext().get("shrinkToSize"), 0)); | ||
|
||
// We don't want the key propagated if interestingHealthProviderNames isn't defined, since this prevents | ||
// health providers from the stage's 'determineHealthProviders' task to be added to the context. | ||
if (parent.getContext().get("interestingHealthProviderNames") != null) { | ||
context.put("interestingHealthProviderNames", parent.getContext().get("interestingHealthProviderNames")); | ||
} | ||
|
||
graph.add((it) -> { | ||
it.setType(disableClusterStage.getType()); | ||
it.setName("disableCluster"); | ||
it.setContext(context); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.