Skip to content

Commit

Permalink
make Prometheus default; left and right helpers
Browse files Browse the repository at this point in the history
* Prometheus is now default for local playground as well

Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Jul 27, 2024
1 parent e2c6e0d commit 5dd9704
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion ais/backend/awsinv.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (s3bp *s3bp) initInventory(cloudBck *cmn.Bck, svc *s3.Client, ctx *core.Lso
if csv.oname == "" {
what := prefix
if ctx.ID == "" {
what = cos.Either(ctx.Name, aiss3.InvName)
what = cos.Left(ctx.Name, aiss3.InvName)
}
return nil, csv, manifest, http.StatusNotFound, cos.NewErrNotFound(cloudBck, invTag+":"+what)
}
Expand Down
2 changes: 1 addition & 1 deletion ais/backend/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ var (
var _ core.Backend = (*azbp)(nil)

func azProto() string {
return cos.Rather(azDefaultProto, os.Getenv(azProtoEnvVar))
return cos.Right(azDefaultProto, os.Getenv(azProtoEnvVar))
}

func azAccName() string { return os.Getenv(azAccNameEnvVar) }
Expand Down
2 changes: 1 addition & 1 deletion ais/prxauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func newAuthManager(config *cmn.Config) *authManager {
tkList: make(tkList),
revokedTokens: make(map[string]bool), // TODO: preallocate
version: 1,
secret: cos.Rather(config.Auth.Secret, os.Getenv(env.AuthN.SecretKey)), // environment override
secret: cos.Right(config.Auth.Secret, os.Getenv(env.AuthN.SecretKey)), // environment override
}
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/authn/mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func (m *mgr) roleList() ([]*authn.Role, error) {
// are not returned to a caller as it is not crucial.
func (m *mgr) createRolesForCluster(clu *authn.CluACL) {
for _, pr := range predefinedRoles {
suffix := cos.Either(clu.Alias, clu.ID)
suffix := cos.Left(clu.Alias, clu.ID)
uid := pr.prefix + "-" + suffix
rInfo := &authn.Role{}
if err := m.db.Get(rolesCollection, uid, rInfo); err == nil {
Expand Down Expand Up @@ -501,8 +501,8 @@ func initializeDB(driver kvdb.Driver) error {
}

// environment override
userName := cos.Rather(adminUserID, os.Getenv(env.AuthN.AdminUsername))
password := cos.Rather(adminUserPass, os.Getenv(env.AuthN.AdminPassword))
userName := cos.Right(adminUserID, os.Getenv(env.AuthN.AdminUsername))
password := cos.Right(adminUserPass, os.Getenv(env.AuthN.AdminPassword))

// Create the admin user
su := &authn.User{
Expand Down
4 changes: 2 additions & 2 deletions cmn/bck.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,8 @@ func (qbck QueryBcks) Equal(bck *Bck) bool { return Bck(qbck).Equal(bck) }
// NOTE: a named bucket with no provider is assumed to be ais://
func (qbck QueryBcks) Contains(other *Bck) bool {
if qbck.Name != "" {
other.Provider = cos.Rather(apc.AIS, other.Provider)
qbck.Provider = cos.Rather(other.Provider, qbck.Provider) //nolint:revive // if not set we match the expected
other.Provider = cos.Right(apc.AIS, other.Provider)
qbck.Provider = cos.Right(other.Provider, qbck.Provider) //nolint:revive // if not set we match the expected
return qbck.Equal(other)
}
ok := qbck.Provider == other.Provider || qbck.Provider == ""
Expand Down
20 changes: 10 additions & 10 deletions cmn/cos/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ func TrimLastB(s string, b byte) string {
return s
}

// return non-empty
func Either(lhs, rhs string) string {
if lhs != "" {
return lhs
// left if non-empty; otherwise right
func Left(left, right string) string {
if left != "" {
return left
}
return rhs
return right
}

// rightmost override if non-empty
func Rather(lhs /*e.g., default value*/, rhs string) string {
if rhs != "" {
return rhs
// right if non-empty; otherwise left
func Right(left, right string) string {
if right != "" {
return right
}
return lhs
return left
}

// (common use)
Expand Down
6 changes: 3 additions & 3 deletions cmn/objlist_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,11 @@ func MergeLso(lists []*LsoRes, lsmsg *apc.LsoMsg, maxSize int) *LsoRes {
}
// merge existing w/ new props
if !entry.IsPresent() && en.IsPresent() {
en.Version = cos.Either(en.Version, entry.Version)
en.Version = cos.Left(en.Version, entry.Version)
tmp[en.Name] = en
} else {
entry.Location = cos.Either(entry.Location, en.Location)
entry.Version = cos.Either(entry.Version, en.Version)
entry.Location = cos.Left(entry.Location, en.Location)
entry.Version = cos.Left(entry.Version, en.Version)
}
}
}
Expand Down
9 changes: 5 additions & 4 deletions deploy/dev/local/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# and so on. This rule holds for all AIS "applications" except `aisnode` itself.
# See https://github.com/NVIDIA/aistore/tree/main/cmn/fname for the most updated locations.
#
# NOTE: build tag `statsd` is the Local Playground's default; to enable Prometheus,
# remove `statsd` from the "... TAGS=statsd make ..." command below.
# NOTE: Prometheus is the Local Playground's default; use TAGS to specify `statsd` and/or
# any other non-default build tag.
#
############################################

Expand Down Expand Up @@ -171,10 +171,11 @@ parse_backend_providers

create_loopbacks

## NOTE: build tag `statsd` in the make command;
## NOTE: to enable StatsD instead of Prometheus, use build tag `statsd` in the make command, as follows:
## TAGS=statsd make ...
## see docs/metrics.md and docs/prometheus.md for more information.
##
if ! AIS_BACKEND_PROVIDERS=${AIS_BACKEND_PROVIDERS} TAGS=statsd make --no-print-directory -C ${AISTORE_PATH} node; then
if ! AIS_BACKEND_PROVIDERS=${AIS_BACKEND_PROVIDERS} make --no-print-directory -C ${AISTORE_PATH} node; then
exit_error "failed to compile 'aisnode' binary"
fi

Expand Down

0 comments on commit 5dd9704

Please sign in to comment.