Skip to content

squid: Fix nvmeof gateway startup with aes256k daemon - #39

Merged
s0nea merged 4 commits into
squid-19.2.7-cobaltcore-storagefrom
backport/623
Oct 22, 2026
Merged

s0nea merged 4 commits into
squid-19.2.7-cobaltcore-storagefrom
backport/623

Conversation

@s0nea

@s0nea s0nea commented Oct 21, 2026

Copy link
Copy Markdown

Closes cobaltcore-dev/cloud-storage#623

Backport file

  • release-management/backports/<uuid>.md added (or updated) by this PR
  • id in frontmatter matches the filename stem
  • provenance.upstream_prs set (or provenance.type: other with an other: block)

Stage-B risk (filled per release-management/backports/RISK-RUBRIC.md)

  • blast — cosmetic / availability / data-loss
  • conflict — clean / trivial / substantive
  • coverage — strong / partial / weak
  • Risk-notes paragraph in the prose section (required for high band)

Merge

Land this via just merge-backport PR=<N> — do not click the green merge button.
The just recipe constructs the merge commit's Backport-Id trailer.

Since 19.2.6 cephadm creates daemon keys as aes256k (ROTATION_CIPHER).
The nvmeof gateway images for squid (quay.io/ceph/nvmeof 1.2.x, the
default 1.2.1, and the squid line 1.4.x up to 1.4.28) carry their own
librados, built before aes256k (19.0.0 dev, 19.2.3), and cannot connect
with such a key: the gateway crash-loops with "RADOS I/O error (error
connecting to the cluster)" and "Unable to create OMAP, exiting!", and
the service never comes up (orch:cephadm:smoke-roleless 2-services/nvmeof
times out on "nvmeof.foo has 0/1").

Create and rotate nvmeof keys with the previous key type (aes): a
per-daemon-type key type in utils (key_type_for), used by the nvmeof
service's keyring and by key_rotate (ceph orch daemon rotate-key). A
gateway already deployed with an aes256k key gets its key rotated to aes
on its next deploy, so `ceph orch redeploy nvmeof.<svc>` heals a failed
service.

Reproduced on a cephadm cluster: with an aes256k key, python3-rados in
quay.io/ceph/nvmeof:1.2.1, 1.2.5 and 1.4.28 fails to connect ([errno 5]);
in 1.7 (librados 20.2.4) and 2.0.0 it connects.

Fixes: https://tracker.ceph.com/issues/81778
Assisted-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Dan van der Ster <dan.vanderster@clyso.com>
Comment thread src/pybind/mgr/cephadm/utils.py Outdated


# CryptoKey type numbers (CEPH_CRYPTO_AES, CEPH_CRYPTO_AES256KRB5)
CRYPTO_KEY_TYPES = {1: 'aes', 2: 'aes256k'}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Instead strings aes and aes256k there would be better use constants: LEGACY_CIPHER and ROTATION_CIPHER.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated the PR by an additional commit.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Also, instead of magic numbers, it is better either import constant or even point where the constants are taken from:

$ grep CEPH_CRYPTO_ src/include/ceph_fs.h
#define CEPH_CRYPTO_NONE       0x0
#define CEPH_CRYPTO_AES        0x1
#define CEPH_CRYPTO_AES256KRB5 0x2 /* AES256-CTS-HMAC384-192 */

So if we don't have import them, python specific declaration would look like:

# C. f. src/include/ceph_fs.h
CEPH_CRYPTO_NONE = 0x0
CEPH_CRYPTO_AES = 0x1
CEPH_CRYPTO_AES256KRB5 = 0x2

CRYPTO_KEY_TYPES = {
  CEPH_CRYPTO_AES: LEGACY_CIPHER, 
  CEPH_CRYPTO_AES256KRB5: ROTATION_CIPHER
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

What's the reason behind CEPH_CRYPTO_NONE?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated the commit.

t = struct.unpack('<H', raw[:2])[0]
except Exception:
return None
return CRYPTO_KEY_TYPES.get(t)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What happens when t != 1 and t != 2 KeyError exception happens?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The .get() will return None if the key is not found.

CRYPTO_KEY_TYPES spelled both its cipher names and its CryptoKey type
numbers as literals, although LEGACY_CIPHER and ROTATION_CIPHER are
declared right above it. Re-use them, and name the type numbers after
the CEPH_CRYPTO_* macros they copy, pointing at the header that defines
them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Tatjana Dehler <tatjana.dehler@clyso.com>
s0nea and others added 2 commits October 22, 2026 09:51
The unit test has to be updated from 23 to 24 mentiones of the quay.io
images, because as part of 0486502 ("mgr/cephadm: give nvmeof
gateways a key they can use") a new reference has been added in a
comment.

Signed-off-by: Tatjana Dehler <tatjana.dehler@clyso.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Tatjana Dehler <tatjana.dehler@clyso.com>
@s0nea
s0nea merged commit 6a1ca82 into squid-19.2.7-cobaltcore-storage Oct 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants