Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deploy): Gracefully handle missing artifacts #918

Merged
merged 2 commits into from
Apr 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.netflix.spinnaker.halyard.core.problem.v1.Problem;
import com.netflix.spinnaker.halyard.deploy.services.v1.GenerateService;
import com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings;
import com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings;
import com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService;
import com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.bake.BakeService;
import com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.bake.BakeServiceProvider;
Expand All @@ -43,7 +44,10 @@ public RemoteAction deploy(
List<SpinnakerService.Type> serviceTypes) {
List<BakeService> enabledServices = serviceProvider.getPrioritizedBakeableServices(serviceTypes)
.stream()
.filter(i -> resolvedConfiguration.getServiceSettings(i.getService()).getEnabled())
.filter(i -> {
ServiceSettings serviceSettings = resolvedConfiguration.getServiceSettings(i.getService());
return serviceSettings != null && serviceSettings.getEnabled();
})
.collect(Collectors.toList());

Map<String, String> installCommands = enabledServices.stream().reduce(new HashMap<>(), (commands, installable) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public RemoteAction deploy(DistributedServiceProvider<T> serviceProvider,
.getPrioritizedDistributedServices(serviceTypes)) {
SpinnakerService service = distributedService.getService();
ServiceSettings settings = resolvedConfiguration.getServiceSettings(service);
if (!settings.getEnabled() || settings.getSkipLifeCycleManagement()) {
if (settings == null || !settings.getEnabled() || settings.getSkipLifeCycleManagement()) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public RemoteAction deploy(KubectlServiceProvider serviceProvider,
List<KubernetesV2Service> services = serviceProvider.getServicesByPriority(serviceTypes);
services.stream().forEach((service) -> {
ServiceSettings settings = resolvedConfiguration.getServiceSettings((SpinnakerService) service);
if (settings == null) {
return;
}

if (settings.getEnabled() != null && !settings.getEnabled()) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings;
import com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ClouddriverService;
import com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.RedisService;
import com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.ServiceSettings;
import com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.SpinnakerService;
import com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.local.LocalService;
import com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.local.LocalServiceProvider;
Expand All @@ -46,7 +47,11 @@ public RemoteAction deploy(
List<SpinnakerService.Type> serviceTypes) {
List<LocalService> enabledServices = serviceProvider.getLocalServices(serviceTypes)
.stream()
.filter(i -> resolvedConfiguration.getServiceSettings(i.getService()).getEnabled())
.filter(i -> resolvedConfiguration.getServiceSettings(i.getService()) != null)
.filter(i -> {
ServiceSettings serviceSettings = resolvedConfiguration.getServiceSettings(i.getService());
return serviceSettings != null && serviceSettings.getEnabled();
})
.collect(Collectors.toList());

Map<String, String> installCommands = enabledServices.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ public ServiceSettings getDefaultServiceSettings(DeploymentConfiguration deploym
}
}

public boolean isInBillOfMaterials(DeploymentConfiguration deployment) {
String version = getArtifactService().getArtifactVersion(deployment.getName(), getArtifact());
return (version != null);
}

abstract public Type getType();
abstract public Class<T> getEndpointClass();
abstract public List<Profile> getProfiles(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ public SpinnakerRuntimeSettings buildRuntimeSettings(DeploymentConfiguration dep
SpinnakerRuntimeSettings endpoints = new SpinnakerRuntimeSettings();
for (SpinnakerService.Type type : SpinnakerService.Type.values()) {
SpinnakerService service = getSpinnakerService(type);
if (service != null) {
if (service != null && service.isInBillOfMaterials(deploymentConfiguration)) {
log.info("Building service settings entry for " + service.getServiceName());
ServiceSettings settings = service.getDefaultServiceSettings(deploymentConfiguration);
settings.mergePreferThis(service.buildServiceSettings(deploymentConfiguration));

endpoints.setServiceSettings(type, settings);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ default void ensureRunning(AccountDeploymentDetails<GoogleAccount> details,
boolean ready = false;
DaemonTaskHandler.message("Waiting for all instances to become healthy.");
while (!ready) {
ready = getRunningServiceDetails(details, runtimeSettings).getLatestEnabledVersion() == version;
Integer runningVersion = getRunningServiceDetails(details, runtimeSettings).getLatestEnabledVersion();
ready = version.equals(runningVersion);

DaemonTaskHandler.safeSleep(TimeUnit.SECONDS.toMillis(2));
}
Expand Down