diff --git a/ais/daemon.go b/ais/daemon.go index 1c2e62e799b..d77efe0a650 100644 --- a/ais/daemon.go +++ b/ais/daemon.go @@ -1,6 +1,6 @@ // Package ais provides core functionality for the AIStore object storage. /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package ais @@ -203,7 +203,7 @@ func initDaemon(version, buildTime string) cos.Runner { xreg.Init() // primary 'host[:port]' endpoint or URL from the environment - if daemon.EP = os.Getenv(env.AIS.PrimaryEP); daemon.EP != "" { + if daemon.EP = os.Getenv(env.AisPrimaryEP); daemon.EP != "" { scheme := "http" if config.Net.HTTP.UseHTTPS { scheme = "https" @@ -211,11 +211,11 @@ func initDaemon(version, buildTime string) cos.Runner { if strings.Contains(daemon.EP, "://") { u, err := url.Parse(daemon.EP) if err != nil { - cos.ExitLogf("invalid environment %s=%s: %v", env.AIS.PrimaryEP, daemon.EP, err) + cos.ExitLogf("invalid environment %s=%s: %v", env.AisPrimaryEP, daemon.EP, err) } if u.Path != "" && u.Path != "/" { cos.ExitLogf("invalid environment %s=%s (not expecting path %q)", - env.AIS.PrimaryEP, daemon.EP, u.Path) + env.AisPrimaryEP, daemon.EP, u.Path) } // reassemble and compare ustr := scheme + "://" + u.Hostname() diff --git a/ais/earlystart.go b/ais/earlystart.go index 4756f51c01f..b2ae095bf94 100644 --- a/ais/earlystart.go +++ b/ais/earlystart.go @@ -1,6 +1,6 @@ // Package ais provides core functionality for the AIStore object storage. /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package ais @@ -78,7 +78,7 @@ func (p *proxy) bootstrap() { case prim.isSmap: nlog.Infof("%s: assuming primary role _for now_ %+v", p, prim) case prim.isEP && isSelf != "": - nlog.Infof("%s: assuming primary role (and note that env %s=%s is redundant)", p, env.AIS.PrimaryEP, daemon.EP) + nlog.Infof("%s: assuming primary role (and note that env %s=%s is redundant)", p, env.AisPrimaryEP, daemon.EP) default: nlog.Infof("%s: assuming primary role as per: %+v", p, prim) } diff --git a/ais/htrun.go b/ais/htrun.go index 9df0c914f2e..c74f4a00c0f 100644 --- a/ais/htrun.go +++ b/ais/htrun.go @@ -1,6 +1,6 @@ // Package ais provides core functionality for the AIStore object storage. /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package ais @@ -1158,7 +1158,7 @@ func (h *htrun) statsAndStatus() (ds *stats.NodeStatus) { DeploymentType: deploymentType(), Version: daemon.version, BuildTime: daemon.buildTime, - K8sPodName: os.Getenv(env.AIS.K8sPod), + K8sPodName: os.Getenv(env.AisK8sPod), Status: h._status(smap), } return ds @@ -1176,7 +1176,7 @@ func (h *htrun) statsAndStatusV322() (ds *stats.NodeStatusV322) { DeploymentType: deploymentType(), Version: daemon.version, BuildTime: daemon.buildTime, - K8sPodName: os.Getenv(env.AIS.K8sPod), + K8sPodName: os.Getenv(env.AisK8sPod), Status: h._status(smap), } return ds diff --git a/ais/proxy.go b/ais/proxy.go index 0b6341ba352..7af7c7d6eab 100644 --- a/ais/proxy.go +++ b/ais/proxy.go @@ -1,6 +1,6 @@ // Package ais provides core functionality for the AIStore object storage. /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package ais @@ -99,7 +99,7 @@ func (p *proxy) init(config *cmn.Config) { cos.InitShortID(p.si.Digest()) - if network, err := _parseCIDR(env.AIS.LocalRedirectCIDR, ""); err != nil { + if network, err := _parseCIDR(env.AisLocalRedirectCIDR, ""); err != nil { cos.ExitLog(err) // FATAL } else { p.si.LocalNet = network diff --git a/ais/prxauth.go b/ais/prxauth.go index 4831c71e43e..306661986dc 100644 --- a/ais/prxauth.go +++ b/ais/prxauth.go @@ -1,6 +1,6 @@ // Package ais provides core functionality for the AIStore object storage. /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package ais @@ -49,7 +49,7 @@ func newAuthManager(config *cmn.Config) *authManager { tkList: make(tkList), revokedTokens: make(map[string]bool), // TODO: preallocate version: 1, - secret: cos.Right(config.Auth.Secret, os.Getenv(env.AuthN.SecretKey)), // environment override + secret: cos.Right(config.Auth.Secret, os.Getenv(env.AisAuthSecretKey)), // environment override } } diff --git a/ais/test/main_test.go b/ais/test/main_test.go index c0c29e3e2e5..a7c8ba64bd7 100644 --- a/ais/test/main_test.go +++ b/ais/test/main_test.go @@ -52,17 +52,17 @@ func waitForCluster() (primaryURL string, err error) { var ( proxyCnt, targetCnt, retry int ) - pc := os.Getenv(env.AIS.NumProxy) - tc := os.Getenv(env.AIS.NumTarget) + pc := os.Getenv(env.AisNumProxy) + tc := os.Getenv(env.AisNumTarget) if pc != "" || tc != "" { proxyCnt, err = strconv.Atoi(pc) if err != nil { - err = fmt.Errorf("error EnvVars: %s. err: %v", env.AIS.NumProxy, err) + err = fmt.Errorf("error EnvVars: %s. err: %v", env.AisNumProxy, err) return } targetCnt, err = strconv.Atoi(tc) if err != nil { - err = fmt.Errorf("error EnvVars: %s. err: %v", env.AIS.NumTarget, err) + err = fmt.Errorf("error EnvVars: %s. err: %v", env.AisNumTarget, err) return } } diff --git a/ais/test/s3/e2e_s3_test.go b/ais/test/s3/e2e_s3_test.go index b0e6f68d8d5..ac6e58c1da8 100644 --- a/ais/test/s3/e2e_s3_test.go +++ b/ais/test/s3/e2e_s3_test.go @@ -1,6 +1,6 @@ // Package s3_integration provides tests of compatibility with AWS S3 /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package s3_test @@ -34,7 +34,7 @@ var _ = Describe("E2E AWS Compatibility Tests", func() { params string ) - if value := os.Getenv(env.AIS.UseHTTPS); cos.IsParseBool(value) { + if value := os.Getenv(env.AisUseHTTPS); cos.IsParseBool(value) { host = "https://localhost:8080/s3" params = "--no-check-certificate" } else { diff --git a/ais/utils.go b/ais/utils.go index a7a780d1ddd..d063bb38e19 100644 --- a/ais/utils.go +++ b/ais/utils.go @@ -1,6 +1,6 @@ // Package ais provides core functionality for the AIStore object storage. /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package ais @@ -208,11 +208,11 @@ func _localIP(addrList []*localIPv4Info) (ip net.IP, _ error) { // NOTE: // - try using environment to eliminate ambiguity - // - env.AIS.PubIPv4CIDR ("AIS_PUBLIC_IP_CIDR") takes precedence + // - env.AisPubIPv4CIDR ("AIS_PUBLIC_IP_CIDR") takes precedence var ( selected = -1 parsed net.IP - network, err = _parseCIDR(env.AIS.LocalRedirectCIDR, env.AIS.PubIPv4CIDR) + network, err = _parseCIDR(env.AisLocalRedirectCIDR, env.AisPubIPv4CIDR) ) if err != nil { return nil, err diff --git a/api/authn/loadtoken.go b/api/authn/loadtoken.go index 0c8a8a523ce..e75c778242d 100644 --- a/api/authn/loadtoken.go +++ b/api/authn/loadtoken.go @@ -1,6 +1,6 @@ // Package authn provides AuthN API over HTTP(S) /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package authn @@ -20,7 +20,7 @@ import ( func LoadToken(tokenFile string) (string /*token value*/, error) { // token value directly from environment if tokenFile == "" { - if tokenEnv := os.Getenv(env.AuthN.Token); tokenEnv != "" { + if tokenEnv := os.Getenv(env.AisAuthToken); tokenEnv != "" { return tokenEnv, nil } } @@ -29,7 +29,7 @@ func LoadToken(tokenFile string) (string /*token value*/, error) { // token filename from environment if tokenFile == "" { - tokenFile = os.Getenv(env.AuthN.TokenFile) + tokenFile = os.Getenv(env.AisAuthTokenFile) } // or, default token filename diff --git a/api/env/ais.go b/api/env/ais.go index ee7ca517499..05a04687392 100644 --- a/api/env/ais.go +++ b/api/env/ais.go @@ -1,95 +1,62 @@ // Package env contains environment variables /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved. */ package env -// NOTE not included: +// not included: // - "AIS_READ_HEADER_TIMEOUT" // - "AIS_DAEMON_ID" // - "AIS_HOST_IP", "AIS_HOST_PORT" - local playground (target only) -// - "AIS_TARGET_URL" - ETL -// -// See also: +// - "AIS_TARGET_URL" - ETL +// see also: // - docs/environment-vars.md -var AIS = struct { +const ( // endpoint: client | primary startup - Endpoint string - PrimaryEP string + + AisEndpoint = "AIS_ENDPOINT" // the way to designate primary when cluster's starting up + AisPrimaryEP = "AIS_PRIMARY_EP" // networking: two CIDR masks - LocalRedirectCIDR string - PubIPv4CIDR string + // 1. differentiate local (same CIDR) clients for faster HTTP redirect + // 2. at node startup: when present with multiple choices, select one matching local unicast IP + // to use it as node's public interface + AisLocalRedirectCIDR = "AIS_CLUSTER_CIDR" + AisPubIPv4CIDR = "AIS_PUBLIC_IP_CIDR" // // HTTPS // for details and background, see: https://github.com/NVIDIA/aistore/blob/main/docs/environment-vars.md#https // - UseHTTPS string - // TLS: client side - Certificate string - CertKey string - ClientCA string - SkipVerifyCrt string - // TLS: server (aistore, AuthN) side (NOTE comment below) - - // tests, CI - NumTarget string - NumProxy string - - // K8s - K8sPod string - K8sNode string - K8sNamespace string - K8sServiceName string - K8sPublicHostname string - K8sClusterDomain string - K8sHostNetwork string - K8sEnableExternalAccess string -}{ - // the way to designate primary when cluster's starting up - Endpoint: "AIS_ENDPOINT", - PrimaryEP: "AIS_PRIMARY_EP", - - // two CIDRs, respectively: - // 1. differentiate local (same CIDR) clients for faster HTTP redirect - // 2. at node startup: when present with multiple choices, select one matching local unicast IP - // to use it as node's public interface - LocalRedirectCIDR: "AIS_CLUSTER_CIDR", - PubIPv4CIDR: "AIS_PUBLIC_IP_CIDR", // false: HTTP transport, with all the TLS config (below) ignored // true: HTTPS/TLS // for details and background, see: https://github.com/NVIDIA/aistore/blob/main/docs/environment-vars.md#https - UseHTTPS: "AIS_USE_HTTPS", // cluster config: "net.http.use_https" + AisUseHTTPS = "AIS_USE_HTTPS" // TLS: client side - Certificate: "AIS_CRT", - CertKey: "AIS_CRT_KEY", - ClientCA: "AIS_CLIENT_CA", - - // TLS: server (aistore, AuthN) side - // "AIS_SERVER_CRT" - TLS certificate (pathname) - // "AIS_SERVER_KEY" - private key (ditto) + AisClientCert = "AIS_CRT" + AisClientCertKey = "AIS_CRT_KEY" + AisClientCA = "AIS_CLIENT_CA" - // TLS: common - SkipVerifyCrt: "AIS_SKIP_VERIFY_CRT", // cluster config: "net.http.skip_verify" + // client and dev deployment; see also cluster config "net.http.skip_verify" + AisSkipVerifyCrt = "AIS_SKIP_VERIFY_CRT" - // variables used in tests and CI - NumTarget: "NUM_TARGET", - NumProxy: "NUM_PROXY", + // tests and CI + AisNumTarget = "NUM_TARGET" + AisNumProxy = "NUM_PROXY" // via ais-k8s repo // see also: // * https://github.com/NVIDIA/ais-k8s/blob/main/operator/pkg/resources/cmn/env.go // * docs/environment-vars.md - K8sPod: "MY_POD", - K8sNode: "MY_NODE", - K8sNamespace: "K8S_NS", - K8sServiceName: "MY_SERVICE", - K8sPublicHostname: "AIS_PUBLIC_HOSTNAME", - K8sClusterDomain: "AIS_K8S_CLUSTER_DOMAIN", - K8sHostNetwork: "HOST_NETWORK", - K8sEnableExternalAccess: "ENABLE_EXTERNAL_ACCESS", -} + AisK8sPod = "MY_POD" + AisK8sNode = "MY_NODE" + AisK8sNamespace = "K8S_NS" + AisK8sServiceName = "MY_SERVICE" + AisK8sPublicHostname = "AIS_PUBLIC_HOSTNAME" + AisK8sClusterDomain = "AIS_K8S_CLUSTER_DOMAIN" + AisK8sHostNetwork = "HOST_NETWORK" + AisK8sEnableExternalAccess = "ENABLE_EXTERNAL_ACCESS" +) diff --git a/api/env/authn.go b/api/env/authn.go index d01a48cc554..1d957aca2e2 100644 --- a/api/env/authn.go +++ b/api/env/authn.go @@ -1,44 +1,27 @@ // Package env contains environment variables /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved. */ package env -// authn environment variables +// AuthN environment names // see also: docs/environment-vars.md -var ( - AuthN = struct { - Enabled string - URL string - TokenFile string - Token string - ConfDir string - LogDir string - LogLevel string - Port string - TTL string - UseHTTPS string - ServerCrt string - ServerKey string - AdminPassword string - AdminUsername string - SecretKey string - }{ - Enabled: "AIS_AUTHN_ENABLED", - URL: "AIS_AUTHN_URL", - TokenFile: "AIS_AUTHN_TOKEN_FILE", // fully qualified - Token: "AIS_AUTHN_TOKEN", // Only the JWT token itself (excluding the file and JSON) - ConfDir: "AIS_AUTHN_CONF_DIR", // contains AuthN config and tokens DB - LogDir: "AIS_AUTHN_LOG_DIR", - LogLevel: "AIS_AUTHN_LOG_LEVEL", - Port: "AIS_AUTHN_PORT", - TTL: "AIS_AUTHN_TTL", - UseHTTPS: "AIS_AUTHN_USE_HTTPS", - ServerCrt: "AIS_SERVER_CRT", - ServerKey: "AIS_SERVER_KEY", - SecretKey: "AIS_AUTHN_SECRET_KEY", - AdminUsername: "AIS_AUTHN_SU_NAME", - AdminPassword: "AIS_AUTHN_SU_PASS", - } +//nolint:gosec // false positive G101 +const ( + AisAuthEnabled = "AIS_AUTHN_ENABLED" + AisAuthURL = "AIS_AUTHN_URL" + AisAuthTokenFile = "AIS_AUTHN_TOKEN_FILE" // fully qualified + AisAuthToken = "AIS_AUTHN_TOKEN" // Only the JWT token itself (excluding the file and JSON) + AisAuthConfDir = "AIS_AUTHN_CONF_DIR" // contains AuthN config and tokens DB + AisAuthLogDir = "AIS_AUTHN_LOG_DIR" + AisAuthLogLevel = "AIS_AUTHN_LOG_LEVEL" + AisAuthPort = "AIS_AUTHN_PORT" + AisAuthTTL = "AIS_AUTHN_TTL" + AisAuthUseHTTPS = "AIS_AUTHN_USE_HTTPS" + AisAuthServerCrt = "AIS_SERVER_CRT" + AisAuthServerKey = "AIS_SERVER_KEY" + AisAuthSecretKey = "AIS_AUTHN_SECRET_KEY" + AisAuthAdminUsername = "AIS_AUTHN_SU_NAME" + AisAuthAdminPassword = "AIS_AUTHN_SU_PASS" ) diff --git a/bench/tools/aisloader/run.go b/bench/tools/aisloader/run.go index 205921e8f2e..05e7127c79c 100644 --- a/bench/tools/aisloader/run.go +++ b/bench/tools/aisloader/run.go @@ -899,11 +899,11 @@ func _init(p *params) (err error) { aisEndpoint := "http://" + ip + ":" + port // see also: tlsArgs - envEndpoint = os.Getenv(env.AIS.Endpoint) + envEndpoint = os.Getenv(env.AisEndpoint) if envEndpoint != "" { if ip != "" && ip != defaultClusterIP && ip != defaultClusterIPv4 { return fmt.Errorf("'%s=%s' environment and '--ip=%s' command-line are mutually exclusive", - env.AIS.Endpoint, envEndpoint, ip) + env.AisEndpoint, envEndpoint, ip) } aisEndpoint = envEndpoint } diff --git a/cmd/aisinit/config.go b/cmd/aisinit/config.go index ffa6e166e83..ccda99723ae 100644 --- a/cmd/aisinit/config.go +++ b/cmd/aisinit/config.go @@ -1,6 +1,6 @@ // Package main contains logic for the aisinit container /* - * Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2024-2025, NVIDIA CORPORATION. All rights reserved. */ package main diff --git a/cmd/aisinit/main.go b/cmd/aisinit/main.go index d7aa5da0ce8..7767247e682 100644 --- a/cmd/aisinit/main.go +++ b/cmd/aisinit/main.go @@ -123,11 +123,11 @@ func main() { err = json.Unmarshal(confBytes, &localConf) failOnError(err) - namespace := getRequiredEnv(env.AIS.K8sNamespace) - serviceName := getRequiredEnv(env.AIS.K8sServiceName) - podName := getRequiredEnv(env.AIS.K8sPod) - clusterDomain := getOrDefaultEnv(env.AIS.K8sClusterDomain, defaultClusterDomain) - publicHostName := getOrDefaultEnv(env.AIS.K8sPublicHostname, "") + namespace := getRequiredEnv(env.AisK8sNamespace) + serviceName := getRequiredEnv(env.AisK8sServiceName) + podName := getRequiredEnv(env.AisK8sPod) + clusterDomain := getOrDefaultEnv(env.AisK8sClusterDomain, defaultClusterDomain) + publicHostName := getOrDefaultEnv(env.AisK8sPublicHostname, "") podDNS := fmt.Sprintf("%s.%s.%s.svc.%s", podName, serviceName, namespace, clusterDomain) localConf.HostNet.HostnameIntraControl = podDNS @@ -135,14 +135,14 @@ func main() { localConf.HostNet.Hostname = publicHostName if role == aisapc.Target { - useHostNetwork, err := cos.ParseBool(getOrDefaultEnv(env.AIS.K8sHostNetwork, "false")) + useHostNetwork, err := cos.ParseBool(getOrDefaultEnv(env.AisK8sHostNetwork, "false")) failOnError(err) if useHostNetwork { localConf.HostNet.HostnameIntraData = "" localConf.HostNet.Hostname = "" } - useExternalLB, err := cos.ParseBool(getOrDefaultEnv(env.AIS.K8sEnableExternalAccess, "false")) + useExternalLB, err := cos.ParseBool(getOrDefaultEnv(env.AisK8sEnableExternalAccess, "false")) failOnError(err) if useExternalLB { localConf.HostNet.Hostname = fetchExternalIP(podName, namespace) diff --git a/cmd/authn/hserv.go b/cmd/authn/hserv.go index dd0b1bfe567..f9ab52a4b82 100644 --- a/cmd/authn/hserv.go +++ b/cmd/authn/hserv.go @@ -1,6 +1,6 @@ // Package authn is authentication server for AIStore. /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package main @@ -55,7 +55,7 @@ func (h *hserv) Run() error { ) // Retrieve and set the port - portStr = os.Getenv(env.AuthN.Port) + portStr = os.Getenv(env.AisAuthPort) if portStr == "" { portStr = fmt.Sprintf(":%d", Conf.Net.HTTP.Port) } else { @@ -74,12 +74,12 @@ func (h *hserv) Run() error { } // Retrieve and set HTTPS configuration with environment variables taking precedence - useHTTPS, err = cos.IsParseEnvBoolOrDefault(env.AuthN.UseHTTPS, Conf.Net.HTTP.UseHTTPS) + useHTTPS, err = cos.IsParseEnvBoolOrDefault(env.AisAuthUseHTTPS, Conf.Net.HTTP.UseHTTPS) if err != nil { - nlog.Errorf("Failed to parse %s: %v. Defaulting to false", env.AuthN.UseHTTPS, err) + nlog.Errorf("Failed to parse %s: %v. Defaulting to false", env.AisAuthUseHTTPS, err) } - serverCert = cos.GetEnvOrDefault(env.AuthN.ServerCrt, Conf.Net.HTTP.Certificate) - serverKey = cos.GetEnvOrDefault(env.AuthN.ServerKey, Conf.Net.HTTP.Key) + serverCert = cos.GetEnvOrDefault(env.AisAuthServerCrt, Conf.Net.HTTP.Certificate) + serverKey = cos.GetEnvOrDefault(env.AisAuthServerKey, Conf.Net.HTTP.Key) // Start the appropriate server based on the configuration if useHTTPS { diff --git a/cmd/authn/main.go b/cmd/authn/main.go index ae994abd2f4..f8c5607857d 100644 --- a/cmd/authn/main.go +++ b/cmd/authn/main.go @@ -1,6 +1,6 @@ // Package authn is authentication server for AIStore. /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package main @@ -60,18 +60,18 @@ func main() { configDir = confDirFlag.Value.String() } if configDir == "" { - configDir = os.Getenv(env.AuthN.ConfDir) + configDir = os.Getenv(env.AisAuthConfDir) } if configDir == "" { cos.ExitLogf("Missing %s configuration file (to specify, use '-%s' option or '%s' environment)", - svcName, confDirFlag.Name, env.AuthN.ConfDir) + svcName, confDirFlag.Name, env.AisAuthConfDir) } configPath = filepath.Join(configDir, fname.AuthNConfig) if _, err := jsp.LoadMeta(configPath, Conf); err != nil { cos.ExitLogf("Failed to load configuration from %q: %v", configPath, err) } Conf.Init() - if val := os.Getenv(env.AuthN.SecretKey); val != "" { + if val := os.Getenv(env.AisAuthSecretKey); val != "" { Conf.SetSecret(&val) } if err := updateLogOptions(); err != nil { @@ -106,7 +106,7 @@ func main() { } func updateLogOptions() error { - logDir := cos.GetEnvOrDefault(env.AuthN.LogDir, Conf.Log.Dir) + logDir := cos.GetEnvOrDefault(env.AisAuthLogDir, Conf.Log.Dir) if err := cos.CreateDir(logDir); err != nil { return fmt.Errorf("failed to create log dir %q, err: %v", logDir, err) } diff --git a/cmd/authn/mgr.go b/cmd/authn/mgr.go index 139b740dc41..4d036e9ff71 100644 --- a/cmd/authn/mgr.go +++ b/cmd/authn/mgr.go @@ -1,6 +1,6 @@ // Package authn is authentication server for AIStore. /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package main @@ -501,8 +501,8 @@ func initializeDB(driver kvdb.Driver) error { } // environment override - userName := cos.Right(adminUserID, os.Getenv(env.AuthN.AdminUsername)) - password := cos.Right(adminUserPass, os.Getenv(env.AuthN.AdminPassword)) + userName := cos.Right(adminUserID, os.Getenv(env.AisAuthAdminUsername)) + password := cos.Right(adminUserPass, os.Getenv(env.AisAuthAdminPassword)) // Create the admin user su := &authn.User{ diff --git a/cmd/cli/cli/auth_hdlr.go b/cmd/cli/cli/auth_hdlr.go index 789af4b4dc9..bada5902273 100644 --- a/cmd/cli/cli/auth_hdlr.go +++ b/cmd/cli/cli/auth_hdlr.go @@ -1,7 +1,7 @@ // Package cli provides easy-to-use commands to manage, monitor, and utilize AIS clusters. // This file handles commands that create entities in the cluster. /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package cli @@ -219,13 +219,13 @@ var ( func wrapAuthN(f cli.ActionFunc) cli.ActionFunc { return func(c *cli.Context) error { if authParams.Client == nil { - return errors.New(env.AuthN.URL + " is not set") + return errors.New(env.AisAuthURL + " is not set") } err := f(c) if err != nil { if msg, unreachable := isUnreachableError(err); unreachable { err = fmt.Errorf(authnUnreachable, authParams.URL+" (detailed error: "+msg+")", - env.AuthN.URL) + env.AisAuthURL) } } return err @@ -242,7 +242,7 @@ func readMasked(c *cli.Context, prompt string) string { } func cliAuthnURL(cfg *config.Config) string { - return cos.Right(cfg.Auth.URL, os.Getenv(env.AuthN.URL)) + return cos.Right(cfg.Auth.URL, os.Getenv(env.AisAuthURL)) } func lookupClusterID(cluID string) (string, error) { @@ -767,7 +767,7 @@ func setAuthConfigHandler(c *cli.Context) (err error) { func getTokenFilePath(c *cli.Context) (string, error) { tokenFilePath := parseStrFlag(c, tokenFileFlag) if tokenFilePath == "" { - tokenFilePath = os.Getenv(env.AuthN.TokenFile) + tokenFilePath = os.Getenv(env.AisAuthTokenFile) } if tokenFilePath == "" { tokenFilePath = filepath.Join(config.ConfigDir, fname.Token) diff --git a/cmd/cli/cli/err.go b/cmd/cli/cli/err.go index 2eab63b80a4..012cb21b059 100644 --- a/cmd/cli/cli/err.go +++ b/cmd/cli/cli/err.go @@ -1,7 +1,7 @@ // Package cli provides easy-to-use commands to manage, monitor, and utilize AIS clusters. // This file contains error handlers and utilities. /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package cli @@ -362,7 +362,7 @@ func formatErr(err error) error { errmsg := fmt.Sprintf("AIStore cannot be reached at %s\n", clusterURL) errmsg += fmt.Sprintf("Make sure that environment '%s' has the address of any AIS gateway (proxy).\n"+ "For defaults, see CLI config at %s or run `ais show config cli`.", - env.AIS.Endpoint, config.Path()) + env.AisEndpoint, config.Path()) return redErr(errors.New(errmsg)) } switch err := err.(type) { diff --git a/cmd/cli/cli/init.go b/cmd/cli/cli/init.go index 142f422854b..b3e9273cff4 100644 --- a/cmd/cli/cli/init.go +++ b/cmd/cli/cli/init.go @@ -1,6 +1,6 @@ // Package cli provides easy-to-use commands to manage, monitor, and utilize AIS clusters. /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package cli @@ -30,11 +30,11 @@ func Init(args []string) (err error) { k8sDetected = detectK8s() // auth - token := os.Getenv(env.AuthN.Token) - tokenFile := os.Getenv(env.AuthN.TokenFile) + token := os.Getenv(env.AisAuthToken) + tokenFile := os.Getenv(env.AisAuthTokenFile) if token != "" && tokenFile != "" { - fmt.Fprintf(os.Stderr, "Warning: both `%s` and `%s` are set, using `%s`\n", env.AuthN.Token, env.AuthN.TokenFile, env.AuthN.Token) + fmt.Fprintf(os.Stderr, "Warning: both `%s` and `%s` are set, using `%s`\n", env.AisAuthToken, env.AisAuthTokenFile, env.AisAuthToken) } loggedUserToken, _ = authn.LoadToken("") // No error handling as token might not be needed @@ -99,7 +99,7 @@ func Init(args []string) (err error) { // 3. Docker default; if not present: // 4. Default as cfg.Cluster.DefaultAISHost func _clusterURL(cfg *config.Config) string { - if envURL := os.Getenv(env.AIS.Endpoint); envURL != "" { + if envURL := os.Getenv(env.AisEndpoint); envURL != "" { return envURL } if cfg.Cluster.URL != "" { diff --git a/cmd/cli/cli/smap.go b/cmd/cli/cli/smap.go index 2dde08248e3..3844b298bb2 100644 --- a/cmd/cli/cli/smap.go +++ b/cmd/cli/cli/smap.go @@ -1,7 +1,7 @@ // Package cli provides easy-to-use commands to manage, monitor, and utilize AIS clusters. // This file contains util functions and types. /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package cli @@ -38,8 +38,8 @@ func getClusterMap(c *cli.Context) (*meta.Smap, error) { curSmap = smap if smap.Primary.PubNet.URL != apiBP.URL { if cliConfVerbose() { - what := env.AIS.Endpoint - if os.Getenv(env.AIS.Endpoint) == "" { + what := env.AisEndpoint + if os.Getenv(env.AisEndpoint) == "" { what = "CLI config URL" } warn := fmt.Sprintf("changing %s from %q to %q", what, apiBP.URL, smap.Primary.PubNet.URL) diff --git a/cmd/cli/config/config.go b/cmd/cli/config/config.go index b352c667d1c..af078638a8c 100644 --- a/cmd/cli/config/config.go +++ b/cmd/cli/config/config.go @@ -1,6 +1,6 @@ // Package config provides types and functions to configure AIS CLI. /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package config @@ -98,7 +98,7 @@ func init() { // $HOME/.config/ais/cli ConfigDir = cos.HomeConfigDir(fname.HomeCLI) proto := "http" - if value := os.Getenv(env.AIS.UseHTTPS); cos.IsParseBool(value) { + if value := os.Getenv(env.AisUseHTTPS); cos.IsParseBool(value) { proto = "https" } aisURL := fmt.Sprintf(urlFmt, proto, defaultAISIP, defaultAISPort) @@ -107,7 +107,7 @@ func init() { URL: aisURL, DefaultAISHost: aisURL, DefaultDockerHost: fmt.Sprintf(urlFmt, proto, defaultDockerIP, defaultAISPort), - SkipVerifyCrt: cos.IsParseBool(os.Getenv(env.AIS.SkipVerifyCrt)), + SkipVerifyCrt: cos.IsParseBool(os.Getenv(env.AisSkipVerifyCrt)), }, Timeout: TimeoutConfig{ TCPTimeoutStr: "60s", diff --git a/cmd/cli/go.mod b/cmd/cli/go.mod index bddfebd30da..0e128cd96c4 100644 --- a/cmd/cli/go.mod +++ b/cmd/cli/go.mod @@ -3,7 +3,7 @@ module github.com/NVIDIA/aistore/cmd/cli go 1.23.2 require ( - github.com/NVIDIA/aistore v1.3.26-0.20250104000959-257daaf15171 + github.com/NVIDIA/aistore v1.3.26-0.20250104164615-22715625e065 github.com/fatih/color v1.18.0 github.com/json-iterator/go v1.1.12 github.com/onsi/ginkgo/v2 v2.21.0 diff --git a/cmd/cli/go.sum b/cmd/cli/go.sum index ee0de4eb81c..d2f4acf99b1 100644 --- a/cmd/cli/go.sum +++ b/cmd/cli/go.sum @@ -1,7 +1,7 @@ code.cloudfoundry.org/bytefmt v0.0.0-20190710193110-1eb035ffe2b6/go.mod h1:wN/zk7mhREp/oviagqUXY3EwuHhWyOvAdsn5Y4CzOrc= github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= -github.com/NVIDIA/aistore v1.3.26-0.20250104000959-257daaf15171 h1:PyKm6G564xu62j1Wo9aTwQaKQa2UxZbrlNfKW3zQfYI= -github.com/NVIDIA/aistore v1.3.26-0.20250104000959-257daaf15171/go.mod h1:mjhY9OGIZULaC79+iRfzEUvUZw7aIWklJ8um321QVpw= +github.com/NVIDIA/aistore v1.3.26-0.20250104164615-22715625e065 h1:rdNRrRxOpjQYkVCHxY0cP8HKT+PTxujZcK1jrbCbwTM= +github.com/NVIDIA/aistore v1.3.26-0.20250104164615-22715625e065/go.mod h1:mjhY9OGIZULaC79+iRfzEUvUZw7aIWklJ8um321QVpw= github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8= github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA= diff --git a/cmn/client.go b/cmn/client.go index 446458f7487..adf771fc1db 100644 --- a/cmn/client.go +++ b/cmn/client.go @@ -1,7 +1,7 @@ // Package cmn provides common constants, types, and utilities for AIS clients // and AIStore. /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package cmn @@ -173,18 +173,18 @@ func NewClientTLS(cargs TransportArgs, sargs TLSArgs, intra bool) *http.Client { // EnvToTLS usage is limited to aisloader and tools // NOTE that embedded intra-cluster clients utilize a similar method: `HTTPConf.ToTLS` func EnvToTLS(sargs *TLSArgs) { - if s := os.Getenv(env.AIS.Certificate); s != "" { + if s := os.Getenv(env.AisClientCert); s != "" { sargs.Certificate = s } - if s := os.Getenv(env.AIS.CertKey); s != "" { + if s := os.Getenv(env.AisClientCertKey); s != "" { sargs.Key = s } - if s := os.Getenv(env.AIS.ClientCA); s != "" { + if s := os.Getenv(env.AisClientCA); s != "" { // XXX This should be RootCA for clients // https://pkg.go.dev/crypto/tls sargs.ClientCA = s } - if s := os.Getenv(env.AIS.SkipVerifyCrt); s != "" { + if s := os.Getenv(env.AisSkipVerifyCrt); s != "" { sargs.SkipVerify = cos.IsParseBool(s) } } diff --git a/cmn/k8s/client.go b/cmn/k8s/client.go index d4355002453..84f7e682ece 100644 --- a/cmn/k8s/client.go +++ b/cmn/k8s/client.go @@ -1,6 +1,6 @@ // Package k8s: initialization, client, and misc. helpers /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package k8s @@ -73,7 +73,7 @@ func _initClient() { // - https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ func _namespace() (namespace string) { // production - if namespace = os.Getenv(env.AIS.K8sNamespace); namespace != "" { + if namespace = os.Getenv(env.AisK8sNamespace); namespace != "" { debug.Func(func() { ns := os.Getenv(defaultNamespaceEnv) debug.Assertf(ns == "" || ns == namespace, "%q vs %q", ns, namespace) diff --git a/cmn/k8s/k8s.go b/cmn/k8s/k8s.go index 0b5e7d664fb..d8563cb1a28 100644 --- a/cmn/k8s/k8s.go +++ b/cmn/k8s/k8s.go @@ -1,6 +1,6 @@ // Package k8s: initialization, client, and misc. helpers /* - * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018=2025, NVIDIA CORPORATION. All rights reserved. */ package k8s @@ -45,8 +45,8 @@ func Init() { var ( pod *v1.Pod - podName = os.Getenv(env.AIS.K8sPod) - nodeName = os.Getenv(env.AIS.K8sNode) + podName = os.Getenv(env.AisK8sPod) + nodeName = os.Getenv(env.AisK8sNode) ) if podName != "" { debug.Func(func() { @@ -63,7 +63,7 @@ func Init() { // If the Pod is not set but the Node is, we should continue checking. goto checkNode } - nlog.Infof("Env %q and %q are not set => %s", env.AIS.K8sNode, env.AIS.K8sPod, nonK8s) + nlog.Infof("Env %q and %q are not set => %s", env.AisK8sNode, env.AisK8sPod, nonK8s) return } diff --git a/tools/init.go b/tools/init.go index 3826260820c..afaee5d64bf 100644 --- a/tools/init.go +++ b/tools/init.go @@ -92,13 +92,13 @@ var ( // NOTE: // With no access to cluster configuration the tests -// currently simply detect protocol type by the env.AIS.Endpoint (proxy's) URL. +// currently simply detect protocol type by the env.AisEndpoint (proxy's) URL. // Certificate check and other TLS is always disabled. func init() { gctx.Log = tlog.Logf - if cos.IsHTTPS(os.Getenv(env.AIS.Endpoint)) { + if cos.IsHTTPS(os.Getenv(env.AisEndpoint)) { // fill-in from env cmn.EnvToTLS(&tlsArgs) gctx.Client = cmn.NewClientTLS(transportArgs, tlsArgs, false /*intra-cluster*/) @@ -151,7 +151,7 @@ func InitLocalCluster() { // This is needed for testing on Kubernetes if we want to run 'make test-XXX' // Many of the other packages do not accept the 'url' flag - if cliAISURL := os.Getenv(env.AIS.Endpoint); cliAISURL != "" { + if cliAISURL := os.Getenv(env.AisEndpoint); cliAISURL != "" { if !strings.HasPrefix(cliAISURL, "http") { cliAISURL = "http://" + cliAISURL } @@ -168,12 +168,12 @@ func InitLocalCluster() { switch { case strings.Contains(err.Error(), "token"): fmt.Printf("Hint: make sure to provide access token via %s environment or the default config location\n", - env.AuthN.TokenFile) + env.AisAuthTokenFile) case strings.Contains(err.Error(), "unreachable"): fmt.Printf("Hint: make sure that cluster is running and/or specify its endpoint via %s environment\n", - env.AIS.Endpoint) + env.AisEndpoint) default: - fmt.Printf("Hint: check api/env/*.go environment and, in particular %s=%s\n", env.AIS.Endpoint, os.Getenv(env.AIS.Endpoint)) + fmt.Printf("Hint: check api/env/*.go environment and, in particular %s=%s\n", env.AisEndpoint, os.Getenv(env.AisEndpoint)) if len(envVars) > 0 { fmt.Println("Docker Environment:") for k, v := range envVars { diff --git a/tools/node.go b/tools/node.go index 6affe258c6c..36a05480d0b 100644 --- a/tools/node.go +++ b/tools/node.go @@ -440,7 +440,7 @@ func startNode(cmd *RestoreCmd, asPrimary bool) (int, error) { if asPrimary { // Sets the environment variable to start as primary environ := os.Environ() - environ = append(environ, env.AIS.PrimaryEP+"="+cmd.Node.PubNet.URL) + environ = append(environ, env.AisPrimaryEP+"="+cmd.Node.PubNet.URL) ncmd.Env = environ } if err := ncmd.Start(); err != nil { diff --git a/tracing/tracing_on.go b/tracing/tracing_on.go index ef6e46a375e..738a91703b0 100644 --- a/tracing/tracing_on.go +++ b/tracing/tracing_on.go @@ -67,7 +67,7 @@ func newResource(conf *cmn.TracingConf, snode *meta.Snode, version string) *reso semconv.ServiceNameKey.String(serviceName), attribute.String("version", version), attribute.String("daemonID", snode.DaeID), - attribute.String("pod", os.Getenv(env.AIS.K8sPod)), + attribute.String("pod", os.Getenv(env.AisK8sPod)), } for k, v := range conf.ExtraAttributes { attrs = append(attrs, attribute.String(k, v))