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

introduce flag --feature-gates to karmadactl register #5970

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zhzhuang-zju
Copy link
Contributor

What type of PR is this?
/kind feature

What this PR does / why we need it:
introduce flag --feature-gates to karmadactl register to describe feature gates for alpha/experimental features of karmada-agent.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

$ karmadactl register -h
Options:

    --feature-gates='':
        Comma-separated list of key=value pairs that describe feature gates for alpha/experimental features
        of karmada-agent. More info: https://github.com/karmada-io/karmada/blob/master/pkg/features/features.go

Does this PR introduce a user-facing change?:

`karmadactl`: introduce flag `--feature-gates` to command `register` to describe feature gates for alpha/experimental features of `karmada-agent`.

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Dec 24, 2024
@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign chaunceyjiang for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@karmada-bot karmada-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Dec 24, 2024
@zhzhuang-zju
Copy link
Contributor Author

Timeout waiting for file exist /home/runner/.kube/member-tmp-member2.config
https://github.com/karmada-io/karmada/actions/runs/12478154855/job/34825314108?pr=5970#step:5:710

/retest

@codecov-commenter
Copy link

codecov-commenter commented Dec 24, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 0% with 11 lines in your changes missing coverage. Please review.

Project coverage is 48.22%. Comparing base (c9ca6ac) to head (50be683).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
pkg/karmadactl/register/register.go 0.00% 11 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5970      +/-   ##
==========================================
- Coverage   48.23%   48.22%   -0.02%     
==========================================
  Files         664      664              
  Lines       54749    54760      +11     
==========================================
- Hits        26410    26406       -4     
- Misses      26624    26638      +14     
- Partials     1715     1716       +1     
Flag Coverage Δ
unittests 48.22% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zhzhuang-zju
Copy link
Contributor Author

/hold for more verification

@karmada-bot karmada-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 24, 2024
@zhzhuang-zju
Copy link
Contributor Author

/hold cancel

@karmada-bot karmada-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 24, 2024
Signed-off-by: zhzhuang-zju <m17799853869@163.com>
Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/assign

Comment on lines +201 to +203
flags.StringVar(&opts.FeatureGates, "feature-gates", "", ""+
"A set of key=value pairs that describe feature gates for alpha/experimental features. "+
"Options are:\n"+strings.Join(features.FeatureGate.KnownFeatures(), "\n"))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
flags.StringVar(&opts.FeatureGates, "feature-gates", "", ""+
"A set of key=value pairs that describe feature gates for alpha/experimental features. "+
"Options are:\n"+strings.Join(features.FeatureGate.KnownFeatures(), "\n"))
features.FeatureGate.AddFlag(flags)

Can we do that this way, which is the way we did at all the other components, like

features.FeatureGate.AddFlag(flags)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've tried this way, but ran into an issue where I couldn't get the string value of the feature gates when injecting them into the agent's manifest.

Copy link
Member

Choose a reason for hiding this comment

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

why?

Copy link
Member

Choose a reason for hiding this comment

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

It is worth noting that, you don't need to introduce an additional field into CommandRegisterOption anymore.

	FeatureGates 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.

why?

// MutableFeatureGate parses and stores flag gates for known features from
// a string like feature1=true,feature2=false,...
type MutableFeatureGate interface {
FeatureGate
// AddFlag adds a flag for setting global feature gates to the specified FlagSet.
AddFlag(fs *pflag.FlagSet)
// Close sets closed to true, and prevents subsequent calls to Add
Close()
// Set parses and stores flag gates for known features
// from a string like feature1=true,feature2=false,...
Set(value string) error
// SetFromMap stores flag gates for known features from a map[string]bool or returns an error
SetFromMap(m map[string]bool) error
// Add adds features to the featureGate.
Add(features map[Feature]FeatureSpec) error
// GetAll returns a copy of the map of known feature names to feature specs.
GetAll() map[Feature]FeatureSpec
// AddMetrics adds feature enablement metrics
AddMetrics()
// OverrideDefault sets a local override for the registered default value of a named
// feature. If the feature has not been previously registered (e.g. by a call to Add), has a
// locked default, or if the gate has already registered itself with a FlagSet, a non-nil
// error is returned.
//
// When two or more components consume a common feature, one component can override its
// default at runtime in order to adopt new defaults before or after the other
// components. For example, a new feature can be evaluated with a limited blast radius by
// overriding its default to true for a limited number of components without simultaneously
// changing its default for all consuming components.
OverrideDefault(name Feature, override bool) error
}

features.FeatureGate.AddFlag(flags) has no method to get the string value of the feature gate. Hard to complete fmt.Sprintf(‘--feature-gates=%s’, o.FeatureGates).

@zhzhuang-zju
Copy link
Contributor Author

I have a question: does it need to verify whether the user-defined featuregate is valid? The method features.FeatureGate.Validate() is used to determine if the user-defined feature gate has been added in [pkg/features/features.go]. This leads to the validation result being highly related to the code at the time karmadactl was compiled. However, karmadactl register should support different versions of karmada-agent.
For example:

  • version v1.12 the supported featuregates are: featuregateA and featuregateB,
  • version v1.13 the supported featuregates are: featuregateA,

So, using the v1.13 version of karmadactl to execute the register command, setting the flags --karmada-agent-image docker.io/karmada/karmada-agent:v1.12.0 --feature-gates=featuregateB=true will result in an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants