0

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

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


@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"
}
4

1 回答 1

0

注意@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"

并将其设置为“真”。如果它不坚持尝试编辑直流

oc edit dc syndesis-server 

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

祝你好运!——库尔特

于 2019-09-10T10:54:15.240 回答