Search code examples
syndesis

Getting 404 on existing Syndesis API endpoint for creating db snapshot


I'm getting back a 404 for an endpoint in the Syndesis API, namely /api/v1/test-support/snapshot-db, which allows you to create a snapshot of the db.

On Restlet, I added the proper _oauth_proxy cookie, and issued a GET to <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;
    }
}

I get the following response:

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

Solution

  • Notice the @ConditionalOnProperty(value = "endpoints.test_support.enabled"). This means that this endpoint might be turn off depending on a parameters set in the environment. If you have access to the server pod check the setting of this param and set it to 'true'. Try using:

    oc edit pod <server-podname>
    

    and look for

    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"
    

    and set it to "true". If it doesn't stick try editing the dc

    oc edit dc syndesis-server 
    

    Final note: if the Syndesis Operator is running in your install you may want to scale it down to zero or else it may undo your edits.

    Good luck! --Kurt