2023-04-10 15:36:59 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2017-03-09 23:20:53 +00:00
|
|
|
package scheduler
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2017-07-31 23:44:17 +00:00
|
|
|
"strconv"
|
2017-03-09 23:20:53 +00:00
|
|
|
|
2018-09-15 23:23:13 +00:00
|
|
|
log "github.com/hashicorp/go-hclog"
|
2017-03-09 23:20:53 +00:00
|
|
|
memdb "github.com/hashicorp/go-memdb"
|
2023-05-17 14:25:00 +00:00
|
|
|
"github.com/hashicorp/go-set"
|
|
|
|
|
2017-07-31 23:44:17 +00:00
|
|
|
"github.com/hashicorp/nomad/helper"
|
2017-03-09 23:20:53 +00:00
|
|
|
"github.com/hashicorp/nomad/nomad/structs"
|
|
|
|
)
|
|
|
|
|
|
|
|
// propertySet is used to track the values used for a particular property.
|
|
|
|
type propertySet struct {
|
|
|
|
// ctx is used to lookup the plan and state
|
|
|
|
ctx Context
|
|
|
|
|
2018-09-15 23:23:13 +00:00
|
|
|
// logger is the logger for the property set
|
|
|
|
logger log.Logger
|
|
|
|
|
2017-03-10 00:12:43 +00:00
|
|
|
// jobID is the job we are operating on
|
2017-03-09 23:20:53 +00:00
|
|
|
jobID string
|
|
|
|
|
2017-09-07 23:56:15 +00:00
|
|
|
// namespace is the namespace of the job we are operating on
|
|
|
|
namespace string
|
|
|
|
|
2017-03-10 00:12:43 +00:00
|
|
|
// taskGroup is optionally set if the constraint is for a task group
|
|
|
|
taskGroup string
|
|
|
|
|
2018-07-17 22:25:38 +00:00
|
|
|
// targetAttribute is the attribute this property set is checking
|
|
|
|
targetAttribute string
|
2017-03-09 23:20:53 +00:00
|
|
|
|
2023-05-17 14:25:00 +00:00
|
|
|
// targetValues are the set of attribute values that are explicitly expected,
|
|
|
|
// so we can combine the count of values that belong to any implicit targets.
|
|
|
|
targetValues *set.Set[string]
|
|
|
|
|
2017-07-31 23:44:17 +00:00
|
|
|
// allowedCount is the allowed number of allocations that can have the
|
|
|
|
// distinct property
|
|
|
|
allowedCount uint64
|
|
|
|
|
2017-03-09 23:20:53 +00:00
|
|
|
// errorBuilding marks whether there was an error when building the property
|
|
|
|
// set
|
|
|
|
errorBuilding error
|
|
|
|
|
2017-07-31 23:44:17 +00:00
|
|
|
// existingValues is a mapping of the values of a property to the number of
|
|
|
|
// times the value has been used by pre-existing allocations.
|
|
|
|
existingValues map[string]uint64
|
2017-03-09 23:20:53 +00:00
|
|
|
|
2017-07-31 23:44:17 +00:00
|
|
|
// proposedValues is a mapping of the values of a property to the number of
|
|
|
|
// times the value has been used by proposed allocations.
|
|
|
|
proposedValues map[string]uint64
|
2017-03-09 23:20:53 +00:00
|
|
|
|
2017-07-31 23:44:17 +00:00
|
|
|
// clearedValues is a mapping of the values of a property to the number of
|
|
|
|
// times the value has been used by proposed stopped allocations.
|
|
|
|
clearedValues map[string]uint64
|
2017-03-09 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewPropertySet returns a new property set used to guarantee unique property
|
|
|
|
// values for new allocation placements.
|
|
|
|
func NewPropertySet(ctx Context, job *structs.Job) *propertySet {
|
|
|
|
p := &propertySet{
|
|
|
|
ctx: ctx,
|
|
|
|
jobID: job.ID,
|
2017-09-07 23:56:15 +00:00
|
|
|
namespace: job.Namespace,
|
2017-07-31 23:44:17 +00:00
|
|
|
existingValues: make(map[string]uint64),
|
2023-05-17 14:25:00 +00:00
|
|
|
targetValues: set.From([]string{}),
|
2018-09-15 23:23:13 +00:00
|
|
|
logger: ctx.Logger().Named("property_set"),
|
2017-03-09 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
2018-07-26 00:08:25 +00:00
|
|
|
// SetJobConstraint is used to parameterize the property set for a
|
2017-03-09 23:20:53 +00:00
|
|
|
// distinct_property constraint set at the job level.
|
|
|
|
func (p *propertySet) SetJobConstraint(constraint *structs.Constraint) {
|
2017-07-31 23:44:17 +00:00
|
|
|
p.setConstraint(constraint, "")
|
2017-03-09 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetTGConstraint is used to parameterize the property set for a
|
|
|
|
// distinct_property constraint set at the task group level. The inputs are the
|
|
|
|
// constraint and the task group name.
|
|
|
|
func (p *propertySet) SetTGConstraint(constraint *structs.Constraint, taskGroup string) {
|
2017-07-31 23:44:17 +00:00
|
|
|
p.setConstraint(constraint, taskGroup)
|
|
|
|
}
|
|
|
|
|
|
|
|
// setConstraint is a shared helper for setting a job or task group constraint.
|
|
|
|
func (p *propertySet) setConstraint(constraint *structs.Constraint, taskGroup string) {
|
2018-07-17 23:10:54 +00:00
|
|
|
var allowedCount uint64
|
2017-07-31 23:44:17 +00:00
|
|
|
// Determine the number of allowed allocations with the property.
|
|
|
|
if v := constraint.RTarget; v != "" {
|
|
|
|
c, err := strconv.ParseUint(v, 10, 64)
|
|
|
|
if err != nil {
|
|
|
|
p.errorBuilding = fmt.Errorf("failed to convert RTarget %q to uint64: %v", v, err)
|
2018-09-15 23:23:13 +00:00
|
|
|
p.logger.Error("failed to convert RTarget to uint64", "RTarget", v, "error", err)
|
2017-07-31 23:44:17 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-07-17 22:25:38 +00:00
|
|
|
allowedCount = c
|
2017-07-31 23:44:17 +00:00
|
|
|
} else {
|
2018-07-17 22:25:38 +00:00
|
|
|
allowedCount = 1
|
|
|
|
}
|
2018-07-26 00:08:25 +00:00
|
|
|
p.setTargetAttributeWithCount(constraint.LTarget, allowedCount, taskGroup)
|
2018-07-17 22:25:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SetTargetAttribute is used to populate this property set without also storing allowed count
|
2023-01-30 14:48:43 +00:00
|
|
|
// This is used when evaluating spread blocks
|
2018-07-17 22:25:38 +00:00
|
|
|
func (p *propertySet) SetTargetAttribute(targetAttribute string, taskGroup string) {
|
2018-07-26 00:08:25 +00:00
|
|
|
p.setTargetAttributeWithCount(targetAttribute, 0, taskGroup)
|
2018-07-17 22:25:38 +00:00
|
|
|
}
|
|
|
|
|
2018-07-26 00:08:25 +00:00
|
|
|
// setTargetAttributeWithCount is a shared helper for setting a job or task group attribute and allowedCount
|
2023-01-30 14:48:43 +00:00
|
|
|
// allowedCount can be zero when this is used in evaluating spread blocks
|
2018-07-26 00:08:25 +00:00
|
|
|
func (p *propertySet) setTargetAttributeWithCount(targetAttribute string, allowedCount uint64, taskGroup string) {
|
2018-07-17 22:25:38 +00:00
|
|
|
// Store that this is for a task group
|
|
|
|
if taskGroup != "" {
|
|
|
|
p.taskGroup = taskGroup
|
2017-07-31 23:44:17 +00:00
|
|
|
}
|
|
|
|
|
2018-07-17 22:25:38 +00:00
|
|
|
// Store the constraint
|
|
|
|
p.targetAttribute = targetAttribute
|
|
|
|
|
|
|
|
p.allowedCount = allowedCount
|
|
|
|
|
2017-07-31 23:44:17 +00:00
|
|
|
// Determine the number of existing allocations that are using a property
|
|
|
|
// value
|
2018-07-26 00:08:25 +00:00
|
|
|
p.populateExisting()
|
2017-07-31 18:17:35 +00:00
|
|
|
|
|
|
|
// Populate the proposed when setting the constraint. We do this because
|
|
|
|
// when detecting if we can inplace update an allocation we stage an
|
|
|
|
// eviction and then select. This means the plan has an eviction before a
|
|
|
|
// single select has finished.
|
|
|
|
p.PopulateProposed()
|
2017-03-10 00:12:43 +00:00
|
|
|
}
|
|
|
|
|
2023-05-17 14:25:00 +00:00
|
|
|
func (p *propertySet) SetTargetValues(values []string) {
|
|
|
|
p.targetValues = set.From(values)
|
|
|
|
}
|
|
|
|
|
2017-03-10 00:12:43 +00:00
|
|
|
// populateExisting is a helper shared when setting the constraint to populate
|
|
|
|
// the existing values.
|
2018-07-26 00:08:25 +00:00
|
|
|
func (p *propertySet) populateExisting() {
|
2017-03-09 23:20:53 +00:00
|
|
|
// Retrieve all previously placed allocations
|
|
|
|
ws := memdb.NewWatchSet()
|
2017-09-07 23:56:15 +00:00
|
|
|
allocs, err := p.ctx.State().AllocsByJob(ws, p.namespace, p.jobID, false)
|
2017-03-09 23:20:53 +00:00
|
|
|
if err != nil {
|
|
|
|
p.errorBuilding = fmt.Errorf("failed to get job's allocations: %v", err)
|
2018-09-15 23:23:13 +00:00
|
|
|
p.logger.Error("failed to get job's allocations", "job", p.jobID, "namespace", p.namespace, "error", err)
|
2017-03-09 23:20:53 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-03-10 00:12:43 +00:00
|
|
|
// Filter to the correct set of allocs
|
2018-07-16 23:00:28 +00:00
|
|
|
allocs = p.filterAllocs(allocs, true)
|
2017-03-09 23:20:53 +00:00
|
|
|
|
|
|
|
// Get all the nodes that have been used by the allocs
|
2018-07-16 23:00:28 +00:00
|
|
|
nodes, err := p.buildNodeMap(allocs)
|
2017-03-09 23:20:53 +00:00
|
|
|
if err != nil {
|
|
|
|
p.errorBuilding = err
|
2018-09-15 23:23:13 +00:00
|
|
|
p.logger.Error("failed to build node map", "error", err)
|
2017-03-09 23:20:53 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-03-10 05:36:27 +00:00
|
|
|
// Build existing properties map
|
2018-07-16 23:00:28 +00:00
|
|
|
p.populateProperties(allocs, nodes, p.existingValues)
|
2017-03-09 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// PopulateProposed populates the proposed values and recomputes any cleared
|
|
|
|
// value. It should be called whenever the plan is updated to ensure correct
|
|
|
|
// results when checking an option.
|
|
|
|
func (p *propertySet) PopulateProposed() {
|
|
|
|
|
|
|
|
// Reset the proposed properties
|
2017-07-31 23:44:17 +00:00
|
|
|
p.proposedValues = make(map[string]uint64)
|
|
|
|
p.clearedValues = make(map[string]uint64)
|
2017-03-09 23:20:53 +00:00
|
|
|
|
|
|
|
// Gather the set of proposed stops.
|
|
|
|
var stopping []*structs.Allocation
|
|
|
|
for _, updates := range p.ctx.Plan().NodeUpdate {
|
|
|
|
stopping = append(stopping, updates...)
|
|
|
|
}
|
2018-07-16 23:00:28 +00:00
|
|
|
stopping = p.filterAllocs(stopping, false)
|
2017-03-09 23:20:53 +00:00
|
|
|
|
|
|
|
// Gather the proposed allocations
|
|
|
|
var proposed []*structs.Allocation
|
|
|
|
for _, pallocs := range p.ctx.Plan().NodeAllocation {
|
|
|
|
proposed = append(proposed, pallocs...)
|
|
|
|
}
|
2018-07-16 23:00:28 +00:00
|
|
|
proposed = p.filterAllocs(proposed, true)
|
2017-03-09 23:20:53 +00:00
|
|
|
|
|
|
|
// Get the used nodes
|
|
|
|
both := make([]*structs.Allocation, 0, len(stopping)+len(proposed))
|
|
|
|
both = append(both, stopping...)
|
|
|
|
both = append(both, proposed...)
|
2018-07-16 23:00:28 +00:00
|
|
|
nodes, err := p.buildNodeMap(both)
|
2017-03-09 23:20:53 +00:00
|
|
|
if err != nil {
|
|
|
|
p.errorBuilding = err
|
2018-09-15 23:23:13 +00:00
|
|
|
p.logger.Error("failed to build node map", "error", err)
|
2017-03-09 23:20:53 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Populate the cleared values
|
2018-07-16 23:00:28 +00:00
|
|
|
p.populateProperties(stopping, nodes, p.clearedValues)
|
2017-03-09 23:20:53 +00:00
|
|
|
|
|
|
|
// Populate the proposed values
|
2018-07-16 23:00:28 +00:00
|
|
|
p.populateProperties(proposed, nodes, p.proposedValues)
|
2017-03-09 23:20:53 +00:00
|
|
|
|
2017-03-10 05:36:27 +00:00
|
|
|
// Remove any cleared value that is now being used by the proposed allocs
|
|
|
|
for value := range p.proposedValues {
|
2017-07-31 23:44:17 +00:00
|
|
|
current, ok := p.clearedValues[value]
|
|
|
|
if !ok {
|
|
|
|
continue
|
|
|
|
} else if current == 0 {
|
|
|
|
delete(p.clearedValues, value)
|
|
|
|
} else if current > 1 {
|
|
|
|
p.clearedValues[value]--
|
|
|
|
}
|
2017-03-09 23:20:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// SatisfiesDistinctProperties checks if the option satisfies the
|
|
|
|
// distinct_property constraints given the existing placements and proposed
|
|
|
|
// placements. If the option does not satisfy the constraints an explanation is
|
|
|
|
// given.
|
|
|
|
func (p *propertySet) SatisfiesDistinctProperties(option *structs.Node, tg string) (bool, string) {
|
2018-07-17 22:25:38 +00:00
|
|
|
nValue, errorMsg, usedCount := p.UsedCount(option, tg)
|
|
|
|
if errorMsg != "" {
|
|
|
|
return false, errorMsg
|
|
|
|
}
|
|
|
|
// The property value has been used but within the number of allowed
|
|
|
|
// allocations.
|
|
|
|
if usedCount < p.allowedCount {
|
|
|
|
return true, ""
|
|
|
|
}
|
|
|
|
|
|
|
|
return false, fmt.Sprintf("distinct_property: %s=%s used by %d allocs", p.targetAttribute, nValue, usedCount)
|
|
|
|
}
|
|
|
|
|
|
|
|
// UsedCount returns the number of times the value of the attribute being tracked by this
|
|
|
|
// property set is used across current and proposed allocations. It also returns the resolved
|
|
|
|
// attribute value for the node, and an error message if it couldn't be resolved correctly
|
2023-05-17 14:25:00 +00:00
|
|
|
func (p *propertySet) UsedCount(option *structs.Node, _ string) (string, string, uint64) {
|
2017-03-09 23:20:53 +00:00
|
|
|
// Check if there was an error building
|
|
|
|
if p.errorBuilding != nil {
|
2018-07-17 22:25:38 +00:00
|
|
|
return "", p.errorBuilding.Error(), 0
|
2017-03-09 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get the nodes property value
|
2018-07-17 22:25:38 +00:00
|
|
|
nValue, ok := getProperty(option, p.targetAttribute)
|
2023-05-17 14:25:00 +00:00
|
|
|
targetPropertyValue := p.targetedPropertyValue(nValue)
|
2017-03-09 23:20:53 +00:00
|
|
|
if !ok {
|
2018-07-17 22:25:38 +00:00
|
|
|
return nValue, fmt.Sprintf("missing property %q", p.targetAttribute), 0
|
2017-03-09 23:20:53 +00:00
|
|
|
}
|
2018-07-26 22:14:27 +00:00
|
|
|
combinedUse := p.GetCombinedUseMap()
|
2023-05-17 14:25:00 +00:00
|
|
|
usedCount := combinedUse[targetPropertyValue]
|
|
|
|
return targetPropertyValue, "", usedCount
|
2018-07-26 22:14:27 +00:00
|
|
|
}
|
2017-03-09 23:20:53 +00:00
|
|
|
|
2018-07-26 22:14:27 +00:00
|
|
|
// GetCombinedUseMap counts how many times the property has been used by
|
|
|
|
// existing and proposed allocations. It also takes into account any stopped
|
|
|
|
// allocations
|
|
|
|
func (p *propertySet) GetCombinedUseMap() map[string]uint64 {
|
2022-08-17 16:26:34 +00:00
|
|
|
combinedUse := make(map[string]uint64, helper.Max(len(p.existingValues), len(p.proposedValues)))
|
2017-07-31 23:44:17 +00:00
|
|
|
for _, usedValues := range []map[string]uint64{p.existingValues, p.proposedValues} {
|
|
|
|
for propertyValue, usedCount := range usedValues {
|
2023-05-17 14:25:00 +00:00
|
|
|
targetPropertyValue := p.targetedPropertyValue(propertyValue)
|
|
|
|
combinedUse[targetPropertyValue] += usedCount
|
2017-03-09 23:20:53 +00:00
|
|
|
}
|
2017-07-31 23:44:17 +00:00
|
|
|
}
|
2017-03-09 23:20:53 +00:00
|
|
|
|
2017-07-31 23:44:17 +00:00
|
|
|
// Go through and discount the combined count when the value has been
|
|
|
|
// cleared by a proposed stop.
|
|
|
|
for propertyValue, clearedCount := range p.clearedValues {
|
2023-05-17 14:25:00 +00:00
|
|
|
targetPropertyValue := p.targetedPropertyValue(propertyValue)
|
|
|
|
combined, ok := combinedUse[targetPropertyValue]
|
2017-07-31 23:44:17 +00:00
|
|
|
if !ok {
|
2017-03-09 23:20:53 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2017-07-31 23:44:17 +00:00
|
|
|
// Don't clear below 0.
|
2017-08-01 21:18:52 +00:00
|
|
|
if combined >= clearedCount {
|
2023-05-17 14:25:00 +00:00
|
|
|
combinedUse[targetPropertyValue] = combined - clearedCount
|
2017-08-01 21:18:52 +00:00
|
|
|
} else {
|
2023-05-17 14:25:00 +00:00
|
|
|
combinedUse[targetPropertyValue] = 0
|
2017-08-01 21:18:52 +00:00
|
|
|
}
|
2017-07-31 23:44:17 +00:00
|
|
|
}
|
2018-07-26 22:14:27 +00:00
|
|
|
return combinedUse
|
2017-03-09 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
2017-03-10 00:12:43 +00:00
|
|
|
// filterAllocs filters a set of allocations to just be those that are running
|
|
|
|
// and if the property set is operation at a task group level, for allocations
|
|
|
|
// for that task group
|
2018-07-16 23:00:28 +00:00
|
|
|
func (p *propertySet) filterAllocs(allocs []*structs.Allocation, filterTerminal bool) []*structs.Allocation {
|
2017-03-10 00:12:43 +00:00
|
|
|
n := len(allocs)
|
|
|
|
for i := 0; i < n; i++ {
|
2017-03-10 06:03:10 +00:00
|
|
|
remove := false
|
|
|
|
if filterTerminal {
|
|
|
|
remove = allocs[i].TerminalStatus()
|
|
|
|
}
|
2017-03-10 00:12:43 +00:00
|
|
|
|
|
|
|
// If the constraint is on the task group filter the allocations to just
|
|
|
|
// those on the task group
|
2018-07-16 23:00:28 +00:00
|
|
|
if p.taskGroup != "" {
|
|
|
|
remove = remove || allocs[i].TaskGroup != p.taskGroup
|
2017-03-10 00:12:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if remove {
|
|
|
|
allocs[i], allocs[n-1] = allocs[n-1], nil
|
|
|
|
i--
|
|
|
|
n--
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return allocs[:n]
|
|
|
|
}
|
|
|
|
|
2017-03-09 23:20:53 +00:00
|
|
|
// buildNodeMap takes a list of allocations and returns a map of the nodes used
|
|
|
|
// by those allocations
|
2018-07-16 23:00:28 +00:00
|
|
|
func (p *propertySet) buildNodeMap(allocs []*structs.Allocation) (map[string]*structs.Node, error) {
|
2017-03-09 23:20:53 +00:00
|
|
|
// Get all the nodes that have been used by the allocs
|
|
|
|
nodes := make(map[string]*structs.Node)
|
|
|
|
ws := memdb.NewWatchSet()
|
|
|
|
for _, alloc := range allocs {
|
|
|
|
if _, ok := nodes[alloc.NodeID]; ok {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2018-07-16 23:00:28 +00:00
|
|
|
node, err := p.ctx.State().NodeByID(ws, alloc.NodeID)
|
2017-03-09 23:20:53 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("failed to lookup node ID %q: %v", alloc.NodeID, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
nodes[alloc.NodeID] = node
|
|
|
|
}
|
|
|
|
|
|
|
|
return nodes, nil
|
|
|
|
}
|
|
|
|
|
2017-03-10 05:36:27 +00:00
|
|
|
// populateProperties goes through all allocations and builds up the used
|
|
|
|
// properties from the nodes storing the results in the passed properties map.
|
2018-07-16 23:00:28 +00:00
|
|
|
func (p *propertySet) populateProperties(allocs []*structs.Allocation, nodes map[string]*structs.Node,
|
2017-07-31 23:44:17 +00:00
|
|
|
properties map[string]uint64) {
|
2017-03-10 05:36:27 +00:00
|
|
|
|
|
|
|
for _, alloc := range allocs {
|
2018-07-17 22:25:38 +00:00
|
|
|
nProperty, ok := getProperty(nodes[alloc.NodeID], p.targetAttribute)
|
2017-03-10 05:36:27 +00:00
|
|
|
if !ok {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2023-05-17 14:25:00 +00:00
|
|
|
targetPropertyValue := p.targetedPropertyValue(nProperty)
|
|
|
|
properties[targetPropertyValue]++
|
2017-03-10 05:36:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-09 23:20:53 +00:00
|
|
|
// getProperty is used to lookup the property value on the node
|
2017-03-10 05:36:27 +00:00
|
|
|
func getProperty(n *structs.Node, property string) (string, bool) {
|
2017-03-09 23:20:53 +00:00
|
|
|
if n == nil || property == "" {
|
|
|
|
return "", false
|
|
|
|
}
|
|
|
|
|
2022-07-12 21:40:25 +00:00
|
|
|
return resolveTarget(property, n)
|
2017-03-09 23:20:53 +00:00
|
|
|
}
|
2023-05-17 14:25:00 +00:00
|
|
|
|
|
|
|
// targetedPropertyValue transforms the property value to combine all implicit
|
|
|
|
// target values into a single wildcard placeholder so that we get accurate
|
|
|
|
// counts when we compare an explicitly-defined target against multiple implicit
|
|
|
|
// targets.
|
|
|
|
func (p *propertySet) targetedPropertyValue(propertyValue string) string {
|
|
|
|
if p.targetValues.Empty() || p.targetValues.Contains(propertyValue) {
|
|
|
|
return propertyValue
|
|
|
|
}
|
|
|
|
return "*"
|
|
|
|
}
|