예제 #1
0
// checkSizeOfRemoteFolder asks remote machine for size of specified remote folder
// and returns warning if size if greater than 100MB.
//
// Note we return a warning since you can technically mount any size you want,
// however the performance will degrade.
func checkSizeOfRemoteFolder(remoteMachine *machine.Machine, remotePath string) (interface{}, error) {
	sizeInB, err := remoteMachine.GetFolderSize(remotePath)
	if err != nil {
		return nil, err
	}

	sizeInMB := sizeInB / (1024 * 1000)

	if sizeInMB > recommendedRemoteFolderSize {
		return fmt.Sprintf(
			"Specified remote folder size is '%dMB', recommended is '%dMB' or less.",
			sizeInMB, recommendedRemoteFolderSize,
		), nil
	}

	return nil, nil
}
예제 #2
0
파일: remote.go 프로젝트: koding/koding
// updateValidMachineFromKite takes an existing valid machine and updates it
// with any simple meta that might have changed. Ie, if you change a
// machines label on Koding, this method updates the Machine's label field.
func (r *Remote) updateValidMachineFromKite(c *KodingClient, validMachine *machine.Machine, log logging.Logger) (bool, error) {
	var metaChanged bool

	if validMachine.MachineLabel != c.MachineLabel {
		validMachine.MachineLabel = c.MachineLabel
		metaChanged = true
	}

	return metaChanged, nil
}
예제 #3
0
파일: cache.go 프로젝트: koding/koding
// startIntervalerIfNeeded starts the given rsync interval, logs any errors, and adds the
// resulting Intervaler to the Mount struct for later Stoppage.
func startIntervalerIfNeeded(log logging.Logger, remoteMachine *machine.Machine, c *rsync.Client, opts rsync.SyncIntervalOpts) {
	log = log.New("startIntervalerIfNeeded")

	if opts.Interval <= 0 {
		// Using debug, because this is not an error - just informative.
		log.Debug(
			"startIntervalerIfNeeded() called with interval:%d. Cannot start Intervaler",
			opts.Interval,
		)
		return
	}

	log.Info("Creating and starting RSync SyncInterval")
	intervaler, err := c.SyncInterval(opts)
	if err != nil {
		log.Error("rsync SyncInterval returned an error:%s", err)
		return
	}

	remoteMachine.Intervaler = intervaler
}