func (s RunnerService) Finish(ctx context.Context, r api.RunnerFinishRequest) (*api.RunnerFinishResponse, error) {
	logger := s.logger.With(zap.String("runner", r.Runner), zap.Int("runner_id", int(r.ID)))
	logger.Info("FINISHED RUNNER")

	var runner api.Runner
	if err := s.DB.First(&runner, r.ID).Error; err != nil {
		logger.Error("Cannot get runner", zap.String("exception", err.Error()))
		return nil, fmt.Errorf("cannot get runner: %v", err)
	}
	runner.Status = avian.StatusFinished
	runner.Active = false
	if err := s.DB.Save(&runner).Error; err != nil {
		logger.Error("Cannot save the failed runner", zap.String("exception", err.Error()))
		return nil, fmt.Errorf("cannot save runner: %v", err)
	}

	// Set servers activity
	if err := s.SetServerActivity(runner, false); err != nil {
		return nil, fmt.Errorf("Failed to set servers activity: %v", err)
	}

	// update nms information
	if err := s.ResetNms(runner); err != nil {
		return nil, fmt.Errorf("Failed to set servers activity: %v", err)
	}

	if err := s.RemoveScript(runner); err != nil {
		return nil, err
	}

	return &api.RunnerFinishResponse{}, nil
}
// Finish sets the specified runner to finished (used by ruby script)
Finish sets the specified runner to finished (used by ruby script)
// Finish sets the specified runner to finished ( used by ruby script )
func (s RunnerService) Finish(ctx context.Context, r api.RunnerFinishRequest) (*api.RunnerFinishResponse, error) {
	logger := s.logger.With(zap.String("runner", r.Runner), zap.Int("runner_id", int(r.ID)))
	logger.Info("FINISHED RUNNER")
	var runner api.Runner
	if err := s.DB.First(&runner, r.ID).Error; err != nil {
		logger.Error("Cannot get runner", zap.String("exception", err.Error()))
		return nil, fmt.Errorf("cannot get runner: %v", err)
	}
	runner.Status = avian.StatusFinished
	runner.Active = false
	if err := s.DB.Save(&runner).Error; err != nil {
		logger.Error("Cannot save the failed runner", zap.String("exception", err.Error()))
		return nil, fmt.Errorf("cannot save runner: %v", err)
	}
	if err := s.SetServerActivity(runner, false); err != nil {
		return nil, fmt.Errorf("Failed to set servers activity: %v", err)
	}
	if err := s.ResetNms(runner); err != nil {
		return nil, fmt.Errorf("Failed to set servers activity: %v", err)
	}
	if err := s.RemoveScript(runner); err != nil {
		return nil, err
	}
	return &api.RunnerFinishResponse{}, nil
}
func ( s RunnerService ) Finish ( ctx context . Context , r api . RunnerFinishRequest ) ( * api . RunnerFinishResponse , error ) { logger := s . logger . With ( zap . String ( " " , r . Runner ) , zap . Int ( " " , int ( r . ID ) ) ) logger . Info ( " " ) var runner api . Runner if err := s . DB . First ( & runner , r . ID ) . Error ; err != nil { logger . Error ( " " , zap . String ( " " , err . Error ( ) ) ) return nil , fmt . Errorf ( " " , err ) } runner . Status = avian . StatusFinished runner . Active = false if err := s . DB . Save ( & runner ) . Error ; err != nil { logger . Error ( " " , zap . String ( " " , err . Error ( ) ) ) return nil , fmt . Errorf ( " " , err ) } if err := s . SetServerActivity ( runner , false ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } if err := s . ResetNms ( runner ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } if err := s . RemoveScript ( runner ) ; err != nil { return nil , err } return & api . RunnerFinishResponse { } , nil }
Finish sets the specified runner to finished (used by ruby script)
Finish sets the specified runner to finished ( used by ruby script )
// Set servers activity // update nms information