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

Update feature gate logging to include default on #4029

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

benjaminjb
Copy link
Contributor

Checklist:

  • Have you added an explanation of what your changes do and why you'd like them to be included?
  • Have you updated or added documentation for the change, as applicable?
  • Have you tested your changes on all related environments with successful results, as applicable?
    • Have you added automated tests?

Type of Changes:

  • New feature
  • Bug fix
  • Documentation
  • Testing enhancement
  • Other

What is the current behavior (link to any open issues here)?

After the 5.7 release, when AutoUserSchemaCreate was graduated to default on/true, we discovered that our current system (and the underlying featuregate implementation) treats features explicitly turned on by the user differently than features turned on by default.

What is the new behavior (if this is a feature change)?

  • Breaking change (fix or feature that would cause existing functionality to change)

This PR updates that logging to make clear that the features are those specifically requested by the user (kept as a string to help debugging) and revises the 'ShowGates' function to include those set through defaults.

Other Information:

Issues: [PGO-1824]

After the 5.7 release, when AutoUserSchemaCreate was graduated to
default on/true, we discovered that our current system (and the
underlying featuregate implementation) treats features explicitly
turned on by the user differently than features turned on by default.

This PR updates that logging to make clear that the features are those
specifically requested by the user (kept as a string to help debugging)
and revises the 'ShowGates' function to include those set through defaults.

Issues: [PGO-1824]
Copy link
Member

@cbandy cbandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation is good, but I've soured on some of the naming. I misunderstood what "String" did, and now want better method names.

I can do the work of renaming a bunch of things if you're ready to be done with this PR.

internal/feature/features.go Outdated Show resolved Hide resolved
internal/feature/features.go Outdated Show resolved Hide resolved
internal/feature/features.go Outdated Show resolved Hide resolved
@@ -52,6 +55,7 @@ type Feature = featuregate.Feature
type Gate interface {
Enabled(Feature) bool
String() string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 I misunderstood what upstream's String() does. Let's explain it here.

Suggested change
String() string
// String returns the features enabled or disabled by Set and SetFromMap.
String() string


🤔 Maybe we drop String from the interface and pivot fully to context functions?

// ShowAssigned returns the features enabled or disabled by Set and SetFromMap
// in the Gate contained in ctx.
func ShowAssigned(ctx context.Context) string

// ShowEnabled returns the features enabled in the Gate contained in ctx.
func ShowEnabled(ctx context.Context) string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only place we use gate.String() is in main.go when we report what the user set -- but if we're just telling the user what they set, why not just print the env var?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever the shape on the way in, we have a canonical representation in the logs.

internal/feature/features.go Outdated Show resolved Hide resolved
internal/feature/features_test.go Outdated Show resolved Hide resolved
internal/feature/features_test.go Outdated Show resolved Hide resolved
@@ -69,7 +69,7 @@ func TestCheckForUpgrades(t *testing.T) {
assert.Equal(t, data.RegistrationToken, "speakFriend")
assert.Equal(t, data.BridgeClustersTotal, 2)
assert.Equal(t, data.PGOClustersTotal, 2)
assert.Equal(t, data.FeatureGatesEnabled, "TablespaceVolumes=true")
assert.Equal(t, data.FeatureGatesEnabled, "AutoCreateUserSchema=true,TablespaceVolumes=true")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻 This isn't Contains, but I don't mind seeing the format. 🌱 We can change the test if it is ever a problem.

@@ -52,6 +55,7 @@ type Feature = featuregate.Feature
type Gate interface {
Enabled(Feature) bool
String() string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever the shape on the way in, we have a canonical representation in the logs.

Copy link
Member

@cbandy cbandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants