use of io.seldon.clustermanager.k8s.SeldonDeploymentOperatorImpl.DeploymentResources in project seldon-core by SeldonIO.
the class SeldonDeploymentControllerImpl method createOrReplaceSeldonDeployment.
@Override
public void createOrReplaceSeldonDeployment(SeldonDeployment mlDep) {
if (mlDep.hasStatus() && mlDep.getStatus().hasState() && mlDep.getStatus().getState().equals(FAILED_STATE_MSG)) {
logger.warn("Ignoring failed deployment " + mlDep.getMetadata().getName());
return;
}
try {
SeldonDeployment existing = mlCache.get(mlDep.getMetadata().getName());
if (existing == null || !existing.getSpec().equals(mlDep.getSpec())) {
logger.debug("Running updates for " + mlDep.getMetadata().getName());
SeldonDeployment mlDep2 = operator.defaulting(mlDep);
operator.validate(mlDep2);
mlCache.put(mlDep2);
DeploymentResources resources = operator.createResources(mlDep2);
ProtoClient client = clientProvider.getProtoClient();
String namespace = getNamespace(mlDep2);
createDeployments(client, namespace, resources.deployments);
removeDeployments(client, namespace, mlDep2, resources.deployments);
createService(client, namespace, resources.service);
if (!mlDep.getSpec().equals(mlDep2.getSpec())) {
logger.debug("Pushing updated SeldonDeployment " + mlDep2.getMetadata().getName() + " back to kubectl");
crdHandler.updateSeldonDeployment(mlDep2);
} else
logger.debug("Not pushing an update as no change to spec for SeldonDeployment " + mlDep2.getMetadata().getName());
} else {
mlCache.put(mlDep);
logger.debug("Only updated cache for " + mlDep.getMetadata().getName());
}
} catch (SeldonDeploymentException e) {
logger.error("Failed to create deployment ", e);
failDeployment(mlDep, e);
} catch (ApiException e) {
logger.error("Kubernetes API exception deploying code:" + e.getCode() + "message:" + e.getResponseBody(), e);
failDeployment(mlDep, e);
} catch (IOException e) {
logger.error("IOException during createReplace ", e);
failDeployment(mlDep, e);
}
}
Aggregations