Skip to content

Commit

Permalink
fix(deploy/ha): Orca reads should point to clouddriver-ro. (#1068)
Browse files Browse the repository at this point in the history
  • Loading branch information
joonlim authored Oct 15, 2018
1 parent 7e64227 commit b45a4ee
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public Class<Orca> getEndpointClass() {
return Orca.class;
}

protected void appendReadonlyClouddriver(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
}

@Override
public List<Profile> getProfiles(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
List<Profile> profiles = super.getProfiles(deploymentConfiguration, endpoints);
Expand All @@ -65,6 +68,8 @@ public List<Profile> getProfiles(DeploymentConfiguration deploymentConfiguration
String path = Paths.get(getConfigOutputPath(), filename).toString();
Profile profile = orcaProfileFactory.getProfile(filename, path, deploymentConfiguration, endpoints);

appendReadonlyClouddriver(profile, deploymentConfiguration, endpoints);

profiles.add(profile);
return profiles;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ public List<Profile> getProfiles(DeploymentConfiguration deploymentConfiguration
return profiles;
}

@Override
protected boolean hasServiceOverrides(DeploymentConfiguration deploymentConfiguration) {
HaServices haServices = deploymentConfiguration.getDeploymentEnvironment().getHaServices();
return haServices.getClouddriver().getRedisMasterEndpoint() != null;
}

@Override
protected SpinnakerRuntimeSettings getServiceOverrides(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
SpinnakerRuntimeSettings serviceOverrides = super.getServiceOverrides(deploymentConfiguration, endpoints);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ public List<Profile> getProfiles(DeploymentConfiguration deploymentConfiguration
return profiles;
}

@Override
protected boolean hasServiceOverrides(DeploymentConfiguration deploymentConfiguration) {
HaServices haServices = deploymentConfiguration.getDeploymentEnvironment().getHaServices();
return haServices.getClouddriver().getRedisSlaveEndpoint() != null;
}

@Override
protected SpinnakerRuntimeSettings getServiceOverrides(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
SpinnakerRuntimeSettings serviceOverrides = super.getServiceOverrides(deploymentConfiguration, endpoints);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ public List<Profile> getProfiles(DeploymentConfiguration deploymentConfiguration
return profiles;
}

@Override
protected boolean hasServiceOverrides(DeploymentConfiguration deploymentConfiguration) {
HaServices haServices = deploymentConfiguration.getDeploymentEnvironment().getHaServices();
return haServices.getClouddriver().getRedisMasterEndpoint() != null;
}

@Override
protected SpinnakerRuntimeSettings getServiceOverrides(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
SpinnakerRuntimeSettings serviceOverrides = super.getServiceOverrides(deploymentConfiguration, endpoints);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
import com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings;
import com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.DistributedService.DeployPriority;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Delegate;
Expand Down Expand Up @@ -83,4 +85,15 @@ protected List<Type> overrideServiceEndpoints() {
Type.ECHO_WORKER
);
}

@Override
protected void appendReadonlyClouddriver(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
if (hasServiceOverrides(deploymentConfiguration)) {
Map<String, Map<String, Map<String, String>>> clouddriver = Collections.singletonMap(
"clouddriver", Collections.singletonMap(
"readonly", Collections.singletonMap(
"baseUrl", endpoints.getServiceSettings(Type.CLOUDDRIVER_RO).getBaseUrl())));
profile.appendContents("\n" + getYamlParser().dump(clouddriver));
}
}
}

0 comments on commit b45a4ee

Please sign in to comment.