// Failed sets the specified runner to failed (used by ruby script)
Failed sets the specified runner to failed (used by ruby script)
// Failed sets the specified runner to failed ( used by ruby script )
func (s RunnerService) Failed(ctx context.Context, r api.RunnerFailedRequest) (*api.RunnerFailedResponse, error) {
	logger := s.logger.With(zap.String("runner", r.Runner), zap.Int("runner_id", int(r.ID)))
	logger.Info("FAILED 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.StatusFailed
	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.RunnerFailedResponse{}, nil
}
func ( s RunnerService ) Failed ( ctx context . Context , r api . RunnerFailedRequest ) ( * api . RunnerFailedResponse , 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 . StatusFailed 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 . RunnerFailedResponse { } , nil }
Failed sets the specified runner to failed (used by ruby script)
Failed sets the specified runner to failed ( used by ruby script )
// Set servers activity // update nms information