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

Pass actual cluster name to cinder-csi-plugin #15095

Merged

Conversation

ederst
Copy link
Contributor

@ederst ederst commented Feb 2, 2023

This passes the acutal cluster name to the cinder-csi-plugin, so that the plugin will add the name as metadata to the backing volume in OpenStack.

Effectively, the change will help to better identify which volume in OpenStack belongs to which cluster, which is especially helpful when running multiple clusters in one OpenStack tenant/project.

Setting the cluster name in both - the controller and the nodeplugin - pods will ensure that dynamic and ephemeral volumes will receive the correct metadata.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 2, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @ederst. 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 the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Feb 2, 2023
@hakman
Copy link
Member

hakman commented Feb 2, 2023

/ok-to-test
/cc @zetaab

@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 Feb 2, 2023
@@ -333,7 +333,7 @@ spec:
- name: CLOUD_CONFIG
value: /etc/kubernetes/cloud.config
- name: CLUSTER_NAME
value: kubernetes
value: {{ ClusterName }}
Copy link
Member

Choose a reason for hiding this comment

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

hmm, what will happen to existing installations? It might work correctly to newer one, but what about old ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tried to answer this in one place, here: #15095 (comment)

@zetaab
Copy link
Member

zetaab commented Feb 2, 2023

also I think we need to add this also to occm? Seems that loadbalancer names have the cluster name, so if you create two similar named LBs to two different clusters it is facing an issue. Anyway this change is not backwards compatible, so I would like to see some boolean flag for that feature. It should be turned on for new clusters, but not to old ones.

if I read code correctly, modifying existing CSI cinder cluster name should not matter(?). The cluster name is used only when creating snapshots or new volumes, but it will not affect anything else (old volumes should work?). Anyway this might be risky move, if later on the behaviour will change in csi cinder driver (the labels should be modified at least).

IMO the best what we can do here, is to add that new boolean value which will define the behaviour for both: occm and csi. After that it can be used for new clusters but not the old ones

@ederst
Copy link
Contributor Author

ederst commented Feb 3, 2023

also I think we need to add this also to occm? Seems that loadbalancer names have the cluster name, so if you create two similar named LBs to two different clusters it is facing an issue. Anyway this change is not backwards compatible, so I would like to see some boolean flag for that feature. It should be turned on for new clusters, but not to old ones.

Don't know about that, I know there was an issue resolved in OCCM (kubernetes/cloud-provider-openstack#1809), but AFAIK the --cluster-name is already configurable for the (O)CCMs in kOps:

https://github.com/kubernetes/kops/blob/master/pkg/apis/kops/componentconfig.go#L675-L676

So in case someone experiences this issue, they can do that already.

if I read code correctly, modifying existing CSI cinder cluster name should not matter(?). The cluster name is used only when creating snapshots or new volumes, but it will not affect anything else (old volumes should work?). Anyway this might be risky move, if later on the behaviour will change in csi cinder driver (the labels should be modified at least).
IMO the best what we can do here, is to add that new boolean value which will define the behaviour for both: occm and csi. After that it can be used for new clusters but not the old ones

Yes, right now the label seems to be just informative, that's what I read from code and doc as well. And I tried it out on a few of our test clusters, does not seem to impact the old volumes, and new volumes just receive the cluster name instead of "kubernetes" in the property.

But you got a point with "when the behavior changes later on". So this might be better off as a config flag. But maybe not a boolean but also a clusterName property here:

type OpenstackBlockStorageConfig struct {
Version *string `json:"bs-version,omitempty"`
IgnoreAZ *bool `json:"ignore-volume-az,omitempty"`
OverrideAZ *string `json:"override-volume-az,omitempty"`
IgnoreVolumeMicroVersion *bool `json:"ignore-volume-microversion,omitempty"`
// CreateStorageClass provisions a default class for the Cinder plugin
CreateStorageClass *bool `json:"createStorageClass,omitempty"`
CSIPluginImage string `json:"csiPluginImage,omitempty"`
CSITopologySupport *bool `json:"csiTopologySupport,omitempty"`
}

For example like this:

type OpenstackBlockStorageConfig struct {
	Version                  *string `json:"bs-version,omitempty"`
	IgnoreAZ                 *bool   `json:"ignore-volume-az,omitempty"`
	OverrideAZ               *string `json:"override-volume-az,omitempty"`
	IgnoreVolumeMicroVersion *bool   `json:"ignore-volume-microversion,omitempty"`
	// CreateStorageClass provisions a default class for the Cinder plugin
	CreateStorageClass *bool  `json:"createStorageClass,omitempty"`
	CSIPluginImage     string `json:"csiPluginImage,omitempty"`
	CSITopologySupport *bool  `json:"csiTopologySupport,omitempty"`
        // ClusterName sets the --cluster flag of the cinder-csi-pluing to the provided name instead of "kubernetes"
        ClusterName  string `json:"clusterName,omitempty"`  // default value: "kubernetes"
}

Edit: did the changes i mentioned above, marked PR as WIP intmt

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. area/api and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 3, 2023
@ederst ederst changed the title Pass actual cluster name to cinder-csi-plugin WIP Pass actual cluster name to cinder-csi-plugin Feb 3, 2023
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 3, 2023
@ederst
Copy link
Contributor Author

ederst commented Feb 3, 2023

/restest

@zetaab
Copy link
Member

zetaab commented Feb 4, 2023

/retest

@ederst IMO this looks almost correct in case of CSI cinder. The only missing item is that we should populate this clusterName in case of new clusters. If we do that, we make it better for users hopefully in future. Perhaps good place for that is in https://github.com/kubernetes/kops/blob/master/upup/pkg/fi/cloudup/new_cluster.go#L326

However, I checked our kops occm installations and those does not have cluster-name flag at all for some reason(?).. anyways that can be handled as separate issue/pr if needed.

@ederst
Copy link
Contributor Author

ederst commented Feb 4, 2023

/retest

@ederst IMO this looks almost correct in case of CSI cinder. The only missing item is that we should populate this clusterName in case of new clusters. If we do that, we make it better for users hopefully in future. Perhaps good place for that is in https://github.com/kubernetes/kops/blob/master/upup/pkg/fi/cloudup/new_cluster.go#L326

Ah, OK now I think I know what you mean. Sounds good, will check out the issue (on Monday probably).

However, I checked our kops occm installations and those does not have cluster-name flag at all for some reason(?).. anyways that can be handled as separate issue/pr if needed.

Strange, but maybe it is only available in OCCM >=1.26 b/c it was not cherry-picked to older versions? Had this issue with some features.

Nope, this should be coming from the controller lib occm has as dependency, so not sure what's the problem with your occm installations.

@zetaab zetaab changed the title WIP Pass actual cluster name to cinder-csi-plugin Pass actual cluster name to cinder-csi-plugin Feb 12, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 12, 2023
@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 12, 2023
@hakman
Copy link
Member

hakman commented Feb 12, 2023

Please squash the commits first.
/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 12, 2023
@zetaab
Copy link
Member

zetaab commented Feb 12, 2023

/approve cancel

also we need that default value to https://github.com/kubernetes/kops/blob/master/upup/pkg/fi/cloudup/new_cluster.go#L326

sorry I was too fast, did not remember that missing piece :)

@k8s-ci-robot k8s-ci-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 12, 2023
@ederst ederst force-pushed the use-clustername-in-cinder-csi-plugin branch from 74b3286 to 6702187 Compare February 13, 2023 15:27
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 13, 2023
@ederst
Copy link
Contributor Author

ederst commented Feb 13, 2023

@hakman @zetaab good to go now, or should the --cluster flag be set to the value of the cloud controller manager?

https://github.com/kubernetes/kops/pull/15139/files#diff-cf0e850db1e4461eab5d4dac860d20f2176b940f236e50825ae538ee23688a1e

@hakman
Copy link
Member

hakman commented Feb 13, 2023

Thanks @ederst. Leaving the final review to @zetaab.
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 13, 2023
@zetaab
Copy link
Member

zetaab commented Feb 13, 2023

@ederst if you could add the clustername by default here https://github.com/kubernetes/kops/blob/master/upup/pkg/fi/cloudup/new_cluster.go#L326

something like

			BlockStorage: &api.OpenstackBlockStorageConfig{
				Version:     fi.PtrTo("v3"),
				IgnoreAZ:    fi.PtrTo(opt.OpenstackStorageIgnoreAZ),
				ClusterName: opt.ClusterName,
			},

then I think you need to execute ./hack/update-expected.sh. Please make code changes to first commit and then update-expected.sh to second commit

This passes the acutal cluster name to the cinder-csi-plugin, so that
the plugin will add the name as metadata to the backing volume in
OpenStack.

Effectively, the change will help to better identify which volume in
OpenStack belongs to which cluster, which is especially helpful when
running multiple clusters in one OpenStack tenant/project.

Setting the cluster name in both - the controller and the nodeserver -
will ensure that dynamic and ephemeral volumes will receive the correct
metadata.
@ederst ederst force-pushed the use-clustername-in-cinder-csi-plugin branch from 6702187 to 3049506 Compare February 13, 2023 16:46
@ederst
Copy link
Contributor Author

ederst commented Feb 13, 2023

@zetaab done like suggested, updated commits again so that code changes are separate from the generated stuff

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.

thank you

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 13, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zetaab

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 Feb 13, 2023
@k8s-ci-robot k8s-ci-robot merged commit ca3b53c into kubernetes:master Feb 13, 2023
@ederst ederst deleted the use-clustername-in-cinder-csi-plugin branch February 14, 2023 08:30
k8s-ci-robot added a commit that referenced this pull request Feb 14, 2023
…95-origin-release-1.26

Automated cherry pick of #15095: Pass actual cluster name to cinder-csi-plugin
Shimiazoulai pushed a commit to spotinst/kubernetes-kops that referenced this pull request Jul 13, 2023
…ck-of-#15095-origin-release-1.26

Automated cherry pick of kubernetes#15095: Pass actual cluster name to cinder-csi-plugin
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. area/addons area/api 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/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