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

[DO-7442] Digital Ocean add consistent volume and droplet tags for multi master feature #7566

Merged

Conversation

srikiz
Copy link
Contributor

@srikiz srikiz commented Sep 11, 2019

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.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 11, 2019
@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 11, 2019
Copy link

@timoreimann timoreimann left a 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)

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


indexCount := 0

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, updated.

clusterTagIndex := do.TagKubernetesClusterIndex + ":" + strconv.Itoa(indexCount)
droplet.Tags = []string{clusterTag, clusterTagIndex}
} else {
droplet.Tags = []string{clusterTag}

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This helps, thanks. Updated.

@@ -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)

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?

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 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?

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"

Choose a reason for hiding this comment

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

Should be dropped.

Copy link
Contributor Author

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")

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.

Copy link
Contributor Author

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)

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds great, updated !

Copy link

@timoreimann timoreimann left a 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.

const TagNameRolePrefix = "k8s.io/role/"
const TagKubernetesClusterNamePrefix = "KubernetesCluster"

func SafeDOClusterName(clusterName string) string {

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

const TagKubernetesClusterNamePrefix = "KubernetesCluster"

func SafeDOClusterName(clusterName string) string {
// GCE does not support . in tags / names

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, updated.

@srikiz
Copy link
Contributor Author

srikiz commented Sep 12, 2019

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

@timoreimann
Copy link

@srikiz oh great point, didn't realize kops was still building for Go 1.11.

Let's stick to Remove then. 👍

@timoreimann
Copy link

/assign @gambol99

@rdrgmnzs
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 12, 2019
@srikiz
Copy link
Contributor Author

srikiz commented Sep 13, 2019

/retest

Copy link
Member

@zetaab zetaab left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 16, 2019
@chrisz100
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 16, 2019
@k8s-ci-robot k8s-ci-robot merged commit 070498b into kubernetes:master Sep 16, 2019
k8s-ci-robot added a commit that referenced this pull request Sep 18, 2019
…66-origin-release-1.15

Automated cherry pick of #7566: Update DO objects to use tags
k8s-ci-robot added a commit that referenced this pull request Sep 19, 2019
#7566-origin-release-1.14

Automated cherry pick of #7467: Update godo dependency to v1.19.0 version #7566: Update DO objects to use tags
@srikiz srikiz deleted the DO-7442-AddTagsForCreateVolumeRequest branch September 25, 2019 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants