protected boolean isResourceReadyToBeObserved()

in flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/observer/AbstractFlinkResourceObserver.java [61:93]


    protected boolean isResourceReadyToBeObserved(FlinkResourceContext<CR> ctx) {
        var resource = ctx.getResource();
        var reconciliationStatus = resource.getStatus().getReconciliationStatus();

        if (reconciliationStatus.isBeforeFirstDeployment()) {
            logger.debug("Skipping observe before first deployment");
            return false;
        }

        if (reconciliationStatus.getState() == ReconciliationState.ROLLING_BACK) {
            logger.debug("Skipping observe during rollback operation");
            return false;
        }

        // We are in the middle or possibly right after an upgrade
        if (reconciliationStatus.getState() == ReconciliationState.UPGRADING) {
            // We must check if the upgrade went through without the status upgrade for some reason

            if (reconciliationStatus.scalingInProgress()) {
                if (ctx.getFlinkService().scalingCompleted(ctx)) {
                    reconciliationStatus.setState(ReconciliationState.DEPLOYED);
                }
            } else if (checkIfAlreadyUpgraded(ctx)) {
                ReconciliationUtils.updateStatusForAlreadyUpgraded(resource);
            } else {
                ReconciliationUtils.clearLastReconciledSpecIfFirstDeploy(resource);
                logger.debug("Skipping observe before resource is deployed during upgrade");
                return false;
            }
        }

        return true;
    }