Skip to content

Commit

Permalink
fix for etcd-io#19066 Print warnings when deprecated options are conf…
Browse files Browse the repository at this point in the history
…igured in config file

Signed-off-by: mansoora <[email protected]>
  • Loading branch information
mansoor17syed committed Jan 9, 2025
1 parent 3388e2b commit b85a90f
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ type ServerConfig struct {
// VerifyBootstrap sanity-checks the initial config for bootstrap case
// and returns an error for things that should never happen.
func (c *ServerConfig) VerifyBootstrap() error {
// Print deprecation warnings first
if warnings := c.checkDeprecatedOptions(); len(warnings) > 0 {
for _, warning := range warnings {
c.Logger.Warn(warning)
}
}

if err := c.hasLocalMember(); err != nil {
return err
}
Expand All @@ -234,8 +241,13 @@ func (c *ServerConfig) VerifyBootstrap() error {
// VerifyJoinExisting sanity-checks the initial config for join existing cluster
// case and returns an error for things that should never happen.
func (c *ServerConfig) VerifyJoinExisting() error {
// The member has announced its peer urls to the cluster before starting; no need to
// set the configuration again.
// Print deprecation warnings first
if warnings := c.checkDeprecatedOptions(); len(warnings) > 0 {
for _, warning := range warnings {
c.Logger.Warn(warning)
}
}

if err := c.hasLocalMember(); err != nil {
return err
}
Expand Down Expand Up @@ -365,3 +377,21 @@ func (c *ServerConfig) BackendPath() string { return datadir.ToBackendFileName(c
func (c *ServerConfig) MaxRequestBytesWithOverhead() uint {
return c.MaxRequestBytes + grpcOverheadBytes
}

// Add this new function to check deprecated options
func (c *ServerConfig) checkDeprecatedOptions() []string {
var warnings []string

// Check for deprecated configurations
if c.ForceNewCluster {
warnings = append(warnings, "WARNING: 'force-new-cluster' option is deprecated and will be removed in future versions")
}

if c.V2Deprecation == "" {
warnings = append(warnings, "WARNING: v2 API is deprecated and will be decommissioned in etcd v3.6")
}

// Add more deprecated option checks as needed

return warnings
}

0 comments on commit b85a90f

Please sign in to comment.