Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] CCCP API server #656

Closed
wants to merge 20 commits into from
Closed

[WIP] CCCP API server #656

wants to merge 20 commits into from

Conversation

navidshaikh
Copy link
Collaborator

@navidshaikh navidshaikh commented Oct 15, 2018

This changeset adds flask implementation of CCP readonly APIs.

The API server skeleton is generated by swagger https://swagger.io/
OpenAPI implementation framework using swagger YAML API specifications.

Added Dockerfile for API server at Dockerfiles/ccp-api-server/Dockerfile,
which will containerize the API server and start it.

@navidshaikh navidshaikh changed the title CCCP API server [WIP] CCCP API server Oct 15, 2018
@mohammedzee1000
Copy link
Collaborator

Looks really cool. We just update the appropriate controllers :)

# from ccp.apis.server.ccp_server.models.all_scanner_logs import AllScannerLogs
# from ccp.apis.server.ccp_server.models.app_id_job_id_tag import AppIdJobIdTag
# from ccp.apis.server.ccp_server.models.app_id_job_id_tags import AppIdJobIdTags
# from ccp.apis.server.ccp_server.models.build_logs import BuildLogs
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are all these imports commented ?
@mohammedzee1000

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They were causing error, once i updated the references. The errors failed once i removed these imports and the server works fine.

Need to still figure out what happened there

ProjectMetadata # noqa: E501
from ccp.apis.server.ccp_server.models.target_file import\
TargetFile # noqa: E501
from ccp.apis.server.ccp_server.test import BaseTestCase

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for this change.

@@ -17,10 +17,14 @@ ENV PYTHONPATH="/opt/ccp_api_server"

COPY . /opt/ccp_api_server

RUN useradd 1001 && usermod -aG 0 1001 && chown 1001:0 /opt/ccp_api_server && chmod -R g+x /opt/ccp_api_server
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chown -R 1001:0 /opt/ccp_api_server

We need to change the permissions to root and all subsequent dirs recursively in that repo, WDYT ?
@mohammedzee1000

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be a problem, but to be safe, yea, i guess it makes sense

@@ -17,10 +17,14 @@ ENV PYTHONPATH="/opt/ccp_api_server"

COPY . /opt/ccp_api_server
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am thinking, now that /opt/ccp_api_server hosts the complete service code, we should name it as our service repo name or ccp-openshift as we did in slave container.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It did right from the start

Copy link
Collaborator

@dharmit dharmit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review is only for the swagger.yaml file.

  • Do we really need to put server code into ccp/apis/v1/server/ccp_server. Is ccp/apis/v1/server not enough? I can't think of another server being written for these APIs.
  • Ending this review early because of the api endpoints of the format /namespace/{namespace}/app-id/{app_id}/job-id/{job_id}/desired-tag/{desired_tag}. I think we had discussed to go with something like r.c.o/api/v1/{app_id}/{job_id}/{desired_tag}. Not sure why we're having namespace here and why we're making the URLs longer by doing /app-id/{app_id}/job-id/{job_id}/desired-tag/{desired_tag}

basePath: "/api/v1/"
tags:
- name: "infra"
description: "APIs serving infra related information as liveness, help."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/infra/infrastructure

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are liveness and help two examples of the kind of information being served? Below sounds more appropriate in that case:

'APIs serving infrastructure related information such as liveness, help.'

- name: "infra"
description: "APIs serving infra related information as liveness, help."
- name: "meta"
description: "APIs serving meta information for projects, namespaces, etc."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/meta/metadata

schema:
$ref: "#/definitions/Namespaces"
x-swagger-router-controller: "ccp_server.controllers.meta_controller"
/namespace/{namespace}/projects:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By namespace, do we mean an OpenShift namespace? At the moment, we have only one OpenShift namespace. So how does having this API endpoint help?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do we want to have /namespaces and /namespace/{namespace}/projects separate? There's a missing s in namespace in the latter. Or do we mean these two endpoints:

  • /namespaces
  • /namespaces/{namespace}/projects

ccp/apis/v1/server/ccp_server/swagger/swagger.yaml Outdated Show resolved Hide resolved
Copy link
Collaborator

@dharmit dharmit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once again, only reviewing the swagger.yaml file because, IIUC, that's the base for rest of the 3,500+ lines of code in this PR.

  • Can we please use fewer abbreviations like info, meta, etc. for documentation (I can't find a better word for the yaml specification) and use the full words instead?
  • Do we really need /namespace/{namespace]/? We are having only one namespace in OpenShift at the moment. Yes, we discussed having separate namespaces for projects and their weekly scan builds but that's not in place at the moment. Is it a good idea to have provision for something in the API that's not yet implemented?
  • Without deciding if we want to fetch details for all builds/weekly-scan build or only for the latest success/failure, we're going to add more logic to the backend or API (wherever we decide to process things.) Is this really required? We could modify the API endpoints and resulting backend functions to just fetch the latest success and failure results, no?

ccp/apis/v1/server/ccp_server/swagger/swagger.yaml Outdated Show resolved Hide resolved
get:
tags:
- "builds"
summary: "Get all the builds info for given project"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Get information for all builds of the given project" sounds more appropriate.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember we discussed having only the latest failure and success builds. Does this API endpoint assume otherwise? I think that goes into the def project_builds() function but just raising it so that it's discussed.

tags:
- "builds"
summary: "Get all the builds info for given project"
description: "Get all the builds number, name and status for given project"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Get build number, name and status of all builds for the given project" sounds appropriate.

ccp/apis/v1/ccp_server/swagger/swagger.yaml Outdated Show resolved Hide resolved
ccp/apis/v1/ccp_server/swagger/swagger.yaml Outdated Show resolved Hide resolved
ccp/apis/v1/ccp_server/swagger/swagger.yaml Show resolved Hide resolved
ccp/apis/v1/ccp_server/swagger/swagger.yaml Outdated Show resolved Hide resolved
ccp/apis/v1/ccp_server/swagger/swagger.yaml Show resolved Hide resolved
ccp/apis/v1/ccp_server/swagger/swagger.yaml Show resolved Hide resolved
ccp/apis/v1/ccp_server/swagger/swagger.yaml Outdated Show resolved Hide resolved
navidshaikh and others added 6 commits November 21, 2018 13:37
 This changeset adds flask implementation of CCP readonly APIs.

 The API server skeleton is generated by swagger <https://swagger.io/>
 OpenAPI implementation framework using swagger YAML API specifications.

 Added Dockerfile for API server at Dockerfiles/ccp-api-server/Dockerfile,
 which will containerize the API server and start it.
 This commit adds backend module structure for wiring up the
 responses for each API response to respective python module file
 in logical API group (infra, meta, projects, builds).

 All of the logical API group are further grouped as per API versioning, i.e. v1 here.
@mohammedzee1000 mohammedzee1000 mentioned this pull request Dec 18, 2018
@bamachrn
Copy link
Collaborator

bamachrn commented Jan 9, 2019

merged this in #668

@bamachrn bamachrn closed this Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants