From af1944f28ddc5380861e6e88681045c525dc0eda Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 10 Jun 2022 09:59:15 -0700 Subject: [PATCH] support reading systemctl config automatically on baremetal setups (#15066) this allows for customers to use `mc admin service restart` directly even when performing RPM, DEB upgrades. Upon such 'restart' after upgrade MinIO will re-read the /etc/default/minio for any newer environment variables. As long as `MINIO_CONFIG_ENV_FILE=/etc/default/minio` is set, this is honored. --- README.md | 10 +++++----- cmd/common-main.go | 5 +---- cmd/server-main.go | 13 ++++++++++--- internal/config/constants.go | 1 + 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index be9790a0b..14cab4e61 100644 --- a/README.md +++ b/README.md @@ -236,16 +236,16 @@ Upgrades require zero downtime in MinIO, all upgrades are non-disruptive, all tr mc admin update ``` -- For deployments without external internet access (e.g. airgapped environments), download the binary from and replace the existing MinIO binary let's say for example `/opt/bin/minio`, apply executable permissions `chmod +x /opt/bin/minio` and do `mc admin service restart alias/`. +- For deployments without external internet access (e.g. airgapped environments), download the binary from and replace the existing MinIO binary let's say for example `/opt/bin/minio`, apply executable permissions `chmod +x /opt/bin/minio` and proceed to perform `mc admin service restart alias/`. -- For installations using Systemd MinIO service, upgrade via RPM/DEB packages **parallelly** on all servers or replace the binary lets say `/opt/bin/minio` on all nodes, apply executable permissions `chmod +x /opt/bin/minio`. Proceed to perform `systemctl restart minio` across all nodes in **parallel**. +- For installations using Systemd MinIO service, upgrade via RPM/DEB packages **parallelly** on all servers or replace the binary lets say `/opt/bin/minio` on all nodes, apply executable permissions `chmod +x /opt/bin/minio` and process to perform `mc admin service restart alias/`. ### Upgrade Checklist - Test all upgrades in a lower environment (DEV, QA, UAT) before applying to production. Performing blind upgrades in production environments carries significant risk. -- Read the release notes for the targeted MinIO release *before* performing any installation, there is no forced requirement to upgrade to latest releases every week. If it has a bug fix you are looking for then yes, else avoid actively upgrading a running production system. -- If you plan to use `mc admin update`, MinIO process must have write access to the parent directory to provide in-place upgrades. -- `mc admin update` is not supported in kubernetes/container environments, container environments provide their own mechanisms for container updates. +- Read the release notes for MinIO *before* performing any upgrade, there is no forced requirement to upgrade to latest releases upon every releases. Some releases may not be relevant to your setup, avoid upgrading production environments unnecessarily. +- If you plan to use `mc admin update`, MinIO process must have write access to the parent directory where the binary is present on the host system. +- `mc admin update` is not supported and should be avoided in kubernetes/container environments, please upgrade containers by upgrading relevant container images. - **We do not recommend upgrading one MinIO server at a time, the product is designed to support parallel upgrades please follow our recommended guidelines.** ## Explore Further diff --git a/cmd/common-main.go b/cmd/common-main.go index 5dbd12f54..47dce73d5 100644 --- a/cmd/common-main.go +++ b/cmd/common-main.go @@ -526,9 +526,6 @@ func parsEnvEntry(envEntry string) (envKV, error) { func minioEnvironFromFile(envConfigFile string) ([]envKV, error) { f, err := os.Open(envConfigFile) if err != nil { - if os.IsNotExist(err) { // ignore if file doesn't exist. - return nil, nil - } return nil, err } defer f.Close() @@ -624,7 +621,7 @@ func loadEnvVarsFromFiles() { if env.IsSet(config.EnvConfigEnvFile) { ekvs, err := minioEnvironFromFile(env.Get(config.EnvConfigEnvFile, "")) - if err != nil { + if err != nil && !os.IsNotExist(err) { logger.Fatal(err, "Unable to read the config environment file") } for _, ekv := range ekvs { diff --git a/cmd/server-main.go b/cmd/server-main.go index bcbc544f1..47a3f07ad 100644 --- a/cmd/server-main.go +++ b/cmd/server-main.go @@ -138,6 +138,13 @@ func serverCmdArgs(ctx *cli.Context) []string { logger.FatalIf(err, "Unable to validate passed arguments in %s:%s", config.EnvArgs, os.Getenv(config.EnvArgs)) } + if v == "" { + v, _, _, err = env.LookupEnv(config.EnvVolumes) + if err != nil { + logger.FatalIf(err, "Unable to validate passed arguments in %s:%s", + config.EnvVolumes, os.Getenv(config.EnvVolumes)) + } + } if v == "" { // Fall back to older environment value MINIO_ENDPOINTS v, _, _, err = env.LookupEnv(config.EnvEndpoints) @@ -422,12 +429,12 @@ func serverMain(ctx *cli.Context) { erasureSelfTest() compressSelfTest() - // Handle all server command args. - serverHandleCmdArgs(ctx) - // Handle all server environment vars. serverHandleEnvVars() + // Handle all server command args. + serverHandleCmdArgs(ctx) + // Set node name, only set for distributed setup. globalConsoleSys.SetNodeName(globalLocalNodeName) diff --git a/internal/config/constants.go b/internal/config/constants.go index f55655209..347d45ff6 100644 --- a/internal/config/constants.go +++ b/internal/config/constants.go @@ -48,6 +48,7 @@ const ( EnvPublicIPs = "MINIO_PUBLIC_IPS" EnvFSOSync = "MINIO_FS_OSYNC" EnvArgs = "MINIO_ARGS" + EnvVolumes = "MINIO_VOLUMES" EnvDNSWebhook = "MINIO_DNS_WEBHOOK_ENDPOINT" EnvSiteName = "MINIO_SITE_NAME"