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
csi: update network fence CR name #13615
Conversation
13d15f0
to
c4d6128
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.
please update the unit test to have both pv in single node and verify both NF are created.
88d27a3
to
cacc0be
Compare
400ea02
to
115aca5
Compare
pkg/operator/ceph/cluster/watcher.go
Outdated
@@ -516,7 +521,7 @@ func (c *clientCluster) createNetworkFence(ctx context.Context, pv corev1.Persis | |||
|
|||
networkFence := &addonsv1alpha1.NetworkFence{ | |||
ObjectMeta: metav1.ObjectMeta{ | |||
Name: node.Name, | |||
Name: node.Name + driver, |
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.
How about also add a -
to the name? It will be more standard K8s convention and also more readable.
Name: node.Name + driver, | |
Name: node.Name + "-" + driver, |
pkg/operator/ceph/cluster/watcher.go
Outdated
} | ||
|
||
err = wait.PollUntilContextTimeout(ctx, 2*time.Second, 60*time.Second, true, func(ctx context.Context) (bool, error) { | ||
err = c.client.Get(ctx, types.NamespacedName{Name: node.Name + "rbd", Namespace: cluster.Namespace}, networkFence) |
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.
err = c.client.Get(ctx, types.NamespacedName{Name: node.Name + "rbd", Namespace: cluster.Namespace}, networkFence) | |
err = c.client.Get(ctx, types.NamespacedName{Name: node.Name + "-rbd", Namespace: cluster.Namespace}, networkFence) |
pkg/operator/ceph/cluster/watcher.go
Outdated
@@ -565,7 +615,7 @@ func (c *clientCluster) unfenceAndDeleteNetworkFence(ctx context.Context, node c | |||
} | |||
|
|||
err = wait.PollUntilContextTimeout(ctx, 2*time.Second, 60*time.Second, true, func(ctx context.Context) (bool, error) { | |||
err = c.client.Get(ctx, types.NamespacedName{Name: node.Name, Namespace: cluster.Namespace}, networkFence) | |||
err = c.client.Get(ctx, types.NamespacedName{Name: node.Name + "cephFS", Namespace: cluster.Namespace}, networkFence) |
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.
Let's just keep it lower case, IMO the K8s resource naming is more consistent that way
err = c.client.Get(ctx, types.NamespacedName{Name: node.Name + "cephFS", Namespace: cluster.Namespace}, networkFence) | |
err = c.client.Get(ctx, types.NamespacedName{Name: node.Name + "-cephfs", Namespace: cluster.Namespace}, networkFence) |
pkg/operator/ceph/cluster/watcher.go
Outdated
return nil | ||
} | ||
|
||
func (c *clientCluster) unfenceAndDeleteCephFSNetworkFence(ctx context.Context, node corev1.Node, cluster *cephv1.CephCluster) error { |
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 we have a common helper method for unfencing? If the only difference between unfenceAndDeleteCephFSNetworkFence()
and unfenceAndDeleteRbdNetworkFence()
is the name of the CR and the log messages, then we can make the name a parameters and keep a single method.
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, made the changes.
803d301
to
40d8262
Compare
Thanks for the review Travis and Subham, |
Thanks, Updated, and working as expected. |
pkg/operator/ceph/cluster/watcher.go
Outdated
@@ -575,7 +580,7 @@ func (c *clientCluster) unfenceAndDeleteNetworkFence(ctx context.Context, node c | |||
return false, err | |||
} | |||
|
|||
logger.Infof("successfully unfenced network fence cr %q, proceeding with deletion", networkFence.Name) | |||
logger.Infof("successfully unfenced %q network fence cr %q, proceeding with deletion", driver, networkFence.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.
logger.Infof("successfully unfenced %q network fence cr %q, proceeding with deletion", driver, networkFence.Name) | |
logger.Infof("successfully unfenced %q network fence cr %q, proceeding with deletion", driver, networkFence.Name) |
pkg/operator/ceph/cluster/watcher.go
Outdated
@@ -516,7 +521,7 @@ func (c *clientCluster) createNetworkFence(ctx context.Context, pv corev1.Persis | |||
|
|||
networkFence := &addonsv1alpha1.NetworkFence{ | |||
ObjectMeta: metav1.ObjectMeta{ | |||
Name: node.Name, | |||
Name: node.Name + "-" + driver, |
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.
Since this name generation is used in several places, how about a helper method to implement it? Something like:
Name: node.Name + "-" + driver, | |
Name: fenceResourceName(node.Name, driver), |
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!
40d8262
to
2cd8b1b
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.
few suggestions
2cd8b1b
to
f687e21
Compare
1ba54f7
to
6f9db56
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.
Secret:
Name: rook-csi-rbd-provisioner
Namespace: openshift-storage
Status:
Message: fencing operation successful
Result: Succeeded
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning OwnerRefInvalidNamespace 89s garbage-collector-controller ownerRef [ceph.rook.io/v1/CephCluster, namespace: , name: ocs-storagecluster-cephcluster, uid: db2eb584-6ebb-4865-8902-a17241e49ff2] does not exist in namespace ""
(venv) [jopinto@jopinto ceph-csi]$
what about the warning mentioned in the BZ, can we check that as well or else we might get i to garbage collection problem.
use SetControllerReference from the k8sutil/resources.go file which check for valid Reference.
pkg/operator/ceph/cluster/watcher.go
Outdated
@@ -343,7 +348,7 @@ func listRWOCephFSPV(listPVs *corev1.PersistentVolumeList, cluster *cephv1.CephC | |||
continue | |||
} | |||
|
|||
if pv.Spec.CSI.VolumeAttributes["staticVolume"] == "true" || pv.Spec.CSI.VolumeAttributes["pool"] == "" { | |||
if pv.Spec.CSI.VolumeAttributes["staticVolume"] == "true" || pv.Spec.CSI.VolumeAttributes["fsName"] == "" { |
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 dont need to check fsName
for a static volume if staticVolume
check is enough, i don't see when fsName can be set to empty.
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 we can simplify to this:
if pv.Spec.CSI.VolumeAttributes["staticVolume"] == "true" || pv.Spec.CSI.VolumeAttributes["fsName"] == "" { | |
if pv.Spec.CSI.VolumeAttributes["staticVolume"] == "true" { |
pkg/operator/ceph/cluster/watcher.go
Outdated
@@ -500,7 +505,11 @@ func concatenateWatcherIp(address string) string { | |||
return watcherIP | |||
} | |||
|
|||
func (c *clientCluster) createNetworkFence(ctx context.Context, pv corev1.PersistentVolume, node *corev1.Node, cluster *cephv1.CephCluster, cidr []string) error { | |||
func fenceResourceName(nodeName string, driver 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.
func fenceResourceName(nodeName string, driver string) string { | |
func fenceResourceName(nodeName , driver string) string { |
pkg/operator/ceph/cluster/watcher.go
Outdated
@@ -185,9 +185,14 @@ func (c *clientCluster) handleNodeFailure(ctx context.Context, cluster *cephv1.C | |||
return nil | |||
} | |||
|
|||
err = c.unfenceAndDeleteNetworkFence(ctx, *node, cluster) | |||
err = c.unfenceAndDeleteNetworkFence(ctx, *node, cluster, "rbd") |
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.
why hardcoding can we define a variable?
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, Thanks.
pkg/operator/ceph/cluster/watcher.go
Outdated
@@ -500,7 +505,11 @@ func concatenateWatcherIp(address string) string { | |||
return watcherIP | |||
} | |||
|
|||
func (c *clientCluster) createNetworkFence(ctx context.Context, pv corev1.PersistentVolume, node *corev1.Node, cluster *cephv1.CephCluster, cidr []string) error { | |||
func fenceResourceName(nodeName string, driver string) string { | |||
return nodeName + "-" + driver |
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.
use fmt.stringf
pkg/operator/ceph/cluster/watcher.go
Outdated
@@ -343,7 +348,7 @@ func listRWOCephFSPV(listPVs *corev1.PersistentVolumeList, cluster *cephv1.CephC | |||
continue | |||
} | |||
|
|||
if pv.Spec.CSI.VolumeAttributes["staticVolume"] == "true" || pv.Spec.CSI.VolumeAttributes["pool"] == "" { | |||
if pv.Spec.CSI.VolumeAttributes["staticVolume"] == "true" || pv.Spec.CSI.VolumeAttributes["fsName"] == "" { |
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 we can simplify to this:
if pv.Spec.CSI.VolumeAttributes["staticVolume"] == "true" || pv.Spec.CSI.VolumeAttributes["fsName"] == "" { | |
if pv.Spec.CSI.VolumeAttributes["staticVolume"] == "true" { |
9b4da07
to
c07f4ad
Compare
Thanks @Madhu-1 , for letting us know about this. |
this commit updates the name of network fence CR to node name + driver name, which will allow the creation of multiple network fence per drivers on the same node, and modifies the unit test and deletion procedure for the same. Signed-off-by: Riya Singhal <rsinghal@redhat.com>
c07f4ad
to
c2e3cf3
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.
The PR looks good, could you also confirm in local testing? The unit tests don't catch everything.
@riya-singhal31 please do the local testing, thanks |
Hi! Working as expected, These are the volumes & pods for cephFS and rbd each driver.
Scheduled on same node, to test the functionality for this PR,
Since there are 2 drivers, so we expect 2 different Network fences to be created after applying taint to the node for each driver,
The above step was the main requirement for the concern of bug and this PR. Thanks, |
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 guess ready to merge once @Madhu-1 approves.
csi: update network fence CR name (backport #13615)
this commit updates the name of network fence CR to node name + driver name, which will allow the creation of multiple network fence per drivers on the same node.
Checklist: