本文整理汇总了Java中io.fabric8.kubernetes.client.KubernetesClientException.getCode方法的典型用法代码示例。如果您正苦于以下问题:Java KubernetesClientException.getCode方法的具体用法?Java KubernetesClientException.getCode怎么用?Java KubernetesClientException.getCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.fabric8.kubernetes.client.KubernetesClientException
的用法示例。
在下文中一共展示了KubernetesClientException.getCode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import io.fabric8.kubernetes.client.KubernetesClientException; //导入方法依赖的package包/类
@Override
public StatusUpdate execute(Integration integration) {
try {
openShiftService().scale(integration.getName(), 0);
logInfo(integration,"Deactivated");
} catch (KubernetesClientException e) {
// Ignore 404 errors, means the deployment does not exist for us
// to scale down
if( e.getCode() != 404 ) {
throw e;
}
}
Integration.Status currentStatus = openShiftService().isScaled(integration.getName(), 0)
? Integration.Status.Deactivated
: Integration.Status.Pending;
return new StatusUpdate(currentStatus);
}
示例2: pollRun
import io.fabric8.kubernetes.client.KubernetesClientException; //导入方法依赖的package包/类
protected synchronized void pollRun(Run run) {
if (!(run instanceof WorkflowRun)) {
throw new IllegalStateException("Cannot poll a non-workflow run");
}
RunExt wfRunExt = RunExt.create((WorkflowRun) run);
// try blue run
BlueRun blueRun = null;
ExtensionList<BlueRunFactory> facts = BlueRunFactory.all();
for (BlueRunFactory fact : facts) {
blueRun = fact.getRun(run, null);
if (blueRun != null) {
break;
}
}
try {
upsertBuild(run, wfRunExt, blueRun);
} catch (KubernetesClientException e) {
if (e.getCode() == HttpStatus.SC_UNPROCESSABLE_ENTITY) {
runsToPoll.remove(run);
logger.log(WARNING, "Cannot update status: {0}", e.getMessage());
return;
}
throw e;
}
}
示例3: deleteSecret
import io.fabric8.kubernetes.client.KubernetesClientException; //导入方法依赖的package包/类
private void deleteSecret(Secret secret) {
LOG.info("[AUDIT] Deleting service account {} secret {}", serviceAccount(secret),
secret.getMetadata().getName());
try {
client.secrets().delete(secret);
} catch (KubernetesClientException e) {
if (e.getCode() == 404) {
LOG.debug("Couldn't find secret to delete {}", secret.getMetadata().getName());
} else {
LOG.warn("[AUDIT] Failed to delete secret {}", secret.getMetadata().getName());
throw e;
}
}
}
示例4: get
import io.fabric8.kubernetes.client.KubernetesClientException; //导入方法依赖的package包/类
private Project get(String projectName, OpenShiftClient client) throws InfrastructureException {
try {
return client.projects().withName(projectName).get();
} catch (KubernetesClientException e) {
if (e.getCode() == 403) {
// project is foreign or doesn't exist
return null;
} else {
throw new InfrastructureException(e.getMessage(), e);
}
}
}
示例5: isMatchingException
import io.fabric8.kubernetes.client.KubernetesClientException; //导入方法依赖的package包/类
private boolean isMatchingException(KubernetesClientException kce) {
return kce.getCode() == statusCode && kce.getStatus().getReason().contains(statusReason);
}
示例6: createProject
import io.fabric8.kubernetes.client.KubernetesClientException; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public OpenShiftProject createProject(final String name) throws
DuplicateProjectException,
IllegalArgumentException {
// Create
final ProjectRequest projectRequest;
try {
projectRequest = client.projectrequests().createNew().
withNewMetadata().
withName(name).
endMetadata().
done();
} catch (final KubernetesClientException kce) {
// Detect if duplicate project
if (kce.getCode() == CODE_DUPLICATE_PROJECT &&
STATUS_REASON_DUPLICATE_PROJECT.equals(kce.getStatus().getReason())) {
throw new DuplicateProjectException(name);
}
// Some other error, rethrow it
throw kce;
}
// Block until exists
int counter = 0;
while (true) {
counter++;
if (projectExists(name)) {
// We good
break;
}
if (counter == 20) {
throw new IllegalStateException("Newly-created project "
+ name + " could not be found ");
}
log.finest("Couldn't find project " + name +
" after creating; waiting and trying again...");
try {
Thread.sleep(3000);
} catch (final InterruptedException ie) {
Thread.interrupted();
throw new RuntimeException("Someone interrupted thread while finding newly-created project", ie);
}
}
// Populate value object and return it
final String roundtripDisplayName = projectRequest.getMetadata().getName();
final OpenShiftProject project = new OpenShiftProjectImpl(roundtripDisplayName, consoleUrl.toString());
return project;
}