Skip to content

Commit f836aca

Browse files
authored
Merge branch 'master' into add_persistence
2 parents 3789e42 + 2dab1b9 commit f836aca

File tree

24 files changed

+50
-1003
lines changed

24 files changed

+50
-1003
lines changed

README.md

-5
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,3 @@ Endpoints are avaliable on [restapi-endpoints.md](docs/restapi-endpoints.md) doc
5858

5959
## Avaliable plugins
6060
* [Kube Jobs](docs/plugins/kubejobs.md)
61-
* [Spark Sahara](docs/plugins/spark_sahara.md)
62-
* [Spark Mesos](docs/plugins/spark_mesos.md)
63-
* [Openstack Generic](docs/plugins/openstack_generic.md)
64-
* [Web Application](docs/plugins/web_app.md)
65-
* [External API](docs/plugins/external-api.md)

docs/plugins/external-api.md

-76
This file was deleted.

docs/plugins/openstack_generic.md

-16
This file was deleted.

docs/plugins/spark_mesos.md

-15
This file was deleted.

docs/plugins/spark_sahara.md

-15
This file was deleted.

docs/plugins/web_app.md

-16
This file was deleted.

monitor/api/v10.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ def stop_monitoring(app_id, data):
4545
def install_plugin(data):
4646
plugin = data.get('plugin_source')
4747
source = data.get('install_source')
48-
response, status = api.install_plugin(plugin, source)
48+
response, status = api.install_plugin(source, plugin)
4949
return jsonify(response), status

monitor/cli/main.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
from flask import Flask
1717
from monitor.api.v10 import rest
1818
from monitor.service import api
19-
from monitor.utils.logger import configure_logging
19+
from monitor.utils import logger
2020

2121
def main():
2222
app = Flask(__name__)
23-
configure_logging()
2423
app.register_blueprint(rest)
24+
logger.configure_logging()
2525
app.run(host='0.0.0.0', port=api.port, debug=True)

monitor/exceptions.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
import uuid
1919

2020

21-
class SaharaException(Exception):
22-
"""Base Exception for the Sahara Plugin
21+
class GenericException(Exception):
22+
"""Base Exception for the Generic Plugin
2323
2424
To correctly use this class, inherit from it and define
2525
a 'message' and 'code' properties.
@@ -43,11 +43,11 @@ def __init__(self, message=None, code=None, inject_error_id=True):
4343
self.message = (('%(message)s\nError ID: %(id)s')
4444
% {'message': self.message, 'id': self.uuid})
4545

46-
super(SaharaException, self).__init__(
46+
super(GenericException, self).__init__(
4747
'%s: %s' % (self.code, self.message))
4848

4949

50-
class NotFoundException(SaharaException):
50+
class NotFoundException(GenericException):
5151
code = "NOT_FOUND"
5252
message_template = "Object '%s' is not found"
5353

@@ -62,7 +62,7 @@ def __init__(self, value, message_template=None):
6262
super(NotFoundException, self).__init__(formatted_message)
6363

6464

65-
class RemoteCommandException(SaharaException):
65+
class RemoteCommandException(GenericException):
6666
code = "REMOTE_COMMAND_FAILED"
6767
message_template = "Error during command execution: \"%s\""
6868

@@ -93,7 +93,7 @@ def to_printable(s):
9393
super(RemoteCommandException, self).__init__(formatted_message)
9494

9595

96-
class TimeoutException(SaharaException):
96+
class TimeoutException(GenericException):
9797
code = "TIMEOUT"
9898
message_template = ("'%(operation)s' timed out after %(timeout)i "
9999
"second(s)")
@@ -115,7 +115,7 @@ def __init__(self, timeout, op_name=None, timeout_name=None):
115115
super(TimeoutException, self).__init__(formatted_message)
116116

117117

118-
class Forbidden(SaharaException):
118+
class Forbidden(GenericException):
119119
code = "FORBIDDEN"
120120
message = ("You are not authorized to complete this action")
121121

@@ -133,7 +133,7 @@ def __init__(self, message="Malformed message body"):
133133
self.message = message
134134

135135

136-
class MalformedRequestBody(SaharaException):
136+
class MalformedRequestBody(GenericException):
137137
code = "MALFORMED_REQUEST_BODY"
138138
message_template = ("Malformed message body: %(reason)s")
139139

@@ -142,7 +142,7 @@ def __init__(self, reason):
142142
super(MalformedRequestBody, self).__init__(formatted_message)
143143

144144

145-
class MaxRetriesExceeded(SaharaException):
145+
class MaxRetriesExceeded(GenericException):
146146
code = "MAX_RETRIES_EXCEEDED"
147147
message_template = ("Operation %(operation)s wasn't executed correctly "
148148
"after %(attempts)d attempts")
@@ -154,11 +154,11 @@ def __init__(self, attempts, operation):
154154
super(MaxRetriesExceeded, self).__init__(formatted_message)
155155

156156

157-
class ClusterNotCreatedException(SaharaException):
157+
class ClusterNotCreatedException(GenericException):
158158
code = "CLUSTER_NOT_CREATED"
159159
message = "Cluster could not be created"
160160

161161

162-
class ConfigurationError(SaharaException):
162+
class ConfigurationError(GenericException):
163163
code = "CONFIGURATION_ERROR"
164164
message = "The configuration has failed"

monitor/plugins/spark_mesos/__init__.py monitor/plugins/builder.py

+21
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,24 @@
1212
# implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15+
16+
from monitor import exceptions as ex
17+
from monitor.service import api
18+
from monitor.plugins.kubejobs.plugin import KubeJobProgress
19+
20+
21+
class MonitorBuilder:
22+
def __init__(self):
23+
pass
24+
25+
def get_monitor(self, plugin, app_id, plugin_info):
26+
executor = None
27+
28+
if plugin == "kubejobs":
29+
executor = KubeJobProgress(
30+
app_id, plugin_info, retries=api.retries)
31+
32+
else:
33+
raise ex.BadRequestException()
34+
35+
return executor

monitor/plugins/kubejobs/plugin.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ def monitoring_application(self):
163163

164164
def validate(self, data):
165165
data_model = {
166-
"datasource_type": six.string_types,
167166
"enable_visualizer": bool,
168167
"expected_time": int,
169168
"number_of_jobs": int,
@@ -172,6 +171,9 @@ def validate(self, data):
172171
"submission_time": six.string_types
173172
}
174173

174+
if 'enable_visualizer' in data and data['enable_visualizer']:
175+
data_model.update({"datasource_type": six.string_types})
176+
175177
for key in data_model:
176178
if (key not in data):
177179
raise ex.BadRequestException(

0 commit comments

Comments
 (0)