MCPcopy Create free account
hub / github.com/apache/mesos / validateHealthCheck

Function validateHealthCheck

src/common/validation.cpp:335–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333
334
335Option<Error> validateHealthCheck(const HealthCheck& healthCheck)
336{
337 if (!healthCheck.has_type()) {
338 return Error("HealthCheck must specify 'type'");
339 }
340
341 switch (healthCheck.type()) {
342 case HealthCheck::COMMAND: {
343 if (!healthCheck.has_command()) {
344 return Error("Expecting 'command' to be set for COMMAND health check");
345 }
346
347 const CommandInfo& command = healthCheck.command();
348
349 if (!command.has_value()) {
350 string commandType =
351 (command.shell() ? "'shell command'" : "'executable path'");
352
353 return Error("Command health check must contain " + commandType);
354 }
355
356 Option<Error> error =
357 common::validation::validateCommandInfo(command);
358 if (error.isSome()) {
359 return Error(
360 "Health check's `CommandInfo` is invalid: " + error->message);
361 }
362
363 // TODO(alexr): Make sure irrelevant fields, e.g., `uris` are not set.
364
365 break;
366 }
367 case HealthCheck::HTTP: {
368 if (!healthCheck.has_http()) {
369 return Error("Expecting 'http' to be set for HTTP health check");
370 }
371
372 const HealthCheck::HTTPCheckInfo& http = healthCheck.http();
373
374 if (http.has_scheme() &&
375 http.scheme() != "http" &&
376 http.scheme() != "https") {
377 return Error(
378 "Unsupported HTTP health check scheme: '" + http.scheme() + "'");
379 }
380
381 if (http.has_path() && !strings::startsWith(http.path(), '/')) {
382 return Error(
383 "The path '" + http.path() +
384 "' of HTTP health check must start with '/'");
385 }
386
387 break;
388 }
389 case HealthCheck::TCP: {
390 if (!healthCheck.has_tcp()) {
391 return Error("Expecting 'tcp' to be set for TCP health check");
392 }

Callers 2

createMethod · 0.50
TEST_FFunction · 0.50

Calls 9

startsWithFunction · 0.85
NoneClass · 0.85
typeMethod · 0.80
commandMethod · 0.80
validateCommandInfoFunction · 0.70
ErrorFunction · 0.50
isSomeMethod · 0.45
schemeMethod · 0.45
pathMethod · 0.45

Tested by 1

TEST_FFunction · 0.40