在用于创建数据库快照的现有 Syndesis API 端点上获取 404

Getting 404 on existing Syndesis API endpoint for creating db snapshot

我正在为 Syndesis API 中的端点取回 404,即 /api/v1/test-support/snapshot-db,它允许您创建数据库的快照。

在 Restlet 上,我添加了正确的 _oauth_proxy cookie,并向 <host>/api/v1/test-support/snapshot-db 发出了一个 GET


@Path("/test-support")
@org.springframework.stereotype.Component
@ConditionalOnProperty(value = "endpoints.test_support.enabled")
public class TestSupportHandler {

    private static final Logger LOG = LoggerFactory.getLogger(TestSupportHandler.class);

    private final DataManager dataMgr;
    private final List<DataAccessObject<?>> daos;
    private final OpenShiftService openShiftService;

    @Context
    private HttpServletRequest context;

    private final DBI dbi;

    private CacheManager cacheManager;

    private Collection<BackendController> controllers;

    public TestSupportHandler(DBI dbi, DataManager dataMgr, CacheManager cacheManager, List<DataAccessObject<?>> daos, OpenShiftService openShiftService, Collection<BackendController> controllers) {
        this.dbi = dbi;
        this.dataMgr = dataMgr;
        this.cacheManager = cacheManager;
        this.controllers = controllers;
        this.daos = daos.stream().filter(x -> !x.isReadOnly()).collect(Collectors.toList());
        this.openShiftService = openShiftService;
    }

@GET
    @Path("/snapshot-db")
    @Produces(MediaType.APPLICATION_JSON)
    public List<ModelData<?>> snapshotDB() {
        LOG.info("user {} is making snapshot", context.getRemoteUser());
        ArrayList<ModelData<?>> result = new ArrayList<>();
        for (DataAccessObject<?> dao : daos) {
            ListResult<? extends WithId<?>> l = dao.fetchAll();
            for (WithId<?> entity : l.getItems()) {
                @SuppressWarnings({"unchecked", "rawtypes"})
                ModelData<?> modelData = new ModelData(entity.getKind(), entity);
                result.add(modelData);
            }
        }
        return result;
    }
}

我收到以下回复:

{
"errorCode": 404,
"userMsg": "Given request is not acceptable",
"developerMsg": "RESTEASY003210: Could not find resource for full path: <host>/api/v1/test-support/snapshot-db"
}

注意 @ConditionalOnProperty(value = "endpoints.test_support.enabled")。这意味着此端点可能会根据环境中设置的参数而关闭。如果您有权访问服务器 pod,请检查此参数的设置并将其设置为 'true'。尝试使用:

oc edit pod <server-podname>

并寻找

spec:
  containers:
  - env:
    - name: JAVA_APP_DIR
      value: /deployments
    - name: JAVA_OPTIONS
      value: -Djava.net.preferIPv4Stack=true -Duser.home=/tmp
    - name: NAMESPACE
      valueFrom:
        fieldRef:
          apiVersion: v1
          fieldPath: metadata.namespace
    - name: ENDPOINTS_TEST_SUPPORT_ENABLED
      value: "false"

并将其设置为 "true"。如果它不粘,请尝试编辑 dc

oc edit dc syndesis-server 

最后说明:如果 Syndesis Operator 在您的安装中 运行,您可能希望将其缩小到零,否则它可能会撤消您的编辑。

祝你好运! --库尔特