use of org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition.Status in project srs-fleet-manager by bf2fc6cc711aee1a0c2a.
the class StartDeprovisionRegistryWorker method execute.
@Transactional
@Override
public void execute(Task aTask, WorkerContext ctl) throws RegistryStorageConflictException {
StartDeprovisionRegistryTask task = (StartDeprovisionRegistryTask) aTask;
Optional<RegistryData> registryOptional = storage.getRegistryById(task.getRegistryId());
if (registryOptional.isPresent()) {
// FAILURE POINT 1
var registry = registryOptional.get();
var force = Instant.now().isAfter(registry.getCreatedAt().plus(props.getDeprovisionStuckInstanceTimeout()));
if (force) {
log.warn("Registry instance '{}' is forced to be deprovisioned.", registry);
}
var deprovision = force;
var status = RegistryStatusValueDto.of(registry.getStatus());
switch(status) {
case ACCEPTED:
case PROVISIONING:
if (!force) {
log.debug("Provisioning in progress. Retrying.");
ctl.retry();
}
break;
case READY:
case FAILED:
deprovision = true;
break;
case REQUESTED_DEPROVISIONING:
case DEPROVISIONING_DELETING:
if (!force) {
log.debug("Deprovisioning is already in progress. Stopping. Registry = {}", registry);
ctl.stop();
}
break;
default:
throw new IllegalStateException("Unexpected status value: " + status);
}
if (deprovision) {
registry.setStatus(RegistryStatusValueDto.DEPROVISIONING_DELETING.value());
// FAILURE POINT 2
storage.createOrUpdateRegistry(registry);
ctl.delay(() -> tasks.submit(DeprovisionRegistryTask.builder().registryId(registry.getId()).build()));
}
} else {
log.warn("Registry id='{}' not found. Stopping.", task.getRegistryId());
ctl.stop();
}
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition.Status in project srs-fleet-manager by bf2fc6cc711aee1a0c2a.
the class RegistryServiceImpl method getRegistries.
@Override
public RegistryListDto getRegistries(Integer page, Integer size, String orderBy, String search) {
// Defaults
var sort = Sort.by("id", Sort.Direction.Ascending);
page = (page != null) ? page : 1;
size = (size != null) ? size : 10;
if (orderBy != null) {
var order = orderBy.split(" ");
if (order.length != 2) {
throw new ValidationException("invalid orderBy");
}
if ("asc".equals(order[1])) {
sort = Sort.by(order[0], Sort.Direction.Ascending);
} else {
sort = Sort.by(order[0], Sort.Direction.Descending);
}
}
List<Pair<String, Object>> conditions = new ArrayList<>();
if (search != null && !search.isEmpty()) {
var basicQuery = new BasicQuery(search, Arrays.asList("name", "status"));
conditions.add(Pair.of(basicQuery.getColumn(), basicQuery.getArgument()));
}
// list only registries from your organization or the ones the user owns
if (isResolvable(securityIdentity)) {
final AccountInfo accountInfo = authService.extractAccountInfo();
String orgId = accountInfo.getOrganizationId();
if (orgId != null) {
conditions.add(Pair.of("orgId", orgId));
} else {
conditions.add(Pair.of("ownerId", accountInfo.getAccountId()));
}
} else {
conditions.add(Pair.of("ownerId", OWNER_ID_PLACEHOLDER));
}
var query = new SearchQuery(conditions);
PanacheQuery<RegistryData> itemsQuery = storage.executeRegistrySearchQuery(query, sort);
var items = itemsQuery.page(Page.of(page - 1, size)).stream().map(convertRegistry::convert).collect(Collectors.toList());
return RegistryListDto.builder().items(items).page(page).size(size).total(itemsQuery.count()).build();
}
use of org.bf2.operator.resources.v1alpha1.ManagedKafkaCondition.Status in project cos-fleetshard by bf2fc6cc711aee1a0c2a.
the class ConnectorStatusExtractor method extract.
public static ConnectorDeploymentStatus extract(ManagedConnector connector) {
ConnectorDeploymentStatus status = new ConnectorDeploymentStatus();
DeploymentSpec deployment = connector.getSpec().getDeployment();
if (connector.getStatus() != null && connector.getStatus().getPhase() != null) {
deployment = connector.getStatus().getDeployment();
}
status.setResourceVersion(deployment.getDeploymentResourceVersion());
if (connector.getSpec().getOperatorSelector() == null || connector.getSpec().getOperatorSelector().getId() == null) {
status.setPhase(STATE_FAILED);
status.addConditionsItem(new MetaV1Condition().type(Conditions.TYPE_READY).status(Conditions.STATUS_FALSE).message("No assignable operator").reason(Conditions.NO_ASSIGNABLE_OPERATOR_REASON).lastTransitionTime(Conditions.now()));
return status;
}
if (connector.getStatus() != null && connector.getStatus().getConnectorStatus() != null) {
status.setOperators(new ConnectorDeploymentStatusOperators().assigned(toConnectorOperator(connector.getStatus().getConnectorStatus().getAssignedOperator())).available(toConnectorOperator(connector.getStatus().getConnectorStatus().getAvailableOperator())));
if (connector.getStatus().getConnectorStatus() != null) {
if (connector.getStatus().getConnectorStatus().getPhase() != null) {
status.setPhase(connector.getStatus().getConnectorStatus().getPhase());
}
if (connector.getStatus().getConnectorStatus().getConditions() != null) {
for (var cond : connector.getStatus().getConnectorStatus().getConditions()) {
status.addConditionsItem(toMetaV1Condition(cond));
}
}
}
}
if (status.getPhase() == null) {
if (DESIRED_STATE_DELETED.equals(deployment.getDesiredState())) {
status.setPhase(STATE_DE_PROVISIONING);
} else if (DESIRED_STATE_STOPPED.equals(deployment.getDesiredState())) {
status.setPhase(STATE_DE_PROVISIONING);
} else {
status.setPhase(STATE_PROVISIONING);
}
}
return status;
}
Aggregations