// GetFailureMapping returns the map_failure mapping for an Export.
339711
func (c *Client) GetFailureMapping(
	ctx context.Context, name string) (UserMapping, error) {

	ex, err := c.GetExportByName(ctx, name)
	if err != nil {
		return nil, err
	}
	if ex == nil {
		return nil, nil
	}
	return ex.MapFailure, nil
}
697958
func (h *CSRFHandler) handleFailure(w http.ResponseWriter, r *http.Request) {
	h.failureHandler.ServeHTTP(w, r)
}
160859
func (s *regenerationStatistics) GetMap() map[string]*spanstat.SpanStat {
	result := map[string]*spanstat.SpanStat{
		"waitingForLock":         &s.waitingForLock,
		"waitingForCTClean":      &s.waitingForCTClean,
		"policyCalculation":      &s.policyCalculation,
		"proxyConfiguration":     &s.proxyConfiguration,
		"proxyPolicyCalculation": &s.proxyPolicyCalculation,
		"proxyWaitForAck":        &s.proxyWaitForAck,
		"mapSync":                &s.mapSync,
		"prepareBuild":           &s.prepareBuild,
		logfields.BuildDuration:  &s.totalTime,
	}
	for k, v := range s.datapathRealization.GetMap() {
		result[k] = v
	}
	return result
}
549003
func (c *Config) GetStringMapString(s string) map[string]string {
	return c.config.GetStringMapString(s)
}
1124752
func (u *UpdateJob) MaxPerInstanceFailures(inst int32) *UpdateJob {
	u.req.Settings.MaxPerInstanceFailures = inst
	return u
}
976159
func (s *TagResourcesOutput) SetFailedResourcesMap(v map[string]*FailureInfo) *TagResourcesOutput {
	s.FailedResourcesMap = v
	return s
}
1226699
func GetFailureCollector(th *starlark.Thread) *FailureCollector {
	fc, _ := th.Local(failSlotKey).(*FailureCollector)
	return fc
}
1249925
func (i *Import) GetFailedStep() string {
	if i == nil || i.FailedStep == nil {
		return ""
	}
	return *i.FailedStep
}
698392
func inferFailedReason(pod *apiv1.Pod) (wfv1.NodePhase, string) {
	if pod.Status.Message != "" {
		// Pod has a nice error message. Use that.
		return wfv1.NodeFailed, pod.Status.Message
	}
	annotatedMsg := pod.Annotations[common.AnnotationKeyNodeMessage]
	// We only get one message to set for the overall node status.
	// If multiple containers failed, in order of preference:
	// init, main (annotated), main (exit code), wait, sidecars
	for _, ctr := range pod.Status.InitContainerStatuses {
		if ctr.State.Terminated == nil {
			// We should never get here
			log.Warnf("Pod %s phase was Failed but %s did not have terminated state", pod.ObjectMeta.Name, ctr.Name)
			continue
		}
		if ctr.State.Terminated.ExitCode == 0 {
			continue
		}
		errMsg := fmt.Sprintf("failed to load artifacts")
		for _, msg := range []string{annotatedMsg, ctr.State.Terminated.Message} {
			if msg != "" {
				errMsg += ": " + msg
				break
			}
		}
		// NOTE: we consider artifact load issues as Error instead of Failed
		return wfv1.NodeError, errMsg
	}
	failMessages := make(map[string]string)
	for _, ctr := range pod.Status.ContainerStatuses {
		if ctr.State.Terminated == nil {
			// We should never get here
			log.Warnf("Pod %s phase was Failed but %s did not have terminated state", pod.ObjectMeta.Name, ctr.Name)
			continue
		}
		if ctr.State.Terminated.ExitCode == 0 {
			continue
		}
		if ctr.Name == common.WaitContainerName {
			errDetails := ""
			for _, msg := range []string{annotatedMsg, ctr.State.Terminated.Message} {
				if msg != "" {
					errDetails = msg
					break
				}
			}
			if errDetails == "" {
				// executor is expected to annotate a message to the pod upon any errors.
				// If we failed to see the annotated message, it is likely the pod ran with
				// insufficient privileges. Give a hint to that effect.
				errDetails = fmt.Sprintf("verify serviceaccount %s:%s has necessary privileges", pod.ObjectMeta.Namespace, pod.Spec.ServiceAccountName)
			}
			errMsg := fmt.Sprintf("failed to save outputs: %s", errDetails)
			failMessages[ctr.Name] = errMsg
			continue
		}
		if ctr.State.Terminated.Message != "" {
			failMessages[ctr.Name] = ctr.State.Terminated.Message
			continue
		}
		if ctr.State.Terminated.Reason == "OOMKilled" {
			failMessages[ctr.Name] = ctr.State.Terminated.Reason
			continue
		}
		errMsg := fmt.Sprintf("failed with exit code %d", ctr.State.Terminated.ExitCode)
		if ctr.Name != common.MainContainerName {
			if ctr.State.Terminated.ExitCode == 137 || ctr.State.Terminated.ExitCode == 143 {
				// if the sidecar was SIGKILL'd (exit code 137) assume it was because argoexec
				// forcibly killed the container, which we ignore the error for.
				// Java code 143 is a normal exit 128 + 15 https://github.com/elastic/elasticsearch/issues/31847
				log.Infof("Ignoring %d exit code of sidecar '%s'", ctr.State.Terminated.ExitCode, ctr.Name)
				continue
			}
			errMsg = fmt.Sprintf("sidecar '%s' %s", ctr.Name, errMsg)
		}
		failMessages[ctr.Name] = errMsg
	}
	if failMsg, ok := failMessages[common.MainContainerName]; ok {
		_, ok = failMessages[common.WaitContainerName]
		isResourceTemplate := !ok
		if isResourceTemplate && annotatedMsg != "" {
			// For resource templates, we prefer the annotated message
			// over the vanilla exit code 1 error
			return wfv1.NodeFailed, annotatedMsg
		}
		return wfv1.NodeFailed, failMsg
	}
	if failMsg, ok := failMessages[common.WaitContainerName]; ok {
		return wfv1.NodeError, failMsg
	}

	// If we get here, both the main and wait container succeeded. Iterate the fail messages to
	// identify the sidecar which failed and return the message.
	for _, failMsg := range failMessages {
		return wfv1.NodeFailed, failMsg
	}
	// If we get here, we have detected that the main/wait containers succeed but the sidecar(s)
	// were  SIGKILL'd. The executor may have had to forcefully terminate the sidecar (kill -9),
	// resulting in a 137 exit code (which we had ignored earlier). If failMessages is empty, it
	// indicates that this is the case and we return Success instead of Failure.
	return wfv1.NodeSucceeded, ""
}
1007069
func (f *FSMContext) FailWorkflow(data interface{}, details *string) Outcome {
	d := &swf.Decision{
		DecisionType: S(swf.DecisionTypeFailWorkflowExecution),
		FailWorkflowExecutionDecisionAttributes: &swf.FailWorkflowExecutionDecisionAttributes{
			Details: details,
		},
	}
	return Outcome{
		State:     FailedState,
		Data:      data,
		Decisions: f.Decision(d),
	}
}
1293160
func GetSpanFilterMapFromContext(ctx context.Context) error {
	v := ctx.Value(spanFailures)
	if v != nil {
		failMap := v.(*Map)
		return failMap
	}
	return emptySpanFilter
}
1262423
func (b *batchSpendReporter) FailRemaining(err error) error {
	for outpoint, requests := range b.requests {
		b.notifyRequests(&outpoint, requests, nil, err)
	}
	return err
}
1088134
func GetStringMapValue(mapVal, keyVal interface{}) (interface{}, error) {
	key, ok := keyVal.(string)
	if !ok {
		return nil, trace.BadParameter("only string keys are supported")
	}
	switch m := mapVal.(type) {
	case map[string][]string:
		if len(m) == 0 {
			// to return nil with a proper type
			var n []string
			return n, nil
		}
		return m[key], nil
	case Traits:
		if len(m) == 0 {
			// to return nil with a proper type
			var n []string
			return n, nil
		}
		return m[key], nil
	case map[string]string:
		if len(m) == 0 {
			return "", nil
		}
		return m[key], nil
	default:
		_, ok := mapVal.(map[string][]string)
		return nil, trace.BadParameter("type %T is not supported, but %v %#v", m, ok, mapVal)
	}
}
344473
func (c *Client) GetRootMapping(
	ctx context.Context, name string) (UserMapping, error) {

	ex, err := c.GetExportByName(ctx, name)
	if err != nil {
		return nil, err
	}
	if ex == nil {
		return nil, nil
	}
	return ex.MapRoot, nil
}
616828
func (s *StepExecution) SetOnFailure(v string) *StepExecution {
	s.OnFailure = &v
	return s
}
295409
func FindRouteAdmissionFailures(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker {
	markers := []osgraph.Marker{}

	for _, uncastRouteNode := range g.NodesByKind(routegraph.RouteNodeKind) {
		routeNode := uncastRouteNode.(*routegraph.RouteNode)
	Route:
		for _, ingress := range routeNode.Status.Ingress {
			switch status, condition := routedisplayhelpers.IngressConditionStatus(&ingress, routev1.RouteAdmitted); status {
			case corev1.ConditionFalse:
				markers = append(markers, osgraph.Marker{
					Node: routeNode,

					Severity: osgraph.ErrorSeverity,
					Key:      RouteNotAdmittedTypeErr,
					Message:  fmt.Sprintf("%s was not accepted by router %q: %s%s (%s)", f.ResourceName(routeNode), ingress.RouterName, ingress.RouterCanonicalHostname, condition.Message, condition.Reason),
				})
				break Route
			}
		}
	}

	return markers
}
1062626
func ToFailpoints(wdst io.Writer, rsrc io.Reader) (fps []*Failpoint, err error) {
	var curfp *Failpoint

	dst := bufio.NewWriter(wdst)
	defer func() {
		if err == nil && curfp != nil {
			err = curfp.flush(dst)
		}
		if err == nil {
			err = dst.Flush()
		}
	}()

	src := bufio.NewReader(rsrc)
	for err == nil {
		l, rerr := src.ReadString('\n')
		if curfp != nil {
			if strings.HasPrefix(strings.TrimSpace(l), "//") {
				if len(l) > 0 && l[len(l)-1] == '\n' {
					l = l[:len(l)-1]
				}
				curfp.code = append(curfp.code, strings.Replace(l, "//", "\t", 1))
				continue
			} else {
				curfp.flush(dst)
				fps = append(fps, curfp)
				curfp = nil
			}
		} else if label := gofailLabel(l); label != "" {
			// expose gofail label
			l = label
		} else if curfp, err = newFailpoint(l); err != nil {
			return
		} else if curfp != nil {
			// found a new failpoint
			continue
		}
		if _, err = dst.WriteString(l); err != nil {
			return
		}
		if rerr == io.EOF {
			break
		}
	}
	return
}