Skip to content

Conversation

@GanghyeonSeo
Copy link
Contributor

Fixed an issue where runningimport-external-cluster.sh in the Rook consumer cluster would result in a for: 1: Syntax error: end of file unexpected (expecting "done") error when the exported config from the Ceph provider cluster (generated via create-external-cluster-resources.py) includes RADOS_NAMESPACE and SUBVOLUME_GROUP values.

Additionally, updated the message shown while waiting for the CephFilesystemSubVolumeGroup CR to reach the Ready status.

Related to the issue below:
#16645

Checklist:

  • Commit Message Formatting: Commit titles and messages follow guidelines in the developer guide.
  • Reviewed the developer guide on Submitting a Pull Request
  • Pending release notes updated with breaking and/or notable changes for the next minor release.
  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • Integration tests have been added, if necessary.

@GanghyeonSeo
Copy link
Contributor Author

Hello @parth-gr
Just wanted to gently check in if you might have some time to review this when you're available.
No rush at all — really appreciate your time. Thanks!

if [ -n "$RADOS_NAMESPACE" ]; then
createRadosNamespaceCR
timeout 20 sh -c "until [ $($KUBECTL -n "$NAMESPACE" get CephBlockPoolRadosNamespace/"$RADOS_NAMESPACE" -o jsonpath='{.status.phase}' | grep -c "Ready") -eq 1 ]; do echo "waiting for radosNamespace to get created" && sleep 1; done"
timeout 20 sh -c "until [ \$($KUBECTL -n \"$NAMESPACE\" get CephBlockPoolRadosNamespace/\"$RADOS_NAMESPACE\" -o jsonpath='{.status.phase}' | grep -c 'Ready') -eq 1 ]; do echo 'waiting for radosNamespace to get created' && sleep 1; done"
Copy link
Member

Choose a reason for hiding this comment

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

the earlier version of script work well for me,
But at the same time the changes look good,

Can you share the sample output of the RADOS_NAMESPACE, that you are exporting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since I re-initialized and reset the Rook-Ceph cluster, I can no longer verify the exact RADOS_NAMESPACE value that was used previously.
However, I was able to confirm the SUBVOLUME_GROUP value, as it is still in use.

When generated via create-external-cluster-resources.py, the output was:
export SUBVOLUME_GROUP=external

Using this value and running import-external-cluster.sh resulted in the same error described in the issue:
Syntax error: end of file unexpected (expecting "done")

Additionally, the structure of the script that waits for resources to become ready—specifically the sections handling both:
• CephBlockPoolRadosNamespace/"$RADOS_NAMESPACE"
• CephFilesystemSubVolumeGroup/"$SUBVOLUME_GROUP"

—is identical inside the importClusterID function, and the root cause is the same quotation parsing issue.

Because of this, I believe the same fix should be applied to both parts.
Thanks for your time.

Copy link
Member

Choose a reason for hiding this comment

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

ack,
cc @travisn please add your thoughts

Copy link
Member

Choose a reason for hiding this comment

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

The changes make sense to me, so the evaluation of the variables is deferred until their execution instead of being evaluated immediately when the script is parsed.

@parth-gr parth-gr requested a review from travisn November 11, 2025 14:16
if [ -n "$SUBVOLUME_GROUP" ]; then
createSubvolumeGroupCR
timeout 20 sh -c "until [ $($KUBECTL -n "$NAMESPACE" get CephFilesystemSubVolumeGroup/"$SUBVOLUME_GROUP" -o jsonpath='{.status.phase}' | grep -c "Ready") -eq 1 ]; do echo "waiting for radosNamespace to get created" && sleep 1; done"
timeout 20 sh -c "until [ \$($KUBECTL -n \"$NAMESPACE\" get CephFilesystemSubVolumeGroup/\"$SUBVOLUME_GROUP\" -o jsonpath='{.status.phase}' | grep -c 'Ready') -eq 1 ]; do echo 'waiting for subVolumeGroup to get created' && sleep 1; done"
Copy link
Member

Choose a reason for hiding this comment

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

Do you really need to add the quotes around \"$SUBVOLUME_GROUP\"? Seems like that shouldn't be necessary since the CR name will not have spaces.

Copy link
Contributor Author

@GanghyeonSeo GanghyeonSeo Nov 11, 2025

Choose a reason for hiding this comment

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

Yes, that makes sense. I think I can remove the quotes and use $SUBVOLUME_GROUP directly.

The same applies to the CephBlockPoolRadosNamespace/\"$RADOS_NAMESPACE\" part. If that looks good, I’ll update both accordingly. Thank you!

Fixed a syntax error caused by incorrect quotation parsing in the importClusterID function of import-external-cluster.sh, and updated the output message shown while waiting for the SubVolumeGroup CR to be created.

Signed-off-by: GanghyeonSeo <sgh000109@gmail.com>
@GanghyeonSeo
Copy link
Contributor Author

@travisn
Thank you for your review. One of the tests is failing — would that be okay?

@travisn
Copy link
Member

travisn commented Nov 11, 2025

The CI issue is unrelated

@travisn travisn merged commit 02c1971 into rook:master Nov 11, 2025
55 of 56 checks passed
subhamkrai added a commit that referenced this pull request Nov 12, 2025
external: fix quote parsing and message in import-external-cluster.sh (backport #16646)
if [ -n "$RADOS_NAMESPACE" ]; then
createRadosNamespaceCR
timeout 20 sh -c "until [ $($KUBECTL -n "$NAMESPACE" get CephBlockPoolRadosNamespace/"$RADOS_NAMESPACE" -o jsonpath='{.status.phase}' | grep -c "Ready") -eq 1 ]; do echo "waiting for radosNamespace to get created" && sleep 1; done"
timeout 20 sh -c "until [ \$($KUBECTL -n \"$NAMESPACE\" get CephBlockPoolRadosNamespace/$RADOS_NAMESPACE -o jsonpath='{.status.phase}' | grep -c 'Ready') -eq 1 ]; do echo 'waiting for radosNamespace to get created' && sleep 1; done"
Copy link
Member

Choose a reason for hiding this comment

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

@travisn @GanghyeonSeo mine question is why not to delay rados namespace expansion too?

\"\$RADOS_NAMESPACE\"

Another question, as the variables are defined in the outer shell so why we need to delay the expansion?

Copy link
Contributor Author

@GanghyeonSeo GanghyeonSeo Nov 12, 2025

Choose a reason for hiding this comment

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

It works without errors in its current form, after reconsidering based on your feedback, I came to the following conclusion:

Since the variables are defined in the outer shell and the value for KUBECTL is assigned inside the shell script, $NAMESPACE, $RADOS_NAMESPACE, and $SUBVOLUME_GROUP do not require delayed expansion — The script runs correctly without delayed expansion.

However, the kubectl invocation itself must remain escaped as \$($KUBECTL ...) to ensure it is evaluated in the inner shell.

Do you think strict consistency in quotation style is necessary here?
If so, for the following part:
-n \"$NAMESPACE\" get CephBlockPoolRadosNamespace/$RADOS_NAMESPACE

Which of the following would be better to standardize?

  1. -n "$NAMESPACE" get CephBlockPoolRadosNamespace/"$RADOS_NAMESPACE"
  2. -n $NAMESPACE get CephBlockPoolRadosNamespace/$RADOS_NAMESPACE

This would also apply to the SubvolumeGroup part as well.
The existing escaping for \$($KUBECTL ...) and the quotation style(single quotation) in the waiting log message should remain unchanged. Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

First one looks good
-n "$NAMESPACE" get CephBlockPoolRadosNamespace/"$RADOS_NAMESPACE"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. I will proceed with the changes based on this and open a new PR.
Thank you for your guidance.

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’ve applied the changes and opened a new PR.
You can find it here: #16706

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants