Skip to content

Commit e5547c9

Browse files
kvapsclaude
andcommitted
fix(store): uppercase satelliteEncryptionType + node Type for CRD enum
Upstream LINSTOR (and golinstor + piraeus-csi node-init) sends satellite_encryption_type as "plain" / "ssl" lowercase. The CRD spec enforces an enum of "PLAIN" / "SSL" only, so PUT /v1/nodes returned 500 with a kubebuilder validation error. Normalise on the way into the CRD store; the wire shape stays whatever the caller sent. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
1 parent 93bfa0f commit e5547c9

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

pkg/store/k8s/nodes.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package k8s
1919
import (
2020
"context"
2121
"sort"
22+
"strings"
2223

2324
"github.com/cockroachdb/errors"
2425
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -207,9 +208,12 @@ func wireToCRDNode(in *apiv1.Node) *crdv1alpha1.Node {
207208
}
208209

209210
// wireToCRDNodeSpec is the spec-only converter used by both Create and Update.
211+
// SatelliteEncryptionType is uppercased on the way in: upstream LINSTOR
212+
// accepts mixed case ("plain"/"PLAIN") but the CRD validation enum is
213+
// uppercase-only, so we normalise here to keep wire compatibility.
210214
func wireToCRDNodeSpec(in *apiv1.Node) crdv1alpha1.NodeSpec {
211215
spec := crdv1alpha1.NodeSpec{
212-
Type: in.Type,
216+
Type: strings.ToUpper(in.Type),
213217
Props: in.Props,
214218
Flags: in.Flags,
215219
}
@@ -222,7 +226,7 @@ func wireToCRDNodeSpec(in *apiv1.Node) crdv1alpha1.NodeSpec {
222226
Name: ni.Name,
223227
Address: ni.Address,
224228
SatellitePort: int32(ni.SatellitePort), //nolint:gosec // upstream LINSTOR ports fit in int32
225-
SatelliteEncryptionType: ni.SatelliteEncryptionType,
229+
SatelliteEncryptionType: strings.ToUpper(ni.SatelliteEncryptionType),
226230
})
227231
}
228232
}

stand/csi-sanity-job.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ spec:
1515
template:
1616
spec:
1717
restartPolicy: Never
18+
initContainers:
19+
# csi-sanity is launched with --node=csi-sanity-node, so
20+
# linstor-csi expects that name to exist as a Node before any
21+
# CreateVolume call. Pre-register it as a SATELLITE — we don't
22+
# care about its actual presence; the topology lookup just
23+
# needs an entry.
24+
- name: register-csi-sanity-node
25+
image: curlimages/curl:8.10.1
26+
command:
27+
- sh
28+
- -c
29+
- |
30+
set -e
31+
curl -fsS -XPOST -H 'content-type: application/json' \
32+
http://blockstor-controller.blockstor-system.svc:3370/v1/nodes \
33+
-d '{"name":"csi-sanity-node","type":"SATELLITE","net_interfaces":[{"name":"default","address":"127.0.0.1","satellite_port":3366,"satellite_encryption_type":"PLAIN"}]}' \
34+
|| true
1835
containers:
1936
- name: linstor-csi
2037
image: quay.io/piraeusdatastore/piraeus-csi:v1.10.1

0 commit comments

Comments
 (0)