Exemple #1
0
func updateNodeFolder(ttl int) error {
	opt := discovery.Options{
		"TTL":       time.Second * time.Duration(ttl),
		"Dir":       true,
		"PrevExist": true,
	}
	remote := cfg.GetNodeConfig().Remote
	err := discovery.Set(remote, "", opt)
	cfg.WriteNodeConfig(remote, cfg.GetNode().Configuration)
	cfg.WriteNodeConstraints(remote, cfg.GetNode().Constraints)
	cfg.WriteNodeResources(remote, cfg.GetNode().Resources)
	cfg.WriteNodeActive(remote, cfg.GetNode().Active)
	if err != nil {
		log.WithField("err", err).Errorln("Error updating node folder")
		return err
	}

	return nil
}
Exemple #2
0
func createNodeFolder() error {
	var err error
	opt := discovery.Options{
		"TTL": time.Second * time.Duration(c_TTL+1),
		"Dir": true,
	}

	config := cfg.GetNodeConfig()
	config.Cluster = myCluster.Name
	remote := c_GRU_REMOTE + myCluster.Name + "/" + c_NODES_REMOTE + config.Name
	config.Remote = remote

	err = discovery.Set(remote, "", opt)
	cfg.WriteNodeConfig(remote, cfg.GetNode().Configuration)
	cfg.WriteNodeConstraints(remote, cfg.GetNode().Constraints)
	cfg.WriteNodeResources(remote, cfg.GetNode().Resources)
	cfg.WriteNodeActive(remote, cfg.GetNode().Active)
	if err != nil {
		log.WithField("err", err).Errorln("Error creating node folder")
		return err
	}

	return nil
}