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

work in progress - remote run #3986

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
31 changes: 31 additions & 0 deletions paasta_tools/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import paasta_tools.api
from paasta_tools import kubernetes_tools
from paasta_tools.api import settings
from paasta_tools.api.tweens import auth
from paasta_tools.api.tweens import profiling
from paasta_tools.api.tweens import request_logger
from paasta_tools.utils import load_system_paasta_config
Expand Down Expand Up @@ -79,6 +80,18 @@ def parse_paasta_api_args():
default=4,
help="Number of gunicorn workers to run",
)
parser.add_argument(
"--auth-endpoint",
type=str,
default="",
help="External API authorization endpoint",
)
parser.add_argument(
"--auth-enforce",
action="store_true",
default=False,
help="Enforce API authorization",
)
args = parser.parse_args()
return args

Expand All @@ -105,6 +118,7 @@ def make_app(global_config=None):

config.include("pyramid_swagger")
config.include(request_logger)
config.include(auth)

config.add_route(
"flink.service.instance.jobs", "/v1/flink/{service}/{instance}/jobs"
Expand Down Expand Up @@ -148,6 +162,18 @@ def make_app(global_config=None):
"service.instance.tasks.task",
"/v1/services/{service}/{instance}/tasks/{task_id}",
)
config.add_route(
"remote_run.start",
"/v1/remote_run/{service}/{instance}/start",
)
config.add_route(
"remote_run.stop",
"/v1/remote_run/{service}/{instance}/stop",
)
config.add_route(
"remote_run.token",
"/v1/remote_run/{service}/{instance}/token",
)
config.add_route("service.list", "/v1/services/{service}")
config.add_route("services", "/v1/services")
config.add_route(
Expand Down Expand Up @@ -257,6 +283,11 @@ def main(argv=None):
if args.cluster:
os.environ["PAASTA_API_CLUSTER"] = args.cluster

if args.auth_endpoint:
os.environ["PAASTA_API_AUTH_ENDPOINT"] = args.auth_endpoint
if args.auth_enforce:
os.environ["PAASTA_API_AUTH_ENFORCE"] = "1"

gunicorn_args = [
"gunicorn",
"-w",
Expand Down
123 changes: 123 additions & 0 deletions paasta_tools/api/api_docs/oapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1627,6 +1627,129 @@ paths:
summary: Get mesos task of service_name.instance_name by task_id
tags:
- service
/remote_run/{service}/{instance}/start:
post:
operationId: remote_run_start
requestBody:
content:
application/json:
schema:
type: object
properties:
interactive:
type: boolean
user:
type: string
image:
type: string
required:
- interactive
- user
required: true
parameters:
- description: Service name
in: path
name: service
required: true
schema:
type: string
- description: Instance name
in: path
name: instance
required: true
schema:
type: string
responses:
"200":
content:
application/json:
schema:
type: string
description: The service is delayed for these possible reasons
"404":
description: Deployment key not found
"500":
description: Failure
summary: Launch a remote-run pod
tags:
- remote_run
/remote_run/{service}/{instance}/stop:
post:
operationId: remote_run_stop
requestBody:
content:
application/json:
schema:
type: object
properties:
user:
type: string
required:
- user
required: true
parameters:
- description: Service name
in: path
name: service
required: true
schema:
type: string
- description: Instance name
in: path
name: instance
required: true
schema:
type: string
responses:
"200":
content:
application/json:
schema:
type: string
description: Remote run pod stopped
"404":
description: Deployment key not found
"500":
description: Failure
summary: Stop a remote-run pod
tags:
- remote_run
/remote_run/{service}/{instance}/token:
get:
operationId: remote_run_token
parameters:
- description: Service name
in: path
name: service
required: true
schema:
type: string
- description: Instance name
in: path
name: instance
required: true
schema:
type: string
- description: User name
in: query
name: user
schema:
type: string
required: true
responses:
"200":
content:
application/json:
schema:
type: string
description: Token generated successfully
"404":
description: Deployment key not found
"500":
description: Failure
summary: Get a short lived token for exec into remote-run pod
tags:
- remote_run
/version:
get:
operationId: showVersion
Expand Down
165 changes: 165 additions & 0 deletions paasta_tools/api/api_docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,171 @@
}
]
}
},
"/remote_run/{service}/{instance}/start": {
"post": {
"responses": {
"200": {
"description": "It worked!",
"schema": {
"type": "string"
}
},
"404": {
"description": "Deployment key not found"
},
"500": {
"description": "Failure"
}
},
"summary": "Do a remote run",
"operationId": "remote_run_start",
"tags": [
"remote_run"
],
"parameters": [
{
"in": "path",
"description": "Service name",
"name": "service",
"required": true,
"type": "string"
},
{
"in": "path",
"description": "Instance name",
"name": "instance",
"required": true,
"type": "string"
},
{
"in": "body",
"description": "Username",
"name": "json_body",
"required": true,
"schema": {
"type": "object",
"properties": {
"interactive": {
"type": "boolean"
},
"user": {
"type": "string"
},
"image": {
"type": "string"
}
},
"required": [
"interactive",
"user"
]
}
}
]
}
},
"/remote_run/{service}/{instance}/stop": {
"post": {
"responses": {
"200": {
"description": "It worked!",
"schema": {
"type": "string"
}
},
"404": {
"description": "Deployment key not found"
},
"500": {
"description": "Failure"
}
},
"summary": "Stop a remote run",
"operationId": "remote_run_stop",
"tags": [
"service"
],
"parameters": [
{
"in": "path",
"description": "Service name",
"name": "service",
"required": true,
"type": "string"
},
{
"in": "path",
"description": "Instance name",
"name": "instance",
"required": true,
"type": "string"
},
{
"in": "body",
"description": "Username",
"name": "json_body",
"required": true,
"schema": {
"type": "object",
"properties": {
"user": {
"type": "string"
}
},
"required": [
"user"
]
}
}
]
}
},
"/remote_run/{service}/{instance}/token": {
"get": {
"responses": {
"200": {
"description": "It worked!",
"schema": {
"type": "string"
}
},
"404": {
"description": "Deployment key not found"
},
"500": {
"description": "Failure"
}
},
"summary": "Get a remote run token",
"operationId": "remote_run_token",
"tags": [
"remote_run"
],
"parameters": [
{
"in": "path",
"description": "Service name",
"name": "service",
"required": true,
"type": "string"
},
{
"in": "path",
"description": "Instance name",
"name": "instance",
"required": true,
"type": "string"
},
{
"in": "query",
"description": "Username",
"name": "user",
"required": true,
"type": "string"
}
]
}
}
},
"definitions": {
Expand Down
Loading
Loading