-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[DO-7442] Digital Ocean add consistent volume and droplet tags for multi master feature #7566
[DO-7442] Digital Ocean add consistent volume and droplet tags for multi master feature #7566
Conversation
Hi @srikiz. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
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.
Left a few minor comments; overall, this looks good to me but it needs another pair of 👁s from someone more familiar with kops.
Thanks!
@@ -393,10 +393,12 @@ func (b *EtcdManagerBuilder) buildPod(etcdCluster *kops.EtcdClusterSpec) (*v1.Po | |||
case kops.CloudProviderDO: | |||
config.VolumeProvider = "do" | |||
|
|||
// DO does not support . in tags / names | |||
safeClusterName := strings.Replace(b.Cluster.Name, ".", "-", -1) |
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.
nit: this could also call strings.ReplaceAll
to allow dropping the last parameter (-1
).
Same for similar usages of Replace
within this PR.
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/model/domodel/droplets.go
Outdated
|
||
indexCount := 0 |
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 call this masterIndexCount
to make clearer that this is about masters only?
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.
Sure, updated.
pkg/model/domodel/droplets.go
Outdated
clusterTagIndex := do.TagKubernetesClusterIndex + ":" + strconv.Itoa(indexCount) | ||
droplet.Tags = []string{clusterTag, clusterTagIndex} | ||
} else { | ||
droplet.Tags = []string{clusterTag} |
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.
Alternatively, we could invoke this line before line 67 and append the tags in line 70 like
droplet.Tags = append(droplet.Tags, clusterTagIndex)
in order to drop the else
branch.
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 helps, thanks. Updated.
pkg/model/master_volumes.go
Outdated
@@ -184,11 +185,19 @@ func (b *MasterVolumeBuilder) addDOVolume(c *fi.ModelBuilderContext, name string | |||
name = name[:64] | |||
} | |||
|
|||
tags := make(map[string]string) | |||
tags[do.TagNameEtcdClusterPrefix+etcd.Name] = gce.SafeClusterName(m.Name) |
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.
I wonder if we should move SafeClusterName
out of the gcp
package now that DO uses it as well. This would also indicate to developers that changes to the function do not affect GCP only. WDYT?
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.
I created a new function in package do - calling it as SafeDOClusterName, otherwise, I had to change the package name to something common, and update all the GCE references to use the common package. I thought this is more safer, since the change will only be reflecting to the DO code now. Is this OK?
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.
Yeah that makes total sense. 👍
@@ -19,9 +19,10 @@ package dotasks | |||
import ( | |||
"context" | |||
"errors" | |||
|
|||
//"strconv" |
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 be dropped.
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.
@@ -108,12 +110,26 @@ func (_ *Volume) RenderDO(t *do.DOAPITarget, a, e, changes *Volume) error { | |||
return nil | |||
} | |||
|
|||
tagArray := []string{} | |||
|
|||
klog.V(2).Info("Looping DO tag arrays") |
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.
AFAIK V(2)
is the standard logging level. If so, then this message might be rather verbose for that level. Maybe push it out to something higher (or drop the line if it was mostly for debugging purposes)?
Similar for line 121.
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.
Sure dropped the line and updated the other klog to V(10)
// DO tags don't accept =. Separate the key and value with an ":" | ||
strJoin := strings.Join(s, ":") | ||
klog.V(2).Infof("DO - Join the volume tag - %s", strJoin) | ||
tagArray = append(tagArray, strJoin) |
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.
We could also do a direct
tagArray = append(tagArray, fmt.Sprintf("%s:%s", k, v)
here and drop s
and strJoin
since we're always joining a pair only.
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.
Sounds great, updated !
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.
Two small nits, otherwise all good from my end.
upup/pkg/fi/cloudup/do/cloud.go
Outdated
const TagNameRolePrefix = "k8s.io/role/" | ||
const TagKubernetesClusterNamePrefix = "KubernetesCluster" | ||
|
||
func SafeDOClusterName(clusterName string) string { |
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.
We can drop the DO
part since it's part of the do
package.
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.
upup/pkg/fi/cloudup/do/cloud.go
Outdated
const TagKubernetesClusterNamePrefix = "KubernetesCluster" | ||
|
||
func SafeDOClusterName(clusterName string) string { | ||
// GCE does not support . in tags / names |
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 say DO instead of GCE.
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.
Thanks, updated.
@timoreimann - The build is failing in Go 1.11 version. It looks like I have to revert ReplaceAll to use Replace instead - TravisCI builds KOPS on 1.11 Go version as well, and Go 1.11 version it didn't ReplaceAll method. It was newly introducted in 1.12. |
@srikiz oh great point, didn't realize kops was still building for Go 1.11. Let's stick to |
…nstead of ReplaceAll
/assign @gambol99 |
/ok-to-test |
/retest |
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
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: chrisz100, srikiz The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…66-origin-release-1.15 Automated cherry pick of #7566: Update DO objects to use tags
Digital Ocean doesn't support Multi master yet. This PR introduces tags that helps in associating a specific droplet to a volume.
I have tested with by making the needed changes in etcd-manager and they are getting linked up properly. I'll be sending a PR for etcd-manager repo separately once this is merged.
I'll also be adding a new PR to add DO support for protokube's gossip cluster to add peers as part of the next step.