-
Notifications
You must be signed in to change notification settings - Fork 102
Added support to run etcd client calls only when in multi-node case #504
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
Conversation
/work-in-progress |
@aaronfern Command |
efbd42f
to
bb64b16
Compare
bb64b16
to
bbf1ffa
Compare
bbf1ffa
to
7d3be46
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me in general. I added some comments to improve DRY. Please add a proper release note as well.
pkg/miscellaneous/miscellaneous.go
Outdated
etcdConfigForTest := os.Getenv("ETCD_CONF") | ||
if etcdConfigForTest != "" { | ||
return false | ||
} | ||
inputFileName = "/var/etcd/config/etcd.conf.yaml" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be transferred into a utility function. I also see this code being duplicated multiple times in the code base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please also make other areas in the code use this utility?
func GetEtcdSvcEndpoint() (string, error) { etcdConfigForTest := os.Getenv("ETCD_CONF") etcdConfigForTest := os.Getenv("ETCD_CONF")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
pkg/miscellaneous/miscellaneous.go
Outdated
@@ -338,6 +338,36 @@ func ProbeEtcd(ctx context.Context, clientFactory etcdClient.Factory, logger *lo | |||
return nil | |||
} | |||
|
|||
// IsMultiNode determines whether a pod is part of a multi node setup or not | |||
// This is determined by checking the `initial-cluster` of the etcd configmap to check the number of members expected. | |||
func IsMultiNode() bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can align this more with that is already used here
OriginalClusterSize: len(initialClusterMap), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
7d3be46
to
4e2f97a
Compare
fa7fe27
to
c60a1d7
Compare
c60a1d7
to
049bfa5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks for the improvements 👍
if etcdConfigForTest != "" { | ||
|
||
inputFileName = GetConfigFilePath() | ||
if inputFileName != EtcdConfigFilePath { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why this check is required or was not there before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So ideally if we are in test-mode (ETCD_CONF is set) then we return an empty service endpoint so that the default one is used (http://127.0.0.1:2379
)
We send a proper service endpoint only when running in a cluster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I can't really judge this case but it seems very implicit and also confusing (because why should we then supprt setting a config via ETCD_CONF
?!). At a minimum a comment would be nice why such a check is performed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I understand, and we will be picking this up and finding a better way to implement this while refactoring the code base
For the time being I have added a comment here
pkg/server/backuprestoreserver.go
Outdated
err := m.PromoteMember(ctx) | ||
if err == nil { | ||
break | ||
if miscellaneous.IsMultiNode(b.logger) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rather use the restoreOpts.OriginalClusterSize
here, so that we don't have to decode the configYML
again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, you're right, that makes sense
Will make that change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
de812f3
to
aaeeada
Compare
aaeeada
to
8dbeddc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
8dbeddc
to
d7b9ac9
Compare
…ardener#504) * Added support to run etcd client calls only when in multi-node case * Addressed review comments * Used values from restoreOpts rather than another func call
* Added support to run etcd client calls only when in multi-node case (#504) * Added support to run etcd client calls only when in multi-node case * Addressed review comments * Used values from restoreOpts rather than another func call * Temp fix: skip single member restoration in case of data-dir invalid. (#501) * Temp fix: skip single member restoration in case of data-dir invalid. * Small fixes. * Improved error log. * Fixed a bug in scaleup feature which present in func: IsMemberInCluster. * Fix the unit tests. * Address the review comments. * Handle the case of when storageProvider is not configured. * Address the review comments. * Address the review comments. * Assigned the correct Peer Address to Etcd after it restores from the backup-bucket. (#505) * Assigned the correct Peer address to the Etcd after restoration. * Fix the unit tests and some refactoring. * Improve some logs. * Address the review comments. * To update the peer address of existing cluster. * Don't update peer URL when promoting member (#506) * Don't update peer URL when promoting member * Update interface name in member package Co-authored-by: Ishan Tyagi <42602577+ishan16696@users.noreply.github.com>
What this PR does / why we need it:
This PR adds support to allow etcd calls only if
backup-restore
determines that it is in a multi-node setup.This removes dependencies in a single node case of requiring network policies for etcd calls to succeed
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Release note: