Search in sources :

Example 1 with DeleteOptions

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));
            }
        }
    }
}
Also used : DeleteOptions(io.kubernetes.client.proto.Meta.DeleteOptions) ExtensionsV1beta1DeploymentList(io.kubernetes.client.models.ExtensionsV1beta1DeploymentList) ExtensionsV1beta1Deployment(io.kubernetes.client.models.ExtensionsV1beta1Deployment) SeldonDeployment(io.seldon.protos.DeploymentProtos.SeldonDeployment) Deployment(io.kubernetes.client.proto.V1beta1Extensions.Deployment) ExtensionsV1beta1Deployment(io.kubernetes.client.models.ExtensionsV1beta1Deployment)

Aggregations

ExtensionsV1beta1Deployment (io.kubernetes.client.models.ExtensionsV1beta1Deployment)1 ExtensionsV1beta1DeploymentList (io.kubernetes.client.models.ExtensionsV1beta1DeploymentList)1 DeleteOptions (io.kubernetes.client.proto.Meta.DeleteOptions)1 Deployment (io.kubernetes.client.proto.V1beta1Extensions.Deployment)1 SeldonDeployment (io.seldon.protos.DeploymentProtos.SeldonDeployment)1