Skip to content

Commit 6026fcb

Browse files
authored
Fix volume mount errors under pod events section (#240)
* return response if non empty Signed-off-by: Ashima-Ashima1 <[email protected]> * publish tag Signed-off-by: Ashima-Ashima1 <[email protected]> * return response if non empty Signed-off-by: Ashima-Ashima1 <[email protected]> * return response if non empty Signed-off-by: Ashima-Ashima1 <[email protected]> * return response if non empty Signed-off-by: Ashima-Ashima1 <[email protected]> * add uts Signed-off-by: Ashima-Ashima1 <[email protected]> * add uts Signed-off-by: Ashima-Ashima1 <[email protected]> * add uts Signed-off-by: Ashima-Ashima1 <[email protected]> * add uts Signed-off-by: Ashima-Ashima1 <[email protected]> --------- Signed-off-by: Ashima-Ashima1 <[email protected]>
1 parent 2056bf1 commit 6026fcb

File tree

9 files changed

+152
-37
lines changed

9 files changed

+152
-37
lines changed

.secrets.baseline

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2025-07-24T10:06:47Z",
6+
"generated_at": "2025-07-28T06:01:06Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"
@@ -190,7 +190,7 @@
190190
"hashed_secret": "2ace62c1befa19e3ea37dd52be9f6d508c5163e6",
191191
"is_secret": false,
192192
"is_verified": false,
193-
"line_number": 264,
193+
"line_number": 270,
194194
"type": "Secret Keyword",
195195
"verified_result": null
196196
}

go.mod

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ require (
1515
github.com/kubernetes-csi/csi-test/v5 v5.3.1
1616
github.com/mitchellh/go-ps v1.0.0
1717
github.com/onsi/ginkgo/v2 v2.23.4
18-
github.com/onsi/gomega v1.37.0
18+
github.com/onsi/gomega v1.38.0
1919
github.com/prometheus/client_golang v1.22.0
2020
github.com/stretchr/testify v1.10.0
2121
go.uber.org/zap v1.27.0
2222
golang.org/x/net v0.42.0
23-
google.golang.org/grpc v1.73.0
23+
google.golang.org/grpc v1.74.2
2424
google.golang.org/protobuf v1.36.6
2525
k8s.io/api v0.33.3
2626
k8s.io/apimachinery v0.33.3
@@ -31,7 +31,7 @@ require (
3131
)
3232

3333
require (
34-
cel.dev/expr v0.23.0 // indirect
34+
cel.dev/expr v0.24.0 // indirect
3535
github.com/BurntSushi/toml v1.0.0 // indirect
3636
github.com/IBM/secret-utils-lib v1.1.14 // indirect
3737
github.com/JeffAshton/win_pdh v0.0.0-20161109143554-76bb4ee9f0ab // indirect
@@ -64,7 +64,7 @@ require (
6464
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
6565
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
6666
github.com/gin-contrib/sse v0.1.0 // indirect
67-
github.com/go-logr/logr v1.4.2 // indirect
67+
github.com/go-logr/logr v1.4.3 // indirect
6868
github.com/go-logr/stdr v1.2.2 // indirect
6969
github.com/go-openapi/errors v0.22.0 // indirect
7070
github.com/go-openapi/jsonpointer v0.21.0 // indirect
@@ -132,27 +132,27 @@ require (
132132
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
133133
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.58.0 // indirect
134134
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 // indirect
135-
go.opentelemetry.io/otel v1.35.0 // indirect
135+
go.opentelemetry.io/otel v1.36.0 // indirect
136136
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0 // indirect
137137
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0 // indirect
138-
go.opentelemetry.io/otel/metric v1.35.0 // indirect
139-
go.opentelemetry.io/otel/sdk v1.35.0 // indirect
140-
go.opentelemetry.io/otel/trace v1.35.0 // indirect
138+
go.opentelemetry.io/otel/metric v1.36.0 // indirect
139+
go.opentelemetry.io/otel/sdk v1.36.0 // indirect
140+
go.opentelemetry.io/otel/trace v1.36.0 // indirect
141141
go.opentelemetry.io/proto/otlp v1.4.0 // indirect
142142
go.uber.org/automaxprocs v1.6.0 // indirect
143143
go.uber.org/multierr v1.11.0 // indirect
144144
golang.org/x/arch v0.8.0 // indirect
145145
golang.org/x/crypto v0.40.0 // indirect
146146
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
147-
golang.org/x/oauth2 v0.28.0 // indirect
147+
golang.org/x/oauth2 v0.30.0 // indirect
148148
golang.org/x/sync v0.16.0 // indirect
149149
golang.org/x/sys v0.34.0 // indirect
150150
golang.org/x/term v0.33.0 // indirect
151151
golang.org/x/text v0.27.0 // indirect
152152
golang.org/x/time v0.9.0 // indirect
153153
golang.org/x/tools v0.34.0 // indirect
154-
google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463 // indirect
155-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 // indirect
154+
google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a // indirect
155+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect
156156
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
157157
gopkg.in/inf.v0 v0.9.1 // indirect
158158
gopkg.in/yaml.v2 v2.4.0 // indirect

go.sum

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
cel.dev/expr v0.23.0 h1:wUb94w6OYQS4uXraxo9U+wUAs9jT47Xvl4iPgAwM2ss=
2-
cel.dev/expr v0.23.0/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw=
1+
cel.dev/expr v0.24.0 h1:56OvJKSH3hDGL0ml5uSxZmz3/3Pq4tJ+fb1unVLAFcY=
2+
cel.dev/expr v0.24.0/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw=
33
github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU=
44
github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
55
github.com/IBM/go-sdk-core/v5 v5.20.1 h1:dzeyifh1kfRLw8VfAIIS5okZYuqLTqplPZP/Kcsgdlo=
@@ -93,8 +93,8 @@ github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm
9393
github.com/gin-gonic/gin v1.10.1 h1:T0ujvqyCSqRopADpgPgiTT63DUQVSfojyME59Ei63pQ=
9494
github.com/gin-gonic/gin v1.10.1/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
9595
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
96-
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
97-
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
96+
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
97+
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
9898
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
9999
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
100100
github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ=
@@ -230,8 +230,8 @@ github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
230230
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
231231
github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus=
232232
github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8=
233-
github.com/onsi/gomega v1.37.0 h1:CdEG8g0S133B4OswTDC/5XPSzE1OeP29QOioj2PID2Y=
234-
github.com/onsi/gomega v1.37.0/go.mod h1:8D9+Txp43QWKhM24yyOBEdpkzN8FvJyAwecBgsU4KU0=
233+
github.com/onsi/gomega v1.38.0 h1:c/WX+w8SLAinvuKKQFh77WEucCnPk4j2OTUr7lt7BeY=
234+
github.com/onsi/gomega v1.38.0/go.mod h1:OcXcwId0b9QsE7Y49u+BTrL4IdKOBOKnD6VQNTJEB6o=
235235
github.com/opencontainers/cgroups v0.0.1 h1:MXjMkkFpKv6kpuirUa4USFBas573sSAY082B4CiHEVA=
236236
github.com/opencontainers/cgroups v0.0.1/go.mod h1:s8lktyhlGUqM7OSRL5P7eAW6Wb+kWPNvt4qvVfzA5vs=
237237
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
@@ -301,20 +301,20 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.5
301301
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.58.0/go.mod h1:HDBUsEjOuRC0EzKZ1bSaRGZWUBAzo+MhAcUUORSr4D0=
302302
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0 h1:yd02MEjBdJkG3uabWP9apV+OuWRIXGDuJEUJbOHmCFU=
303303
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.58.0/go.mod h1:umTcuxiv1n/s/S6/c2AT/g2CQ7u5C59sHDNmfSwgz7Q=
304-
go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ=
305-
go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y=
304+
go.opentelemetry.io/otel v1.36.0 h1:UumtzIklRBY6cI/lllNZlALOF5nNIzJVb16APdvgTXg=
305+
go.opentelemetry.io/otel v1.36.0/go.mod h1:/TcFMXYjyRNh8khOAO9ybYkqaDBb/70aVwkNML4pP8E=
306306
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0 h1:Vh5HayB/0HHfOQA7Ctx69E/Y/DcQSMPpKANYVMQ7fBA=
307307
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0/go.mod h1:cpgtDBaqD/6ok/UG0jT15/uKjAY8mRA53diogHBg3UI=
308308
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0 h1:5pojmb1U1AogINhN3SurB+zm/nIcusopeBNp42f45QM=
309309
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0/go.mod h1:57gTHJSE5S1tqg+EKsLPlTWhpHMsWlVmer+LA926XiA=
310-
go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M=
311-
go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE=
312-
go.opentelemetry.io/otel/sdk v1.35.0 h1:iPctf8iprVySXSKJffSS79eOjl9pvxV9ZqOWT0QejKY=
313-
go.opentelemetry.io/otel/sdk v1.35.0/go.mod h1:+ga1bZliga3DxJ3CQGg3updiaAJoNECOgJREo9KHGQg=
314-
go.opentelemetry.io/otel/sdk/metric v1.35.0 h1:1RriWBmCKgkeHEhM7a2uMjMUfP7MsOF5JpUCaEqEI9o=
315-
go.opentelemetry.io/otel/sdk/metric v1.35.0/go.mod h1:is6XYCUMpcKi+ZsOvfluY5YstFnhW0BidkR+gL+qN+w=
316-
go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs=
317-
go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=
310+
go.opentelemetry.io/otel/metric v1.36.0 h1:MoWPKVhQvJ+eeXWHFBOPoBOi20jh6Iq2CcCREuTYufE=
311+
go.opentelemetry.io/otel/metric v1.36.0/go.mod h1:zC7Ks+yeyJt4xig9DEw9kuUFe5C3zLbVjV2PzT6qzbs=
312+
go.opentelemetry.io/otel/sdk v1.36.0 h1:b6SYIuLRs88ztox4EyrvRti80uXIFy+Sqzoh9kFULbs=
313+
go.opentelemetry.io/otel/sdk v1.36.0/go.mod h1:+lC+mTgD+MUWfjJubi2vvXWcVxyr9rmlshZni72pXeY=
314+
go.opentelemetry.io/otel/sdk/metric v1.36.0 h1:r0ntwwGosWGaa0CrSt8cuNuTcccMXERFwHX4dThiPis=
315+
go.opentelemetry.io/otel/sdk/metric v1.36.0/go.mod h1:qTNOhFDfKRwX0yXOqJYegL5WRaW376QbB7P4Pb0qva4=
316+
go.opentelemetry.io/otel/trace v1.36.0 h1:ahxWNuqZjpdiFAyrIoQ4GIiAIhxAunQR6MUoKrsNd4w=
317+
go.opentelemetry.io/otel/trace v1.36.0/go.mod h1:gQ+OnDZzrybY4k4seLzPAWNwVBBVlF2szhehOBB/tGA=
318318
go.opentelemetry.io/proto/otlp v1.4.0 h1:TA9WRvW6zMwP+Ssb6fLoUIuirti1gGbP28GcKG1jgeg=
319319
go.opentelemetry.io/proto/otlp v1.4.0/go.mod h1:PPBWZIP98o2ElSqI35IHfu7hIhSwvc5N38Jw8pXuGFY=
320320
go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
@@ -345,8 +345,8 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
345345
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
346346
golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
347347
golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8=
348-
golang.org/x/oauth2 v0.28.0 h1:CrgCKl8PPAVtLnU3c+EDw6x11699EWlsDeWNWKdIOkc=
349-
golang.org/x/oauth2 v0.28.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
348+
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
349+
golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU=
350350
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
351351
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
352352
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -384,12 +384,12 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
384384
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
385385
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
386386
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
387-
google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463 h1:hE3bRWtU6uceqlh4fhrSnUyjKHMKB9KrTLLG+bc0ddM=
388-
google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463/go.mod h1:U90ffi8eUL9MwPcrJylN5+Mk2v3vuPDptd5yyNUiRR8=
389-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 h1:e0AIkUUhxyBKh6ssZNrAMeqhA7RKUj42346d1y02i2g=
390-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
391-
google.golang.org/grpc v1.73.0 h1:VIWSmpI2MegBtTuFt5/JWy2oXxtjJ/e89Z70ImfD2ok=
392-
google.golang.org/grpc v1.73.0/go.mod h1:50sbHOUqWoCQGI8V2HQLJM0B+LMlIUjNSZmow7EVBQc=
387+
google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a h1:SGktgSolFCo75dnHJF2yMvnns6jCmHFJ0vE4Vn2JKvQ=
388+
google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a/go.mod h1:a77HrdMjoeKbnd2jmgcWdaS++ZLZAEq3orIOAEIKiVw=
389+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a h1:v2PbRU4K3llS09c7zodFpNePeamkAwG3mPrAery9VeE=
390+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A=
391+
google.golang.org/grpc v1.74.2 h1:WoosgB65DlWVC9FqI82dGsZhWFNBSLjQ84bjROOpMu4=
392+
google.golang.org/grpc v1.74.2/go.mod h1:CtQ+BGjaAIXHs/5YS3i473GqwBBa1zGQNevxdeBEXrM=
393393
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
394394
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
395395
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

pkg/driver/fileOps_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,22 @@ func (m *mockSocketPermission) Chmod(name string, mode os.FileMode) error {
5656
return m.chmodErr
5757
}
5858

59+
func TestChown(t *testing.T) {
60+
t.Run("", func(t *testing.T) {
61+
f := opsSocketPermission{}
62+
err := f.Chown("test-name", 0, 0)
63+
assert.Error(t, err)
64+
})
65+
}
66+
67+
func TestChmod(t *testing.T) {
68+
t.Run("", func(t *testing.T) {
69+
f := opsSocketPermission{}
70+
err := f.Chmod("test-name", os.ModeDir)
71+
assert.Error(t, err)
72+
})
73+
}
74+
5975
func TestSetupSidecar(t *testing.T) {
6076
tests := []struct {
6177
name string

pkg/mounter/mounter-rclone.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ func (rclone *RcloneMounter) Mount(source string, target string) error {
213213
response, err := mounterRequest(payload, "http://unix/api/cos/mount")
214214
klog.Info("Worker Mounting...", response)
215215
if err != nil {
216+
if strings.TrimSpace(response) != "" {
217+
return parseErrFromResponse(response)
218+
}
216219
return err
217220
}
218221
return nil
@@ -232,6 +235,9 @@ func (rclone *RcloneMounter) Unmount(target string) error {
232235
response, err := mounterRequest(payload, "http://unix/api/cos/unmount")
233236
klog.Info("Worker Unmounting...", response)
234237
if err != nil {
238+
if strings.TrimSpace(response) != "" {
239+
return parseErrFromResponse(response)
240+
}
235241
return err
236242
}
237243

pkg/mounter/mounter-rclone_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,28 @@ func TestRcloneMount_WorkerNode_Negative(t *testing.T) {
186186
assert.Contains(t, err.Error(), "failed to create http request")
187187
}
188188

189+
func TestRcloneMount_WorkerNode_FailedToParseError(t *testing.T) {
190+
mountWorker = true
191+
192+
MakeDir = func(path string, perm os.FileMode) error {
193+
return nil
194+
}
195+
writePassWrap = func(_, _ string) error {
196+
return nil
197+
}
198+
mounterRequest = func(_, _ string) (string, error) {
199+
return "{\"error\": \"failed to perform http request\"}", errors.New("error")
200+
}
201+
202+
defer func() { MakeDir = os.MkdirAll }()
203+
204+
rclone := &RcloneMounter{}
205+
206+
err := rclone.Mount(source, target)
207+
assert.Error(t, err)
208+
assert.Contains(t, err.Error(), "failed to perform http request")
209+
}
210+
189211
func TestRcloneUnmount_NodeServer(t *testing.T) {
190212
mountWorker = false
191213

@@ -238,6 +260,20 @@ func TestRcloneUnmount_WorkerNode_Negative(t *testing.T) {
238260
assert.Contains(t, err.Error(), "failed to create http request")
239261
}
240262

263+
func TestRcloneUnmount_WorkerNode_FailedToParseError(t *testing.T) {
264+
mountWorker = true
265+
266+
mounterRequest = func(_, _ string) (string, error) {
267+
return "{\"error\": \"failed to perform http request\"}", errors.New("error")
268+
}
269+
270+
rclone := &RcloneMounter{}
271+
272+
err := rclone.Unmount(target)
273+
assert.Error(t, err)
274+
assert.Contains(t, err.Error(), "failed to perform http request")
275+
}
276+
241277
func TestRcloneUnmount_NodeServer_Negative(t *testing.T) {
242278
mountWorker = false
243279

pkg/mounter/mounter-s3fs.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ func (s3fs *S3fsMounter) Mount(source string, target string) error {
167167
response, err := mounterRequest(payload, "http://unix/api/cos/mount")
168168
klog.Info("Worker Mounting...", response)
169169
if err != nil {
170+
if strings.TrimSpace(response) != "" {
171+
return parseErrFromResponse(response)
172+
}
170173
return err
171174
}
172175
return nil
@@ -187,6 +190,9 @@ func (s3fs *S3fsMounter) Unmount(target string) error {
187190
response, err := mounterRequest(payload, "http://unix/api/cos/unmount")
188191
klog.Info("Worker Unmounting...", response)
189192
if err != nil {
193+
if strings.TrimSpace(response) != "" {
194+
return parseErrFromResponse(response)
195+
}
190196
return err
191197
}
192198

pkg/mounter/mounter-s3fs_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,28 @@ func TestS3FSMount_WorkerNode_Negative(t *testing.T) {
163163
assert.Contains(t, err.Error(), "failed to perform http request")
164164
}
165165

166+
func TestS3FSMount_WorkerNode_FailedToParseError(t *testing.T) {
167+
mountWorker = true
168+
169+
MakeDir = func(path string, perm os.FileMode) error {
170+
return nil
171+
}
172+
writePassWrap = func(_, _ string) error {
173+
return nil
174+
}
175+
mounterRequest = func(_, _ string) (string, error) {
176+
return "{\"error\": \"failed to perform http request\"}", errors.New("error")
177+
}
178+
179+
defer func() { MakeDir = os.MkdirAll }()
180+
181+
s3fs := &S3fsMounter{}
182+
183+
err := s3fs.Mount(source, target)
184+
assert.Error(t, err)
185+
assert.Contains(t, err.Error(), "failed to perform http request")
186+
}
187+
166188
func TestUnmount_NodeServer(t *testing.T) {
167189
mountWorker = false
168190

@@ -215,6 +237,20 @@ func TestUnmount_WorkerNode_Negative(t *testing.T) {
215237
assert.Contains(t, err.Error(), "failed to create http request")
216238
}
217239

240+
func TestUnmount_WorkerNode_FailedToParseError(t *testing.T) {
241+
mountWorker = true
242+
243+
mounterRequest = func(_, _ string) (string, error) {
244+
return "{\"error\": \"failed to perform http request\"}", errors.New("error")
245+
}
246+
247+
s3fs := &S3fsMounter{}
248+
249+
err := s3fs.Unmount(target)
250+
assert.Error(t, err)
251+
assert.Contains(t, err.Error(), "failed to perform http request")
252+
}
253+
218254
func TestUnmount_NodeServer_Negative(t *testing.T) {
219255
mountWorker = false
220256

pkg/mounter/mounter.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package mounter
22

33
import (
44
"context"
5+
"encoding/json"
56
"errors"
67
"io"
78
"net"
@@ -220,3 +221,17 @@ func isGRPCServerAvailable(socketPath string) error {
220221
}
221222
return nil
222223
}
224+
225+
func parseErrFromResponse(response string) error {
226+
var errFromResp map[string]string
227+
err := json.Unmarshal([]byte(response), &errFromResp)
228+
if err != nil {
229+
klog.Warning("failed to unmarshal response from server")
230+
return errors.New(response)
231+
}
232+
val, exists := errFromResp["error"]
233+
if !exists {
234+
return errors.New(response)
235+
}
236+
return errors.New(val)
237+
}

0 commit comments

Comments
 (0)