bugs

package
v0.0.0-...-8ff35f7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceBugRuleUpdatedTemplate = `Because this bug was merged into another bug, LUCI Analysis has` +
		` merged the failure association rule for this bug into the rule for the canonical bug.

See failure impact and configure the failure association rule for the canoncial bug at: %s`

	LinkTemplate = `See failure impact and configure the failure association rule for this bug at: %s`

	NoPermissionTemplate = `` /* 138-byte string literal not displayed */
)
View Source
const BuganizerSystem = "buganizer"

BuganizerSystem is the name of the buganizer bug tracker system.

View Source
const MonorailSystem = "monorail"

MonorailSystem is the name of the monorail bug tracker system.

Variables

View Source
var (
	// BugsCreatedCounter is the metric that counts the number of bugs
	// created by LUCI Analysis, by project and bug-filing system.
	BugsCreatedCounter = metric.NewCounter("analysis/bug_updater/bugs_created",
		"The number of bugs created by auto-bug filing, "+
			"by LUCI Project and bug-filing system.",
		&types.MetricMetadata{
			Units: "bugs",
		},

		field.String("project"),

		field.String("bug_system"),
	)

	BugsUpdatedCounter = metric.NewCounter("analysis/bug_updater/bugs_updated",
		"The number of bugs updated by auto-bug filing, "+
			"by LUCI Project and bug-filing system.",
		&types.MetricMetadata{
			Units: "bugs",
		},

		field.String("project"),

		field.String("bug_system"))
)
View Source
var BuganizerBugIDRe = regexp.MustCompile(`^([1-9][0-9]*)$`)

BuganizerBugIDRe matches identifiers of buganizer bugs (excluding the b/), like 1234567890.

View Source
var MonorailBugIDRe = regexp.MustCompile(`^([a-z0-9\-_]+)/([1-9][0-9]*)$`)

MonorailBugIDRe matches identifiers of monorail bugs, like "{monorail_project}/{numeric_id}".

Functions

func ActivationThresholds

func ActivationThresholds(policy *configpb.BugManagementPolicy) []*configpb.ImpactMetricThreshold

ActivationThresholds returns the set of thresholds that result in a policy activating. The returned thresholds should be treated as an 'OR', i.e. any of the given metric thresholds can result in a policy activating.

func ActivePolicies

func ActivePolicies(state *bugspb.BugManagementState) map[PolicyID]struct{}

ActivePolicies returns the set of policy IDs active in the given bug management state.

func ActivePoliciesPendingNotification

func ActivePoliciesPendingNotification(state *bugspb.BugManagementState) map[PolicyID]struct{}

ActivePoliciesPendingNotification returns the set of policies which are active but for which activation has not been notified to the bug.

func BugFiledHelpURL

func BugFiledHelpURL(uiBaseURL string) string

func BugReopenedHelpURL

func BugReopenedHelpURL(uiBaseURL string) string

func BugVerifiedHelpURL

func BugVerifiedHelpURL(uiBaseURL string) string

func ComponentSelectionHelpURL

func ComponentSelectionHelpURL(uiBaseURL string) string

func EnsureTimeToDeadline

func EnsureTimeToDeadline(ctx context.Context, d time.Duration) error

EnsureTimeToDeadline ensures there is at least duration `d` available before the context deadline. If not, it returns an error. It also returns an error if the context is already cancelled.

func FeedbackURL

func FeedbackURL(uiBaseURL string) string

func GenerateBugSummary

func GenerateBugSummary(title string) string

GenerateBugSummary generates a unified form of bug summary with a sanitized title.

func InflateThreshold

func InflateThreshold(t []*configpb.ImpactMetricThreshold, inflationPercent int64) []*configpb.ImpactMetricThreshold

InflateThreshold inflates or deflates impact thresholds by the given factor. This method is provided to help implement hysteresis. inflationPercent can be positive or negative (or zero), and is interpreted as follows: - If inflationPercent is positive, the new threshold is (threshold * (1 + (inflationPercent/100))) - If inflationPercent is negative, the new threshold used is (threshold / (1 + (-inflationPercent/100)) i.e. inflationPercent of +100 would result in a threshold that is 200% the original threshold being used, inflationPercent of -100 would result in a threshold that is 50% of the original. To avoid unintended effects such as 1 being inflated down to 0, inflation can never make a zero number non-zero or a non-zero number zero.

func PolicyActivatedHelpURL

func PolicyActivatedHelpURL(uiBaseURL string) string

func PriorityUpdatedHelpURL

func PriorityUpdatedHelpURL(uiBaseURL string) string

func RuleForBuganizerBugURL

func RuleForBuganizerBugURL(uiBaseURL string, issueID int64) string

RuleForBuganizerBugURL returns the link to the rule for the given buganizer bug. uiBaseURL is the base URL of the LUCI Analysis UI, excluding trailing slash.

func RuleForMonorailBugURL

func RuleForMonorailBugURL(uiBaseURL string, issueID string) string

RuleForMonorailBugURL returns the link to the rule for the given monorail bug. issueID is of the form "<monorail-project>/<id>", e.g. "chromium/100". uiBaseURL is the base URL of the LUCI Analysis UI, excluding trailing slash.

func RuleURL

func RuleURL(uiBaseURL, project, ruleID string) string

func Shorten

Shorten returns a derived context with its deadline shortened by d. The context can also be cancelled with the returned cancel function.

func UpdatePolicyActivations

func UpdatePolicyActivations(state *bugspb.BugManagementState, policies []*configpb.BugManagementPolicy, clusterMetrics ClusterMetrics, now time.Time) (updatedState *bugspb.BugManagementState, changed bool)

UpdatePolicyActivations updates the active policies for a failure association rule, given its current state, configured policies and cluster metrics.

If no reliable cluster metrics are available, nil should be passed as clusterMetrics and only pruning of old policies/creation of new state entries for new policies will occur.

If any updates need to be made, changed will be true and a new *bugspb.BugManagementState is returned. Otherwise, the original state is returned.

Types

type BugChange

type BugChange struct {
	// The human-readable justification of the change.
	// This will be blank if no change is proposed.
	Justification Commentary

	// Whether the bug priority should be updated.
	UpdatePriority bool
	// The new bug priority.
	Priority configpb.BuganizerPriority

	// Whether the bug verified status should be changed.
	UpdateVerified bool
	// Whether the bug should be verified now.
	ShouldBeVerified bool
}

type BugCreateRequest

type BugCreateRequest struct {
	// The ID of the rule that is in the process of being created.
	RuleID string
	// Description is the human-readable description of the cluster.
	Description *clustering.ClusterDescription
	// The monorail components (if any) to use.
	// This value is ignored for Buganizer.
	MonorailComponents []string
	// The buganizer component id (if any) to use.
	// This value is ignored for Monorail.
	BuganizerComponent int64
	// The bug management policies which activated for this
	// cluster and are triggering the filing of this bug.
	ActivePolicyIDs map[PolicyID]struct{}
}

BugCreateRequest captures a request to a bug filing system to file a new bug for a suggested cluster.

type BugCreateResponse

type BugCreateResponse struct {
	// The error encountered creating the bug. Note that this error
	// may have occured after a partial success; for example, we may have
	// successfully created a bug but failed on a subequent RPC to
	// posting comments for the policies that have activated.
	//
	// In the case of partial success, ID shall still be set to allow
	// creation of the rule. This avoids duplicate bugs being created
	// from repeated failed attempts to completely create a bug.
	// The policies for which comments could not be posted will
	// not be set to true under BugManagementState.Policies[<policyID>].ActivationNotified
	// so that these are retried as part of the bug update process.
	Error error

	// Simulated indicates whether the bug creation was simulated,
	// i.e. did not actually occur. If this is set, the returned
	// bug ID should be ignored.
	Simulated bool

	// The system-specific bug ID for the bug that was created.
	// See BugID.ID.
	// If we failed to create a bug, set to "" (empty).
	ID string

	// The set of policy IDs for which activation was successfully notified.
	// This may differ from the list in the request in the case of
	// partial or total failure to create the bug.
	// If a policy ID is included here,
	// BugManagementState.Policies[<policyID>].ActivationNotified will be
	// set to true on the rule.
	PolicyActivationsNotified map[PolicyID]struct{}
}

type BugID

type BugID struct {
	// System is the bug tracking system of the bug. This is either
	// "monorail" or "buganizer".
	System string `json:"system"`
	// ID is the bug tracking system-specific identity of the bug.
	// For monorail, the scheme is {project}/{numeric_id}, for
	// buganizer the scheme is {numeric_id}.
	ID string `json:"id"`
}

BugID represents the identity of a bug managed by LUCI Analysis.

func (*BugID) MonorailProjectAndID

func (b *BugID) MonorailProjectAndID() (project, id string, err error)

MonorailID returns the monorail project and ID of the given bug. If the bug is not a monorail bug or is invalid, an error is returned.

func (BugID) String

func (b BugID) String() string

func (*BugID) Validate

func (b *BugID) Validate() error

Validate checks if BugID is a valid bug reference. If not, it returns an error.

type BugOptions

type BugOptions struct {
	// The current bug management state.
	State *bugspb.BugManagementState
	// Whether we are managing the priority of the bug.
	IsManagingPriority bool
	// The current priority of the bug.
	ExistingPriority configpb.BuganizerPriority
	// Whether the bug is currently verified.
	ExistingVerified bool
}

type BugUpdateRequest

type BugUpdateRequest struct {
	// The bug to update.
	Bug BugID
	// Whether the user enabled priority updates and auto-closure for the bug.
	// If this if false, the BugUpdateRequest is only made to determine if the
	// bug is the duplicate of another bug and if the rule should be archived.
	IsManagingBug bool
	// Whether the user enabled priority updates for the Bug.
	// If this is false, the bug priority will not change.
	IsManagingBugPriority bool
	// The time when the field `IsManagingBugPriority` was last updated.
	// This is used to determine whether or not we should make priority updates by
	// if the user manually took control of the bug priority before
	// or after automatic priority updates were (re-)enabled.
	IsManagingBugPriorityLastUpdated time.Time
	// The identity of the rule associated with the bug.
	RuleID string
	// The bug management state of the rule. Only set if policy-based bug
	// management should be used; see Metrics field otherwise.
	BugManagementState *bugspb.BugManagementState
}

type BugUpdateResponse

type BugUpdateResponse struct {
	// Error is the error encountered updating this specific bug (if any).
	//
	// Even if an error is set here, partial success is possible and
	// actions may have been taken on the bug which require corresponding
	// rule updates. As such, even if an error is set here, the consumer
	// of this response must action the rule updates specified by
	// DisableRulePriorityUpdates, RuleAssociationNotified and
	// PolicyActivationsNotified to avoid us unnecessarily repeating
	// these actions on the bug the next time bug management runs.
	//
	// Similarly, even when an error occurs, the producer of this response
	// still has an an obligation to set DisableRulePriorityUpdates,
	// RuleAssociationNotified and PolicyActivationsNotified correctly.
	// In case of complete failures, leaving DisableRulePriorityUpdates
	// and PolicyActivationsNotified set to false, and PolicyActivationsNotified
	// empty will satisfy this requirement.
	Error error

	// IsDuplicate is set if the bug is a duplicate of another.
	// Set to true to trigger updating/merging failure association rules.
	//
	// If we could not fetch the bug for some reason and cannot determine
	// if the bug should be archived, this must be set to false.
	IsDuplicate bool

	// IsDuplicateAndAssigned is set if the bug is assigned to a user.
	// Only set if IsDuplicate is set.
	IsDuplicateAndAssigned bool

	// ShouldArchive indicates if the rule for this bug should be archived.
	// This should be set if:
	// - The bug is managed by LUCI Analysis (IsManagingBug = true) and it has
	//   been marked as Closed (verified) by LUCI Analysis for the last 30
	//   days.
	// - The bug is managed by the user (IsManagingBug = false), and the
	//   bug has been closed for the last 30 days.
	//
	// If we could not fetch the bug for some reason and cannot determine
	// if the bug should be archived, this must be set to false.
	ShouldArchive bool

	// DisableRulePriorityUpdates indicates that the rules `IsManagingBugUpdates`
	// field should be disabled.
	// This is set when a user manually takes control of the priority of a bug.
	//
	// If we could not fetch the bug for some reason and cannot determine
	// if the user has taken control of the bug, this must be set to false.
	DisableRulePriorityUpdates bool

	// Whether the association between the rule and the bug was notified.
	// Set to true to set BugManagementState.RuleAssociationNotified.
	RuleAssociationNotified bool

	// The set of policy IDs for which activation was notified.
	// This may differ from the set which is pending notification in the case of
	// partial or total failure to update the bug.
	// If a policy ID is included here,
	// BugManagementState.Policies[<policyID>].ActivationNotified will be
	// set to true on the rule.
	PolicyActivationsNotified map[PolicyID]struct{}
}

type ClusterMetrics

type ClusterMetrics map[metrics.ID]MetricValues

ClusterMetrics captures measurements of a cluster's impact and other variables, as needed to control the priority and verified status of bugs.

func (*ClusterMetrics) MeetsAnyOfThresholds

func (c *ClusterMetrics) MeetsAnyOfThresholds(ts []*configpb.ImpactMetricThreshold) bool

MeetsAnyOfThresholds returns whether the cluster metrics meet or exceed any of the specified thresholds.

func (*ClusterMetrics) MeetsThreshold

func (c *ClusterMetrics) MeetsThreshold(metricID metrics.ID, t *configpb.MetricThreshold) bool

MeetsThreshold returns whether the cluster metrics meet or exceed the specified threshold.

type Commentary

type Commentary struct {
	// The comment bodies. This should be the most important information to surface
	// to the user, and appears first. Do not include leading or trailing new line
	// character.
	Bodies []string
	// Text to appear in the footer of the comment, such as links to more information.
	// This information appears last. Do not include leading or trailing new line
	// character.
	Footers []string
}

Commentary represents part of a bug comment.

func ManualPriorityUpdateCommentary

func ManualPriorityUpdateCommentary() Commentary

func MergeCommentary

func MergeCommentary(cs ...Commentary) Commentary

MergeCommentary merges one or more commentary items into a bug comment. All commentary bodies appear first, followed by all footers.

func RuleAssociatedCommentary

func RuleAssociatedCommentary(ruleURL string) Commentary

func (Commentary) ToComment

func (c Commentary) ToComment() string

ToComment prepares a comment from commentary.

type DuplicateBugDetails

type DuplicateBugDetails struct {
	// The rule ID.
	RuleID string
	// Bug is the source bug that was merged-into another bug.
	Bug BugID
	// IsAssigned indicated whether this bug is assigned or not.
	IsAssigned bool
}

DuplicateBugDetails holds the data of a duplicate bug, this includes it's bug id, and whether or not it is assigned to a user.

type MetricValues

type MetricValues struct {
	OneDay   int64
	ThreeDay int64
	SevenDay int64
}

MetricValues captures measurements for one metric, over different timescales.

type PolicyApplyer

type PolicyApplyer struct {
	// contains filtered or unexported fields
}

PolicyApplyer provides methods to apply bug managment policies in a manner that is generic to the bug management system being used.

func NewPolicyApplyer

func NewPolicyApplyer(policies []*configpb.BugManagementPolicy, floorPriority configpb.BuganizerPriority) (PolicyApplyer, error)

NewPolicyApplyer initialises a new PolicyApplyer.

func (PolicyApplyer) NeedsPriorityOrVerifiedUpdate

func (p PolicyApplyer) NeedsPriorityOrVerifiedUpdate(opts BugOptions) bool

NeedsPriorityOrVerifiedUpdate returns whether a bug needs to have its priority or verified status updated, based on the current active policies.

func (PolicyApplyer) NewIssueDescription

func (p PolicyApplyer) NewIssueDescription(description *clustering.ClusterDescription, activatedPolicyIDs map[PolicyID]struct{}, uiBaseURL, ruleURL string) string

NewIssueDescription returns the issue description for a new bug. uiBaseURL is the URL of the UI base, without trailing slash, e.g. "https://luci-milo.appspot.com".

func (PolicyApplyer) PoliciesByIDs

func (p PolicyApplyer) PoliciesByIDs(policyIDs map[PolicyID]struct{}) []*configpb.BugManagementPolicy

PoliciesByIDs returns the policies with the given IDs, to the extent that they are still configured.

func (PolicyApplyer) PolicyActivatedComment

func (p PolicyApplyer) PolicyActivatedComment(policyID PolicyID, uiBaseURL string, input TemplateInput) (string, error)

PolicyActivatedComment returns a comment used to notify a bug that a policy has activated on a bug for the first time.

func (PolicyApplyer) PolicyByID

func (p PolicyApplyer) PolicyByID(policyID PolicyID) *configpb.BugManagementPolicy

PolicyByID returns the policy with the given ID, if it is still configured.

func (PolicyApplyer) PreparePriorityAndVerifiedChange

func (p PolicyApplyer) PreparePriorityAndVerifiedChange(opts BugOptions, uiBaseURL string) (BugChange, error)

PreparePriorityAndVerifiedChange generates the changes to apply to a bug's priority and verified fields, based on the the current active policies.

A human readable explanation of the changes to include in a comment is also returned.

func (PolicyApplyer) RecommendedPriorityAndVerified

func (p PolicyApplyer) RecommendedPriorityAndVerified(activePolicyIDs map[PolicyID]struct{}) (priority configpb.BuganizerPriority, verified bool)

RecommendedPriorityAndVerified identifies the priority and verification state recommended for a bug with the given set of policies active.

func (PolicyApplyer) SortPolicyIDsByPriorityDescending

func (p PolicyApplyer) SortPolicyIDsByPriorityDescending(policyIDs map[PolicyID]struct{}) []PolicyID

SortPolicyIDsByPriorityDescending sorts policy IDs in descending priority order (i.e. P0 policies first, then P1, then P2, ...). Where multiple policies have the same priority, they are sorted by policy ID. Only policies which are configured are returned.

type PolicyID

type PolicyID string

Represents the identifier of a bug management policy.

type Template

type Template struct {
	// contains filtered or unexported fields
}

Template is a template for bug comments.

func ParseTemplate

func ParseTemplate(t string) (Template, error)

ParseTemplate parses the given template source.

func (*Template) Execute

func (t *Template) Execute(input TemplateInput) (string, error)

Execute executes the template.

func (Template) Validate

func (t Template) Validate() error

Validate validates the template.

type TemplateBugID

type TemplateBugID struct {
	// contains filtered or unexported fields
}

TemplateBugID wraps the BugID type so we do not couple the interface the seen by a project's bug template to our implementation details. We want full control over the interface the template sees to ensure project configuration compatibility over time.

func NewTemplateBugID

func NewTemplateBugID(id BugID) TemplateBugID

NewTemplateBugID initializes a new TemplateBugID.

func (TemplateBugID) BuganizerBugID

func (b TemplateBugID) BuganizerBugID() (string, error)

BuganizerBugID returns the buganizer ID for a bug. E.g. "123456" for "b/123456". Errors if the bug is not a buganizer bug.

func (TemplateBugID) IsBuganizer

func (b TemplateBugID) IsBuganizer() bool

IsBuganizer returns whether the bug is a Buganizer bug.

func (TemplateBugID) IsMonorail

func (b TemplateBugID) IsMonorail() bool

IsMonorail returns whether the bug is a monorail bug.

func (TemplateBugID) MonorailBugID

func (b TemplateBugID) MonorailBugID() (string, error)

MonorailBugID returns the monorail ID for a bug (e.g. "123456" for crbug.com/123456). Errors if the bug is not a monorail bug.

func (TemplateBugID) MonorailProject

func (b TemplateBugID) MonorailProject() (string, error)

MonorailProject returns the monorail project for a bug. (e.g. "chromium" for crbug.com/123456). Errors if the bug is not a monorail bug.

type TemplateInput

type TemplateInput struct {
	// The link to the LUCI Analysis failure association rule.
	RuleURL string
	// The identifier of the bug on which we are commenting.
	BugID TemplateBugID
}

TemplateInput is the input to the policy-specified template for generating bug comments.

type UpdateDuplicateSourceRequest

type UpdateDuplicateSourceRequest struct {
	// BugDetails are details of the bug to be updated.
	// This includes the bug ID and whether or not it is assigned.
	BugDetails DuplicateBugDetails
	// ErrorMessage is the error that occured handling the duplicate bug.
	// If this is set, it will be posted to the bug and bug will marked as
	// no longer a duplicate to avoid repeately triggering the same error.
	ErrorMessage string
	// DestinationRuleID is the rule ID for the destination bug, that the rule
	// for the source bug was merged into.
	// Only populated if Error is unset.
	DestinationRuleID string
}

UpdateDuplicateSourceRequest represents a request to update the source bug of a duplicate bug (source bug, destination bug) pair, after LUCI Analysis has attempted to merge the failure association rule of the source to the destination.

Directories

Path Synopsis
Package buganizer contains methods to manage issues in Issue Tracker linked to failure association rules.
Package buganizer contains methods to manage issues in Issue Tracker linked to failure association rules.
Package cron defines the update-analysis-and-bugs cron job handler.
Package cron defines the update-analysis-and-bugs cron job handler.
Package updater contains methods to orchestrate automatic bug management, including automatic bug filing and automatic priority updates/auto-closure.
Package updater contains methods to orchestrate automatic bug management, including automatic bug filing and automatic priority updates/auto-closure.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL