Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport: Don't use autogenerated licenses in diagnose when config is specified #12235

Merged
merged 4 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/12229.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
core: fix byte printing for diagnose disk checks
```
3 changes: 3 additions & 0 deletions changelog/_2071.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
core (enterprise): Disallow autogenerated licenses to be used in diagnose even when config is specified
```
2 changes: 1 addition & 1 deletion command/operator_diagnose.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ SEALFAIL:
if envLicense := os.Getenv(EnvVaultLicense); envLicense != "" {
coreConfig.License = envLicense
}
vault.DiagnoseCheckLicense(licenseCtx, vaultCore, coreConfig)
vault.DiagnoseCheckLicense(licenseCtx, vaultCore, coreConfig, false)
}
licenseSpan.End()

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ require (
github.com/docker/go-connections v0.4.0
github.com/dsnet/compress v0.0.1 // indirect
github.com/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74
github.com/dustin/go-humanize v1.0.0
github.com/elazarl/go-bindata-assetfs v1.0.1-0.20200509193318-234c15e7648f
github.com/fatih/color v1.11.0
github.com/fatih/structs v1.1.0
Expand Down
2 changes: 1 addition & 1 deletion vault/core_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,6 @@ func (c *Core) MissingRequiredState(raw []string, perfStandby bool) bool {
return false
}

func DiagnoseCheckLicense(ctx context.Context, vaultCore *Core, coreConfig CoreConfig) (bool, []string) {
func DiagnoseCheckLicense(ctx context.Context, vaultCore *Core, coreConfig CoreConfig, generate bool) (bool, []string) {
return false, nil
}
11 changes: 6 additions & 5 deletions vault/diagnose/os_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"strings"

"github.com/dustin/go-humanize"
"github.com/shirou/gopsutil/disk"
)

Expand All @@ -31,11 +32,11 @@ partLoop:
Warn(ctx, fmt.Sprintf("Could not obtain partition usage for %s: %v.", partition.Mountpoint, err))
} else {
if usage.UsedPercent > 95 {
SpotWarn(ctx, testName, fmt.Sprintf(partition.Mountpoint+" is %d percent full.", usage.UsedPercent),
Advice("It is recommended to have more than five percent of the partition free."))
} else if usage.Free < 2<<30 {
SpotWarn(ctx, testName, partition.Mountpoint+" has %d bytes full.",
Advice("It is recommended to have at least 1 GB of space free per partition."))
SpotWarn(ctx, testName, fmt.Sprintf(partition.Mountpoint+" is %.2f percent full.", usage.UsedPercent))
Advise(ctx, "It is recommended to have more than five percent of the partition free.")
} else if usage.Free < 1<<30 {
SpotWarn(ctx, testName, fmt.Sprintf(partition.Mountpoint+" has %s free.", humanize.Bytes(usage.Free)))
Advise(ctx, "It is recommended to have at least 1 GB of space free per partition.")
} else {
SpotOk(ctx, testName, partition.Mountpoint+" usage ok.")
}
Expand Down