use of io.kubernetes.client.proto.Meta.DeleteOptions in project seldon-core by SeldonIO.
the class SeldonDeploymentControllerImpl method removeDeployments.
private void removeDeployments(ProtoClient client, String namespace, SeldonDeployment seldonDeployment, List<Deployment> deployments) throws ApiException, IOException, SeldonDeploymentException {
Set<String> names = getDeploymentNames(deployments);
ExtensionsV1beta1DeploymentList depList = crdHandler.getOwnedDeployments(seldonDeployment.getSpec().getName());
for (ExtensionsV1beta1Deployment d : depList.getItems()) {
if (!names.contains(d.getMetadata().getName())) {
final String deleteApiPath = "/apis/" + DEPLOYMENT_API_VERSION + "/namespaces/{namespace}/deployments/{name}".replaceAll("\\{" + "name" + "\\}", client.getApiClient().escapeString(d.getMetadata().getName())).replaceAll("\\{" + "namespace" + "\\}", client.getApiClient().escapeString(namespace));
DeleteOptions options = DeleteOptions.newBuilder().setPropagationPolicy("Foreground").build();
ObjectOrStatus<Deployment> os = client.delete(Deployment.newBuilder(), deleteApiPath, options);
if (os.status != null) {
logger.error("Error deleting deployment:" + ProtoBufUtils.toJson(os.status));
throw new SeldonDeploymentException("Failed to delete deployment " + d.getMetadata().getName());
} else {
logger.debug("Deleted deployment:" + ProtoBufUtils.toJson(os.object));
}
}
}
}
Aggregations