my_api_host = None
_cached_config = {}
+keep_existing = None
def find_server_pid(PID_PATH, wait=10):
now = time.time()
return port
def run_keep(blob_signing_key=None, enforce_permissions=False):
- if args.keep_existing is None:
+ if keep_existing is None:
stop_keep()
keep_args = {}
api.keep_disks().delete(uuid=d['uuid']).execute()
start_index = 0
- if args.keep_existing is not None:
+ if keep_existing is not None:
start_index = 2
for d in range(start_index, start_index+2):
port = _start_keep(d, keep_args)
parser.add_argument('--keep_existing', type=str, help="Used to add additional keep servers, without terminating existing servers")
args = parser.parse_args()
+ keep_existing = args.keep_existing
+
if args.action not in actions:
print("Unrecognized action '{}'. Actions are: {}.".format(args.action, actions), file=sys.stderr)
sys.exit(1)
// keep-rsync arguments
var (
- srcConfig map[string]string
- destConfig map[string]string
- srcKeepServicesJSON string
- destKeepServicesJSON string
- replications int
- prefix string
+ srcConfig map[string]string
+ dstConfig map[string]string
+ srcKeepServicesJSON string
+ dstKeepServicesJSON string
+ replications int
+ prefix string
)
func main() {
var srcConfigFile string
- var destConfigFile string
+ var dstConfigFile string
flag.StringVar(
&srcConfigFile,
"ARVADOS_API_HOST, ARVADOS_API_HOST_INSECURE, and ARVADOS_BLOB_SIGNING_KEY.")
flag.StringVar(
- &destConfigFile,
- "dest-config-file",
+ &dstConfigFile,
+ "dst-config-file",
"",
"Destination configuration filename with full path that contains "+
"an ARVADOS_API_TOKEN which is a valid datamanager token recognized by the destination keep servers, "+
"If not provided, this list is obtained from api server configured in src-config-file.")
flag.StringVar(
- &destKeepServicesJSON,
- "dest-keep-services-json",
+ &dstKeepServicesJSON,
+ "dst-keep-services-json",
"",
"An optional list of available destination keepservices. "+
- "If not provided, this list is obtained from api server configured in dest-config-file.")
+ "If not provided, this list is obtained from api server configured in dst-config-file.")
flag.IntVar(
&replications,
log.Fatal("Error reading source configuration: %s", err.Error())
}
- if destConfigFile == "" {
- log.Fatal("-dest-config-file must be specified.")
+ if dstConfigFile == "" {
+ log.Fatal("-dst-config-file must be specified.")
}
- destConfig, err = readConfigFromFile(destConfigFile)
+ dstConfig, err = readConfigFromFile(dstConfigFile)
if err != nil {
log.Fatal("Error reading destination configuration: %s", err.Error())
}
// keep-rsync source and destination clients
var (
- arvSrc arvadosclient.ArvadosClient
- arvDest arvadosclient.ArvadosClient
- kcSrc *keepclient.KeepClient
- kcDest *keepclient.KeepClient
+ arvSrc arvadosclient.ArvadosClient
+ arvDst arvadosclient.ArvadosClient
+ kcSrc *keepclient.KeepClient
+ kcDst *keepclient.KeepClient
)
// Initializes keep-rsync using the config provided
return
}
- arvDest, err = arvadosclient.MakeArvadosClientWithConfig(destConfig)
+ arvDst, err = arvadosclient.MakeArvadosClientWithConfig(dstConfig)
if err != nil {
return
}
return
}
- kcDest, err = keepclient.MakeKeepClient(&arvDest)
+ kcDst, err = keepclient.MakeKeepClient(&arvDst)
return
}
arvadostest.StopAPI()
}
-// Testing keep-rsync needs two sets of keep services: src and dest.
+// Testing keep-rsync needs two sets of keep services: src and dst.
// The test setup hence tweaks keep-rsync initialzation to achieve this.
// First invoke initializeKeepRsync and then invoke StartKeepAdditional
// to create the keep servers to be used as destination.
srcConfig["ARVADOS_API_TOKEN"] = os.Getenv("ARVADOS_API_TOKEN")
srcConfig["ARVADOS_API_HOST_INSECURE"] = os.Getenv("ARVADOS_API_HOST_INSECURE")
- // destConfig
- destConfig = make(map[string]string)
- destConfig["ARVADOS_API_HOST"] = os.Getenv("ARVADOS_API_HOST")
- destConfig["ARVADOS_API_TOKEN"] = os.Getenv("ARVADOS_API_TOKEN")
- destConfig["ARVADOS_API_HOST_INSECURE"] = os.Getenv("ARVADOS_API_HOST_INSECURE")
+ // dstConfig
+ dstConfig = make(map[string]string)
+ dstConfig["ARVADOS_API_HOST"] = os.Getenv("ARVADOS_API_HOST")
+ dstConfig["ARVADOS_API_TOKEN"] = os.Getenv("ARVADOS_API_TOKEN")
+ dstConfig["ARVADOS_API_HOST_INSECURE"] = os.Getenv("ARVADOS_API_HOST_INSECURE")
arvadostest.StartAPI()
arvadostest.StartKeep()
// Create two more keep servers to be used as destination
arvadostest.StartKeepAdditional(true)
- // load kcDest
- kcDest, err = keepclient.MakeKeepClient(&arvDest)
+ // load kcDst
+ kcDst, err = keepclient.MakeKeepClient(&arvDst)
c.Assert(err, Equals, nil)
}
c.Assert(config["EXTERNAL_CLIENT"], Equals, "")
}
-// Test keep-rsync initialization, with src and dest keep servers.
+// Test keep-rsync initialization, with src and dst keep servers.
// Do a Put and Get in src, both of which should succeed.
-// Do a Get in dest for the same hash, which should raise block not found error.
-func (s *ServerRequiredSuite) TestRsyncPutInSrc_GetFromDestShouldFail(c *C) {
+// Do a Get in dst for the same hash, which should raise block not found error.
+func (s *ServerRequiredSuite) TestRsyncPutInSrc_GetFromDstShouldFail(c *C) {
setupRsync(c)
// Put a block in src using kcSrc and Get it
all, err := ioutil.ReadAll(reader)
c.Check(all, DeepEquals, data)
- // Get using kcDest should fail with NotFound error
- _, _, _, err = kcDest.Get(hash)
+ // Get using kcDst should fail with NotFound error
+ _, _, _, err = kcDst.Get(hash)
c.Assert(err.Error(), Equals, "Block not found")
}