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

feat(etcd): support external standalone etcd #595

Merged
merged 5 commits into from
May 5, 2022

Conversation

aniaan
Copy link
Collaborator

@aniaan aniaan commented Apr 27, 2022

close #584

  1. add flag: use-standalone-etcd: bool
  2. if use-standalone-etcd is true, all node role is secondary

@codecov-commenter
Copy link

codecov-commenter commented Apr 27, 2022

Codecov Report

Merging #595 (091fc34) into main (72354f1) will increase coverage by 0.10%.
The diff coverage is 57.14%.

@@            Coverage Diff             @@
##             main     #595      +/-   ##
==========================================
+ Coverage   80.06%   80.16%   +0.10%     
==========================================
  Files          95       95              
  Lines       10956    10961       +5     
==========================================
+ Hits         8772     8787      +15     
+ Misses       1705     1698       -7     
+ Partials      479      476       -3     
Impacted Files Coverage Δ
pkg/cluster/cluster.go 60.86% <57.14%> (+1.24%) ⬆️
pkg/object/mqttproxy/spec.go 100.00% <0.00%> (ø)
pkg/filter/validator/basicauth.go 80.73% <0.00%> (+1.83%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 72354f1...091fc34. Read the comment docs.

@aniaan aniaan marked this pull request as ready for review April 27, 2022 03:08
@@ -245,6 +276,11 @@ func (opt *Options) Parse() (string, error) {
}

opt.renameLegacyClusterRoles()

if opt.UseStandaloneEtcd {
opt.ClusterRole = "secondary"
Copy link
Contributor

@samutamm samutamm Apr 27, 2022

Choose a reason for hiding this comment

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

It could be more visible / explicit that when using "standalone" etcd, the cluster role cannot be "primary". Logging is not yet initialized here but maybe consider adding a comment:

Suggested change
opt.ClusterRole = "secondary"
opt.ClusterRole = "secondary" // when using external standalone etcd, the cluster role cannot be "primary"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

Comment on lines 378 to 387
} else {
if c.opt.UseStandaloneEtcd {
err := c.Put(c.Layout().ClusterNameKey(), c.opt.ClusterName)
if err != nil {
return fmt.Errorf("register cluster name %s failed: %v",
c.opt.ClusterName, err)
}
} else {
return fmt.Errorf("key %s not found", c.Layout().ClusterNameKey())
}
Copy link
Collaborator

@localvar localvar Apr 29, 2022

Choose a reason for hiding this comment

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

to reduce nesting.

Suggested change
} else {
if c.opt.UseStandaloneEtcd {
err := c.Put(c.Layout().ClusterNameKey(), c.opt.ClusterName)
if err != nil {
return fmt.Errorf("register cluster name %s failed: %v",
c.opt.ClusterName, err)
}
} else {
return fmt.Errorf("key %s not found", c.Layout().ClusterNameKey())
}
} else if c.opt.UseStandaloneEtcd {
err := c.Put(c.Layout().ClusterNameKey(), c.opt.ClusterName)
if err != nil {
return fmt.Errorf("register cluster name %s failed: %v", c.opt.ClusterName, err)
}
} else {
return fmt.Errorf("key %s not found", c.Layout().ClusterNameKey())

opt.flags.StringVar(&opt.ClusterName, "cluster-name", "eg-cluster-default-name", "Human-readable name for the new cluster, ignored while joining an existed cluster.")
opt.flags.StringVar(&opt.ClusterRole, "cluster-role", "primary", "Cluster role for this member (primary, secondary).")
opt.flags.StringVar(&opt.ClusterRequestTimeout, "cluster-request-timeout", "10s", "Timeout to handle request in the cluster.")
opt.flags.StringVar(&opt.ClusterName, "cluster-name", "eg-cluster-default-name",
Copy link
Collaborator

Choose a reason for hiding this comment

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

per https://github.com/golang/go/wiki/CodeReviewComments#line-length:

don't add line breaks to keep lines short when they are more readable long--for example, if they are repetitive.

please revert the newly added line breaks.

@aniaan aniaan requested a review from localvar April 29, 2022 03:48
@suchen-sci suchen-sci merged commit 252cb34 into easegress-io:main May 5, 2022
@aniaan aniaan deleted the feature/standalone-etcd branch May 9, 2022 03:19
localvar pushed a commit that referenced this pull request Jun 13, 2022
* feat(etcd): init

* fix(statuscontroller): remove log

* fix(option): add comment

* fix(chart): fix typo

* style(option): revert break line
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.

support external standalone etcd
5 participants