// Abort marks the current upgrade as aborted. It should be called if
// the upgrade can't be completed for some reason.
185580
func (info *UpgradeInfo) Abort() error {
	buildTxn := func(attempt int) ([]txn.Op, error) {
		doc, err := currentUpgradeInfoDoc(info.st)
		if errors.IsNotFound(err) {
			return nil, jujutxn.ErrNoOperations
		} else if err != nil {
			return nil, errors.Trace(err)
		}
		ops := info.makeArchiveOps(doc, UpgradeAborted)
		extraOps, err := upgradeStatusHistoryAndOps(info.st, UpgradeAborted, info.st.clock().Now())
		if err != nil {
			return nil, errors.Trace(err)
		}
		if len(extraOps) > 0 {
			ops = append(ops, extraOps...)
		}

		return ops, nil
	}
	err := info.st.db().Run(buildTxn)
	return errors.Annotate(err, "cannot abort upgrade")
}
733042
func UpgradeTimeout(timeout int64) UpdateOption {
	return func(opts *options) {
		opts.updateReq.Timeout = timeout
	}
}
74159
func (r *Response) Abort(status int, body string) {
	r.ResponseWriter.WriteHeader(status)
	r.WriteString(body)
}
350033
func (c *Client) AbortCurrentUpgrade() error {
	if err := c.checkCanWrite(); err != nil {
		return err
	}

	if err := c.check.ChangeAllowed(); err != nil {
		return errors.Trace(err)
	}
	return c.api.stateAccessor.AbortCurrentUpgrade()
}
214346
func (s *GetBotOutput) SetAbortStatement(v *Statement) *GetBotOutput {
	s.AbortStatement = v
	return s
}
970551
func (e *engineImpl) abortInvocation(c context.Context, jobID string, invID int64) error {
	return e.withController(c, jobID, invID, "manual abort", func(c context.Context, ctl *taskController) error {
		ctl.DebugLog("Invocation is manually aborted by %s", auth.CurrentIdentity(c))

		switch err := ctl.manager.AbortTask(c, ctl); {
		case transient.Tag.In(err):
			return err // ask for retry on transient errors, don't touch Invocation
		case err != nil:
			ctl.DebugLog("Fatal error when aborting the invocation - %s", err)
		}

		// On success or on a fatal error mark the task as aborted (unless the
		// manager already switched the state). We can't do anything about the
		// failed abort attempt anyway.
		if !ctl.State().Status.Final() {
			ctl.State().Status = task.StatusAborted
		}
		return nil
	})
}
422703
func (api *HighAvailabilityAPI) StopHAReplicationForUpgrade(args params.UpgradeMongoParams) (
	params.MongoUpgradeResults, error,
) {
	ha, err := api.state.SetUpgradeMongoMode(mongo.Version{
		Major:         args.Target.Major,
		Minor:         args.Target.Minor,
		Patch:         args.Target.Patch,
		StorageEngine: mongo.StorageEngine(args.Target.StorageEngine),
	})
	if err != nil {
		return params.MongoUpgradeResults{}, errors.Annotate(err, "cannot stop HA for upgrade")
	}
	members := make([]params.HAMember, len(ha.Members))
	for i, m := range ha.Members {
		members[i] = params.HAMember{
			Tag:           m.Tag,
			PublicAddress: m.PublicAddress,
			Series:        m.Series,
		}
	}
	return params.MongoUpgradeResults{
		Master: params.HAMember{
			Tag:           ha.Master.Tag,
			PublicAddress: ha.Master.PublicAddress,
			Series:        ha.Master.Series,
		},
		Members:   members,
		RsMembers: ha.RsMembers,
	}, nil
}
525206
func (api objectAPIHandlers) AbortMultipartUploadHandler(w http.ResponseWriter, r *http.Request) {
	ctx := newContext(r, w, "AbortMultipartUpload")

	defer logger.AuditLog(w, r, "AbortMultipartUpload", mustGetClaimsFromToken(r))

	vars := mux.Vars(r)
	bucket := vars["bucket"]
	object := vars["object"]

	objectAPI := api.ObjectAPI()
	if objectAPI == nil {
		writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL, guessIsBrowserReq(r))
		return
	}
	abortMultipartUpload := objectAPI.AbortMultipartUpload
	if api.CacheAPI() != nil {
		abortMultipartUpload = api.CacheAPI().AbortMultipartUpload
	}

	if s3Error := checkRequestAuthType(ctx, r, policy.AbortMultipartUploadAction, bucket, object); s3Error != ErrNone {
		writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL, guessIsBrowserReq(r))
		return
	}

	// Deny if WORM is enabled
	if globalWORMEnabled {
		if _, err := objectAPI.GetObjectInfo(ctx, bucket, object, ObjectOptions{}); err == nil {
			writeErrorResponse(ctx, w, errorCodes.ToAPIErr(ErrMethodNotAllowed), r.URL, guessIsBrowserReq(r))
			return
		}
	}

	uploadID, _, _, _, s3Error := getObjectResources(r.URL.Query())
	if s3Error != ErrNone {
		writeErrorResponse(ctx, w, errorCodes.ToAPIErr(s3Error), r.URL, guessIsBrowserReq(r))
		return
	}
	if err := abortMultipartUpload(ctx, bucket, object, uploadID); err != nil {
		writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r))
		return
	}

	writeSuccessNoContent(w)
}
256859
func (c *Conversation) AbortAuthentication() ([]ValidMessage, error) {
	t := c.restartSMP()

	msgs, _, err := c.createSerializedDataMessage(nil, messageFlagIgnoreUnreadable, []tlv{t})
	return msgs, err
}
659744
func (ctx *Context) Abort(statusCode int, data ...map[string]interface{}) {
	ctx.App.handleError(ctx, statusCode, data...)
}
248111
func (c Core) AbortMultipartUpload(bucket, object, uploadID string) error {
	return c.abortMultipartUpload(context.Background(), bucket, object, uploadID)
}
379887
func (c *Canceller) Cancel() {
	c.mutex.Lock()
	defer c.mutex.Unlock()
	c.cancel()
}
445431
func (cwg *ControlWaitGroup) Abort() {
	cwg.mu.Lock()
	cwg.abort = true
	cwg.mu.Unlock()
}
1212690
func (e *engineImpl) AbortJob(c context.Context, job *Job) error {
	if err := job.CheckRole(c, acl.Owner); err != nil {
		return err
	}
	jobID := job.JobID

	var invs []int64
	err := e.jobTxn(c, jobID, func(c context.Context, job *Job, isNew bool) (err error) {
		if isNew {
			return errSkipPut // the job was removed, nothing to abort
		}
		// We just abort all active invocations. This should cause them to
		// eventually move to Aborted state, which will kick them out of
		// ActiveInvocations list.
		invs = job.ActiveInvocations
		// AbortJob is sometimes used manually to "reset" the job state if it got
		// stuck for some reason. We initiate a triage for this purpose. This is not
		// strictly necessary (but doesn't hurt either).
		return e.kickTriageLater(c, job.JobID, 0)
	})
	if err != nil {
		return err
	}

	// Now we kill the invocations. We do it separately because it may involve
	// an RPC to remote service (e.g. to cancel a task) that can't be done from
	// the transaction.
	wg := sync.WaitGroup{}
	wg.Add(len(invs))
	errs := errors.NewLazyMultiError(len(invs))
	for i, invID := range invs {
		go func(i int, invID int64) {
			defer wg.Done()
			errs.Assign(i, e.abortInvocation(c, jobID, invID))
		}(i, invID)
	}
	wg.Wait()
	if err := errs.Get(); err != nil {
		return transient.Tag.Apply(err)
	}
	return nil
}
1062976
func (c *Context) AbortWithError(code int, err error) *Error {
	c.AbortWithStatus(code)
	return c.Error(err)
}
695599
func (c cacheObjects) AbortMultipartUpload(ctx context.Context, bucket, object, uploadID string) error {
	abortMultipartUploadFn := c.AbortMultipartUploadFn

	if c.isCacheExclude(bucket, object) {
		return abortMultipartUploadFn(ctx, bucket, object, uploadID)
	}

	dcache, err := c.cache.getCacheFS(ctx, bucket, object)
	if err != nil {
		// disk cache could not be located,execute backend call.
		return abortMultipartUploadFn(ctx, bucket, object, uploadID)
	}
	// execute backend operation
	err = abortMultipartUploadFn(ctx, bucket, object, uploadID)
	if err != nil {
		return err
	}
	// abort multipart upload on cache
	dcache.AbortMultipartUpload(ctx, bucket, object, uploadID)
	return nil
}
1310557
func (l *b2Objects) AbortMultipartUpload(ctx context.Context, bucket string, object string, uploadID string) error {
	bkt, err := l.Bucket(ctx, bucket)
	if err != nil {
		return err
	}
	err = bkt.File(uploadID, object).CompileParts(0, nil).CancelLargeFile(l.ctx)
	logger.LogIf(ctx, err)
	return b2ToObjectError(err, bucket, object, uploadID)
}