use of org.eclipse.che.workspace.infrastructure.kubernetes.RuntimeLogsPublisher in project che-server by eclipse-che.
the class DeployBroker method execute.
@Override
public List<ChePlugin> execute() throws InfrastructureException {
LOG.debug("Starting brokers pod for workspace '{}'", runtimeId.getWorkspaceId());
Span tracingSpan = tracer.buildSpan(DEPLOY_BROKER_PHASE).start();
TracingTags.WORKSPACE_ID.set(tracingSpan, runtimeId.getWorkspaceId());
KubernetesDeployments deployments = namespace.deployments();
try {
// broker in a workspace.
for (ConfigMap configMap : brokerEnvironment.getConfigMaps().values()) {
namespace.configMaps().create(configMap);
}
for (Secret secret : brokerEnvironment.getSecrets().values()) {
namespace.secrets().create(secret);
}
Pod pluginBrokerPod = getPluginBrokerPod(brokerEnvironment.getPodsCopy());
if (factory.isConfigured()) {
UnrecoverablePodEventListener unrecoverableEventListener = factory.create(ImmutableSet.of(pluginBrokerPod.getMetadata().getName()), this::handleUnrecoverableEvent);
namespace.deployments().watchEvents(unrecoverableEventListener);
}
namespace.deployments().watchEvents(new RuntimeLogsPublisher(runtimeEventsPublisher, runtimeId, ImmutableSet.of(pluginBrokerPod.getMetadata().getName())));
deployments.create(pluginBrokerPod);
watchLogsIfDebugEnabled(startOptions, pluginBrokerPod);
LOG.debug("Brokers pod is created for workspace '{}'", runtimeId.getWorkspaceId());
tracingSpan.finish();
return nextPhase.execute();
} catch (InfrastructureException e) {
namespace.deployments().stopWatch(true);
// Ensure span is finished with exception message
TracingTags.setErrorStatus(tracingSpan, e);
tracingSpan.finish();
throw e;
} finally {
namespace.deployments().stopWatch();
try {
deployments.delete();
} catch (InfrastructureException e) {
LOG.error("Brokers pod removal failed. Error: " + e.getLocalizedMessage(), e);
}
try {
namespace.secrets().delete();
} catch (InfrastructureException ex) {
LOG.error("Brokers secret removal failed. Error: " + ex.getLocalizedMessage(), ex);
}
try {
namespace.configMaps().delete();
} catch (InfrastructureException ex) {
LOG.error("Brokers config map removal failed. Error: " + ex.getLocalizedMessage(), ex);
}
}
}
use of org.eclipse.che.workspace.infrastructure.kubernetes.RuntimeLogsPublisher in project devspaces-images by redhat-developer.
the class DeployBroker method execute.
@Override
public List<ChePlugin> execute() throws InfrastructureException {
LOG.debug("Starting brokers pod for workspace '{}'", runtimeId.getWorkspaceId());
Span tracingSpan = tracer.buildSpan(DEPLOY_BROKER_PHASE).start();
TracingTags.WORKSPACE_ID.set(tracingSpan, runtimeId.getWorkspaceId());
KubernetesDeployments deployments = namespace.deployments();
try {
// broker in a workspace.
for (ConfigMap configMap : brokerEnvironment.getConfigMaps().values()) {
namespace.configMaps().create(configMap);
}
for (Secret secret : brokerEnvironment.getSecrets().values()) {
namespace.secrets().create(secret);
}
Pod pluginBrokerPod = getPluginBrokerPod(brokerEnvironment.getPodsCopy());
if (factory.isConfigured()) {
UnrecoverablePodEventListener unrecoverableEventListener = factory.create(ImmutableSet.of(pluginBrokerPod.getMetadata().getName()), this::handleUnrecoverableEvent);
namespace.deployments().watchEvents(unrecoverableEventListener);
}
namespace.deployments().watchEvents(new RuntimeLogsPublisher(runtimeEventsPublisher, runtimeId, ImmutableSet.of(pluginBrokerPod.getMetadata().getName())));
deployments.create(pluginBrokerPod);
watchLogsIfDebugEnabled(startOptions, pluginBrokerPod);
LOG.debug("Brokers pod is created for workspace '{}'", runtimeId.getWorkspaceId());
tracingSpan.finish();
return nextPhase.execute();
} catch (InfrastructureException e) {
namespace.deployments().stopWatch(true);
// Ensure span is finished with exception message
TracingTags.setErrorStatus(tracingSpan, e);
tracingSpan.finish();
throw e;
} finally {
namespace.deployments().stopWatch();
try {
deployments.delete();
} catch (InfrastructureException e) {
LOG.error("Brokers pod removal failed. Error: " + e.getLocalizedMessage(), e);
}
try {
namespace.secrets().delete();
} catch (InfrastructureException ex) {
LOG.error("Brokers secret removal failed. Error: " + ex.getLocalizedMessage(), ex);
}
try {
namespace.configMaps().delete();
} catch (InfrastructureException ex) {
LOG.error("Brokers config map removal failed. Error: " + ex.getLocalizedMessage(), ex);
}
}
}
Aggregations