diff options
Diffstat (limited to 'node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/TaskContext.java')
-rw-r--r-- | node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/TaskContext.java | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/TaskContext.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/TaskContext.java index cee2dc9b66b..2d94db3d96e 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/TaskContext.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/component/TaskContext.java @@ -1,26 +1,29 @@ // Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.node.admin.component; -import java.nio.file.FileSystem; -import java.util.EnumSet; import java.util.logging.Logger; public interface TaskContext { - enum Cloud { YAHOO, AWS } - Cloud cloud(); + /** + * Record a system modification. IdempotentTask is supposed to converge the system (files, + * directory permission, iptable rules, etc) to some wanted state. It is especially important + * to produce a truthful log of system changes to understand what may or may not be going on. + * + * All tasks should: + * 1. Record any and all modifications to the system + * 2. Avoid recording system interactions that does not actually change the system. + * 3. Record system modifications as early as possible and preferably before they are + * performed (sometimes this is not possible). + * + * @param logger Used to log the modification to help locate the source of the modification. + * @param description Description of the modification, e.g. "Changing owner of /foo from alice + * to bob". + */ + void recordSystemModification(Logger logger, String description); - enum Role { TENANT_DOCKER_HOST, CONFIG_SERVER_DOCKER_HOST } - EnumSet<Role> roles(); - default boolean hasRole(Role role) { - return roles().contains(role); - } - - FileSystem fileSystem(); - - void logSystemModification(Logger logger, String actionDescription); - default void logSystemModification(Logger logger, String format, String... args) { - logSystemModification(logger, String.format(format, (Object[]) args)); - } - - default boolean executeSubtask(IdempotentTask task) { return false; } + /** + * Execute a task as a child of this task, and with its own sub-TaskContext. Please avoid + * excessive task hierarchies. + */ + boolean executeSubtask(IdempotentTask task); } |