Пример #1
0
// RemoveBrickPaths is to clean up the bricks in case commit fails for volume
// create
func RemoveBrickPaths(bricks []Brickinfo) error {
	var e error
	for _, brick := range bricks {
		local, err := utils.IsLocalAddress(brick.Hostname)
		if err != nil || local == false {
			continue
		}
		err = os.Remove(brick.Path)
		if err != nil {
			e := err
			log.WithFields(log.Fields{"error": e.Error(),
				"brickPath": brick.Path,
				"host":      brick.Hostname}).Error("Failed to remove directory")
		}
	}
	return e
}
Пример #2
0
// ValidateBrickEntries validates the brick list
func ValidateBrickEntries(bricks []brick.Brickinfo, volID uuid.UUID, force bool) (int, error) {

	for _, b := range bricks {
		if !uuid.Equal(b.ID, gdctx.MyUUID) {
			continue
		}

		local, err := utils.IsLocalAddress(b.Hostname)
		if err != nil {
			log.WithField("Host", b.Hostname).Error(err.Error())
			return http.StatusInternalServerError, err
		}
		if local == false {
			log.WithField("Host", b.Hostname).Error("Host is not local")
			return http.StatusBadRequest, errors.ErrBrickNotLocal
		}
		err = utils.ValidateBrickPathLength(b.Path)
		if err != nil {
			return http.StatusBadRequest, err
		}
		err = utils.ValidateBrickSubDirLength(b.Path)
		if err != nil {
			return http.StatusBadRequest, err
		}
		err = isBrickPathAvailable(b.Hostname, b.Path)
		if err != nil {
			return http.StatusBadRequest, err
		}
		err = validateBrickPathStatsFunc(b.Path, b.Hostname, force)
		if err != nil {
			return http.StatusBadRequest, err
		}
		err = utils.ValidateXattrSupport(b.Path, b.Hostname, volID, force)
		if err != nil {
			return http.StatusBadRequest, err
		}
	}
	return 0, nil
}
Пример #3
0
// ValidateBrickEntries validates the brick list
func ValidateBrickEntries(bricks []Brickinfo, volID uuid.UUID, force bool) (int, error) {

	for _, brick := range bricks {
		//TODO : Check for peer hosts first, otherwise look for local
		//address
		local, err := utils.IsLocalAddress(brick.Hostname)
		if err != nil {
			log.WithField("Host", brick.Hostname).Error(err.Error())
			return http.StatusInternalServerError, err
		}
		if local == false {
			log.WithField("Host", brick.Hostname).Error("Host is not local")
			return http.StatusBadRequest, errors.ErrBrickNotLocal
		}
		err = utils.ValidateBrickPathLength(brick.Path)
		if err != nil {
			return http.StatusBadRequest, err
		}
		err = utils.ValidateBrickSubDirLength(brick.Path)
		if err != nil {
			return http.StatusBadRequest, err
		}
		err = isBrickPathAvailable(brick.Hostname, brick.Path)
		if err != nil {
			return http.StatusBadRequest, err
		}
		err = validateBrickPathStatsFunc(brick.Path, brick.Hostname, force)
		if err != nil {
			return http.StatusBadRequest, err
		}
		err = utils.ValidateXattrSupport(brick.Path, brick.Hostname, volID, force)
		if err != nil {
			return http.StatusBadRequest, err
		}
	}
	return 0, nil
}