Skip to content

Commit c753d39

Browse files
stackit-skexoxys
andauthored
[release-v1.31] Drop CSI with-topology and cleanups (#68)
* Drop CSI with-topology and cleanups * drop additional-topology and more cleanups * fix * fix * fix shellcheck and cleanup * fix --------- Co-authored-by: Robert Kaussow <[email protected]>
1 parent ac79ffe commit c753d39

File tree

14 files changed

+69
-99
lines changed

14 files changed

+69
-99
lines changed

cmd/stackit-csi-plugin/main.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@ import (
2020
var (
2121
endpoint string
2222
cloudConfig string
23-
additionalTopologies map[string]string
2423
cluster string
2524
httpEndpoint string
2625
provideControllerService bool
2726
provideNodeService bool
28-
withTopology bool
2927
)
3028

3129
func main() {
@@ -65,12 +63,6 @@ func main() {
6563

6664
cmd.Flags().StringVar(&cloudConfig, "cloud-config", "", "CSI driver cloud config. This option can be given multiple times")
6765

68-
cmd.PersistentFlags().BoolVar(&withTopology, "with-topology", true, "cluster is topology-aware")
69-
70-
cmd.PersistentFlags().StringToStringVar(&additionalTopologies, "additional-topology", map[string]string{},
71-
"Additional CSI driver topology keys, for example topology.kubernetes.io/region=REGION1."+
72-
"This option can be specified multiple times to add multiple additional topology keys.")
73-
7466
cmd.PersistentFlags().StringVar(&cluster, "cluster", "", "The identifier of the cluster that the plugin is running in.")
7567
cmd.PersistentFlags().StringVar(&httpEndpoint, "http-endpoint", "",
7668
"The TCP network address where the HTTP server for providing metrics for diagnostics, will listen (example: `:8080`)."+
@@ -90,20 +82,19 @@ func main() {
9082
func handle() {
9183
// Initialize cloud
9284
d := blockstorage.NewDriver(&blockstorage.DriverOpts{
93-
Endpoint: endpoint,
94-
ClusterID: cluster,
95-
PVCLister: csi.GetPVCLister(),
96-
WithTopology: withTopology,
85+
Endpoint: endpoint,
86+
ClusterID: cluster,
87+
PVCLister: csi.GetPVCLister(),
9788
})
9889

9990
if provideControllerService {
10091
var err error
101-
cfg, err := stackit.GetConfigForFile(cloudConfig)
92+
cfg, err := stackit.GetConfigFromFile(cloudConfig)
10293
if err != nil {
10394
klog.Fatal(err)
10495
}
10596

106-
iaasClient, err := stackit.CreateIAASClient(&cfg)
97+
iaasClient, err := stackit.CreateIaaSClient(&cfg)
10798
if err != nil {
10899
klog.Fatalf("Failed to create IaaS client: %v", err)
109100
}
@@ -120,15 +111,15 @@ func handle() {
120111
// Initialize mount
121112
mountProvider := mount.GetMountProvider()
122113

123-
cfg, err := stackit.GetConfigForFile(cloudConfig)
114+
cfg, err := stackit.GetConfigFromFile(cloudConfig)
124115
if err != nil {
125116
klog.Fatal(err)
126117
}
127118

128119
// Initialize Metadata
129120
metadataProvider := metadata.GetMetadataProvider(fmt.Sprintf("%s,%s", metadata.MetadataID, metadata.ConfigDriveID))
130121

131-
d.SetupNodeService(mountProvider, metadataProvider, cfg.BlockStorage, additionalTopologies)
122+
d.SetupNodeService(mountProvider, metadataProvider, cfg.BlockStorage)
132123
}
133124

134125
d.Run()

deploy/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
terminationGracePeriodSeconds: 30
2525
containers:
2626
- name: stackit-cloud-controller-manager
27-
image: ghcr.io/stackitcloud/cloud-provider-stackit:latest
27+
image: ghcr.io/stackitcloud/cloud-provider-stackit/cloud-controller-manager:release-v1.33
2828
args:
2929
- --cloud-provider=stackit
3030
- --webhook-secure-port=0

docs/csi-driver.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ storageClass:
8989
volumeBindingMode: WaitForFirstConsumer
9090
allowedTopologies:
9191
- matchLabelExpressions:
92-
- key: topology.kubernetes.io/zone
92+
- key: topology.block-storage.csi.stackit.cloud/zone
9393
values:
9494
- zone1
9595
- zone2

docs/deployment.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
5. [Example Deployment](#example-deployment)
1212
6. [Configuration Options](#configuration-options)
1313
- [Cloud Configuration](#cloud-configuration)
14-
- [Topology Configuration](#topology-configuration)
1514
7. [Monitoring and Logging](#monitoring-and-logging)
1615
- [Metrics](#metrics)
1716
- [Logs](#logs)
@@ -46,8 +45,6 @@ The deployment can be customized using the following flags:
4645

4746
- `--endpoint`: CSI endpoint URL
4847
- `--cloud-config`: Path to cloud configuration file
49-
- `--with-topology`: Enable topology awareness (default: true)
50-
- `--additional-topology`: Additional topology keys for volume placement
5148
- `--cluster`: Cluster identifier
5249
- `--http-endpoint`: HTTP server endpoint for metrics
5350
- `--provide-controller-service`: Enable controller service (default: true)
@@ -84,7 +81,7 @@ spec:
8481
serviceAccountName: stackit-cloud-controller-manager
8582
containers:
8683
- name: stackit-cloud-controller-manager
87-
image: ghcr.io/stackitcloud/cloud-provider-stackit:latest
84+
image: ghcr.io/stackitcloud/cloud-provider-stackit/cloud-controller-manager:release-v1.33
8885
args:
8986
# CCM flags
9087
- --cloud-provider=stackit
@@ -97,8 +94,6 @@ spec:
9794
# CSI flags
9895
- --endpoint=unix:///csi/csi.sock
9996
- --cloud-config=/etc/stackit/cloud-config.yaml
100-
- --with-topology=true
101-
- --additional-topology=topology.kubernetes.io/region=REGION1
10297
- --cluster=my-cluster-id
10398
- --provide-controller-service=true
10499
- --provide-node-service=true
@@ -137,17 +132,6 @@ loadBalancerApi:
137132
url: https://load-balancer.api.eu01.stackit.cloud
138133
```
139134

140-
### Topology Configuration
141-
142-
The driver supports topology-aware volume placement. Configure topology using the `--with-topology` and `--additional-topology` flags.
143-
144-
Example with multiple topology keys:
145-
146-
```bash
147-
--with-topology=true
148-
--additional-topology=topology.kubernetes.io/region=REGION1,topology.kubernetes.io/zone=ZONE1
149-
```
150-
151135
## Monitoring and Logging
152136

153137
### Metrics

hack/common.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,30 @@
33
# See https://misc.flogisoft.com/bash/tip_colors_and_formatting
44

55
color-green() { # Green
6-
echo -e "\x1B[1;32m${@}\x1B[0m"
6+
echo -e "\x1B[1;32m${*}\x1B[0m"
77
}
88

99
color-step() { # Yellow
10-
echo -e "\x1B[1;33m${@}\x1B[0m"
10+
echo -e "\x1B[1;33m${*}\x1B[0m"
1111
}
1212

1313
color-context() { # Bold blue
14-
echo -e "\x1B[1;34m${@}\x1B[0m"
14+
echo -e "\x1B[1;34m${*}\x1B[0m"
1515
}
1616

1717
color-missing() { # Yellow
18-
echo -e "\x1B[1;33m${@}\x1B[0m"
18+
echo -e "\x1B[1;33m${*}\x1B[0m"
1919
}
2020

2121
prepare_token() {
2222
local namespace="$1"
2323
local name="$2"
24-
local rolekind="$(echo "$3" | tr '[:upper:]' '[:lower:]')"
2524
local role="$4"
2625
local duration="${5:-10m}"
2726

27+
local rolekind
28+
rolekind="$(echo "$3" | tr '[:upper:]' '[:lower:]')"
29+
2830
result="$(kubectl -n "$namespace" create serviceaccount "$name" 2>&1)"
2931
# ignore "already exists" errors
3032
if ! [[ "$result" == *"created"* ]] && ! [[ "$result" == *"already exists"* ]] ; then
@@ -44,10 +46,12 @@ prepare_token() {
4446
prepare_access() {
4547
local namespace="$1"
4648
local name="$2"
47-
local rolekind="$(echo "$3" | tr '[:upper:]' '[:lower:]')"
4849
local role="$4"
4950
local tmp_kubeconfig="$5"
5051

52+
local rolekind
53+
rolekind="$(echo "$3" | tr '[:upper:]' '[:lower:]')"
54+
5155
color-step "Preparing access for $name"
5256

5357
local token
@@ -71,10 +75,12 @@ prepare_access() {
7175
cleanup_access() {
7276
local namespace="$1"
7377
local name="$2"
74-
local rolekind="$(echo "$3" | tr '[:upper:]' '[:lower:]')"
7578
local role="$4"
7679
local tmp_kubeconfig="$5"
7780

81+
local rolekind
82+
rolekind="$(echo "$3" | tr '[:upper:]' '[:lower:]')"
83+
7884
color-step "Cleaning up cluster access for $name"
7985

8086
rm "$tmp_kubeconfig"

hack/test.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@ set -o errexit
44
set -o nounset
55
set -o pipefail
66

7+
# shellcheck disable=SC1091
78
source "$(dirname "$0")/common.sh"
89

910
echo "> Unit Tests"
1011

11-
test_flags=
12+
test_flags=()
1213
# If running in Prow, we want to generate a machine-readable output file under the location specified via $ARTIFACTS.
1314
# This will add a JUnit view above the build log that shows an overview over successful and failed test cases.
1415
if [ -n "${CI:-}" ] && [ -n "${ARTIFACTS:-}" ]; then
1516
mkdir -p "$ARTIFACTS/junit"
17+
# shellcheck disable=SC2064
1618
trap "collect_reports \"$ARTIFACTS/junit\"" EXIT
17-
test_flags="--ginkgo.junit-report=junit.xml"
19+
test_flags+=(--ginkgo.junit-report=junit.xml)
1820
# Use Ginkgo timeout in Prow to print everything that is buffered in GinkgoWriter.
19-
test_flags+=" --ginkgo.timeout=2m"
21+
test_flags+=(--ginkgo.timeout=2m)
2022
else
2123
# We don't want Ginkgo's timeout flag locally because it causes skipping the test cache.
2224
timeout_flag="-timeout=2m"
2325
fi
2426

25-
go test ${timeout_flag:-} "$@" $test_flags
27+
go test ${timeout_flag:+"$timeout_flag"} "$@" "${test_flags[@]}"

pkg/csi/blockstorage/controllerserver.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,14 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
105105
volSizeGB := util.RoundUpSize(volSizeBytes, util.GIBIBYTE)
106106

107107
var volAvailability string
108-
if cs.Driver.withTopology {
109-
// First check if volAvailability is already specified, if not get preferred from Topology
110-
// Required, incase vol AZ is different from node AZ
111-
volAvailability = ptr.Deref(volParams.AvailabilityZone, "")
112-
if volAvailability == "" {
113-
accessibleTopologyReq := req.GetAccessibilityRequirements()
114-
// Check from Topology
115-
if accessibleTopologyReq != nil {
116-
volAvailability = sharedcsi.GetAZFromTopology(topologyKey, accessibleTopologyReq)
117-
}
108+
// First check if volAvailability is already specified, if not, get preferred from topology
109+
// Required, in case volume AZ is different from node AZ
110+
volAvailability = ptr.Deref(volParams.AvailabilityZone, "")
111+
if volAvailability == "" {
112+
accessibleTopologyReq := req.GetAccessibilityRequirements()
113+
// Check from topology
114+
if accessibleTopologyReq != nil {
115+
volAvailability = sharedcsi.GetAZFromTopology(topologyKey, accessibleTopologyReq)
118116
}
119117
}
120118

pkg/csi/blockstorage/controllerserver_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var _ = Describe("ControllerServer test", Ordered, func() {
4949
)
5050

5151
BeforeEach(func() {
52-
d := NewDriver(&DriverOpts{Endpoint: FakeEndpoint, ClusterID: FakeCluster, WithTopology: true})
52+
d := NewDriver(&DriverOpts{Endpoint: FakeEndpoint, ClusterID: FakeCluster})
5353

5454
mockCtrl := gomock.NewController(GinkgoT())
5555
iaasClient = stackit.NewMockIaasClient(mockCtrl)

pkg/csi/blockstorage/driver.go

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ var (
2828
)
2929

3030
type Driver struct {
31-
name string
32-
fqVersion string // Fully qualified version in format {Version}@{CPO version}
33-
endpoint string
34-
clusterID string
35-
withTopology bool
31+
name string
32+
fqVersion string // Fully qualified version in format {Version}@{CPO version}
33+
endpoint string
34+
clusterID string
3635

3736
ids *identityServer
3837
cs *controllerServer
@@ -47,27 +46,24 @@ type Driver struct {
4746
}
4847

4948
type DriverOpts struct {
50-
ClusterID string
51-
Endpoint string
52-
WithTopology bool
49+
ClusterID string
50+
Endpoint string
5351

5452
PVCLister corev1.PersistentVolumeClaimLister
5553
}
5654

5755
func NewDriver(o *DriverOpts) *Driver {
5856
d := &Driver{
59-
name: driverName,
60-
fqVersion: fmt.Sprintf("%s@%s", Version, version.Version),
61-
endpoint: o.Endpoint,
62-
clusterID: o.ClusterID,
63-
withTopology: o.WithTopology,
64-
pvcLister: o.PVCLister,
57+
name: driverName,
58+
fqVersion: fmt.Sprintf("%s@%s", Version, version.Version),
59+
endpoint: o.Endpoint,
60+
clusterID: o.ClusterID,
61+
pvcLister: o.PVCLister,
6562
}
6663

6764
klog.Info("Driver: ", d.name)
6865
klog.Info("Driver version: ", d.fqVersion)
6966
klog.Info("CSI Spec version: ", specVersion)
70-
klog.Infof("Topology awareness: %t", d.withTopology)
7167

7268
d.AddControllerServiceCapabilities(
7369
[]csi.ControllerServiceCapability_RPC_Type{
@@ -142,9 +138,9 @@ func (d *Driver) SetupControllerService(instance stackit.IaasClient) {
142138
d.cs = NewControllerServer(d, instance)
143139
}
144140

145-
func (d *Driver) SetupNodeService(mountProvider mount.IMount, metadataProvider metadata.IMetadata, opts stackit.BlockStorageOpts, topologies map[string]string) {
141+
func (d *Driver) SetupNodeService(mountProvider mount.IMount, metadataProvider metadata.IMetadata, opts stackit.BlockStorageOpts) {
146142
klog.Info("Providing node service")
147-
d.ns = NewNodeServer(d, mountProvider, metadataProvider, opts, topologies)
143+
d.ns = NewNodeServer(d, mountProvider, metadataProvider, opts)
148144
}
149145

150146
func (d *Driver) Run() {

pkg/csi/blockstorage/nodeserver.go

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ import (
4040
)
4141

4242
type nodeServer struct {
43-
Driver *Driver
44-
Mount mount.IMount
45-
Metadata metadata.IMetadata
46-
Opts stackit.BlockStorageOpts
47-
Topologies map[string]string
43+
Driver *Driver
44+
Mount mount.IMount
45+
Metadata metadata.IMetadata
46+
Opts stackit.BlockStorageOpts
4847
csi.UnimplementedNodeServer
4948
}
5049

@@ -318,20 +317,17 @@ func (ns *nodeServer) NodeGetInfo(ctx context.Context, _ *csi.NodeGetInfoRequest
318317
MaxVolumesPerNode: maxVolumesPerNode,
319318
}
320319

321-
if !ns.Driver.withTopology {
322-
return nodeInfo, nil
323-
}
324-
325320
zone, err := ns.Metadata.GetAvailabilityZone(ctx)
326321
if err != nil {
327322
return nil, status.Errorf(codes.Internal, "[NodeGetInfo] Unable to retrieve availability zone of node %v", err)
328323
}
329-
topologyMap := make(map[string]string, len(ns.Topologies)+1)
330-
topologyMap[topologyKey] = zone
331-
for k, v := range ns.Topologies {
332-
topologyMap[k] = v
324+
325+
//TODO: support well-known topology key "topology.kubernetes.io/zone"
326+
segments := map[string]string{
327+
topologyKey: zone,
333328
}
334-
nodeInfo.AccessibleTopology = &csi.Topology{Segments: topologyMap}
329+
330+
nodeInfo.AccessibleTopology = &csi.Topology{Segments: segments}
335331

336332
return nodeInfo, nil
337333
}

0 commit comments

Comments
 (0)