Skip to content

Commit 9d4bfec

Browse files
committed
Adapt the flag -automaxprocs added in csi-lib-utils
kubernetes-csi/csi-lib-utils#193 added a flag across all the sidecars. In this repo that flag should only be defined once.
1 parent 14f1db4 commit 9d4bfec

File tree

4 files changed

+32
-21
lines changed

4 files changed

+32
-21
lines changed

hack/cmd/csi-sidecars/config/flags.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,3 @@ func RegisterCommonFlags(flags *flag.FlagSet) {
6363

6464
flags.StringVar(&Configuration.Controllers, "controllers", "", "A comma-separated list of controllers to enable. The possible values are: [resizer,attacher,provisioner]")
6565
}
66-

hack/do_sync.log

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ Your branch is up to date with 'origin/master'.
363363
+ sort
364364
+ uniq
365365
+ go mod tidy
366+
go: downloading github.com/kubernetes-csi/csi-lib-utils v0.22.0
366367
+ cat
367368
+ csi_lib_utils=staging/src/github.com/kubernetes-csi/csi-lib-utils
368369
+ [[ ! -d staging/src/github.com/kubernetes-csi/csi-lib-utils ]]
@@ -404,7 +405,7 @@ export os_arch_seen="" && echo '' | tr ';' '\n' | while read -r os arch buildx_p
404405
if ! [ ${#os_arch_seen_pre} = ${#os_arch_seen} ]; then \
405406
continue; \
406407
fi; \
407-
if ! (set -x; cd ./cmd/csi-sidecars && CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build -a -ldflags ' -X main.version=cce1dbc9976c7b93985cab9ec8bf8da6b0025feb -extldflags "-static"' -o "/home/mauriciopoppe.linux/go/src/github.com/mauriciopoppe/csi-sidecars-aio-poc/bin/csi-sidecars$suffix" .); then \
408+
if ! (set -x; cd ./cmd/csi-sidecars && CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build -a -ldflags ' -X main.version=dfc572b7e7680ba79e2b78f8a01c080406cb7f81 -extldflags "-static"' -o "/home/mauriciopoppe.linux/go/src/github.com/mauriciopoppe/csi-sidecars-aio-poc/bin/csi-sidecars$suffix" .); then \
408409
echo "Building csi-sidecars for GOOS=$os GOARCH=$arch failed, see error(s) above."; \
409410
exit 1; \
410411
fi; \
@@ -414,7 +415,7 @@ done
414415
+ CGO_ENABLED=0
415416
+ GOOS=
416417
+ GOARCH=
417-
+ go build -a -ldflags ' -X main.version=cce1dbc9976c7b93985cab9ec8bf8da6b0025feb -extldflags "-static"' -o /home/mauriciopoppe.linux/go/src/github.com/mauriciopoppe/csi-sidecars-aio-poc/bin/csi-sidecars .
418+
+ go build -a -ldflags ' -X main.version=dfc572b7e7680ba79e2b78f8a01c080406cb7f81 -extldflags "-static"' -o /home/mauriciopoppe.linux/go/src/github.com/mauriciopoppe/csi-sidecars-aio-poc/bin/csi-sidecars .
418419
+ ./bin/csi-sidecars --help
419420
Usage of ./bin/csi-sidecars:
420421
--add_dir_header If true, adds the file directory to the header of the log messages

hack/do_sync.sh

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -euxo pipefail
33

44
if [[ $(uname) != "Linux" ]]; then
5-
echo "This script only works in Linux arm64/amd64, yours is `uname`"
5+
echo "This script only works in Linux arm64/amd64, yours is $(uname)"
66
exit 1
77
fi
88

@@ -34,16 +34,15 @@ symlink_from_hack_to_root() {
3434
ln -s $PWD/$file $PWD/$file_without_hack
3535
}
3636

37-
3837
# loop params: [repository,branch]
3938
for i in attacher,master provisioner,master resizer,master; do
40-
IFS=',' read SIDECAR SIDECAR_HASH <<< "${i}"
39+
IFS=',' read SIDECAR SIDECAR_HASH <<<"${i}"
4140
if [[ ! -d pkg/${SIDECAR} ]]; then
4241
git clone --depth 1 https://github.com/kubernetes-csi/external-${SIDECAR} pkg/${SIDECAR}
4342
(cd pkg/${SIDECAR} && git checkout ${SIDECAR_HASH})
4443

45-
cat pkg/${SIDECAR}/go.mod | grep " " | grep -v "indirect" >> tmp/gomod-require.txt
46-
cat pkg/${SIDECAR}/go.mod | { grep "replace " || [[ $? == 1 ]] } >> tmp/gomod-replace.txt
44+
cat pkg/${SIDECAR}/go.mod | grep " " | grep -v "indirect" >>tmp/gomod-require.txt
45+
cat pkg/${SIDECAR}/go.mod | { grep "replace " || [[ $? == 1 ]]; } >>tmp/gomod-replace.txt
4746

4847
${TRASH} pkg/${SIDECAR}/.git
4948
${TRASH} pkg/${SIDECAR}/.github
@@ -58,10 +57,16 @@ for i in attacher,master provisioner,master resizer,master; do
5857
${TRASH} pkg/${SIDECAR}/OWNER_ALIASES
5958
${TRASH} pkg/${SIDECAR}/Makefile
6059

61-
(cd pkg/${SIDECAR}; find . -type f -exec grep -q "github.com/kubernetes-csi/external-${SIDECAR}/" --files-with-matches {} \; -print)
60+
(
61+
cd pkg/${SIDECAR}
62+
find . -type f -exec grep -q "github.com/kubernetes-csi/external-${SIDECAR}/" --files-with-matches {} \; -print
63+
)
6264

63-
(cd pkg/${SIDECAR}; find . -type f -exec grep -q "github.com/kubernetes-csi/external-${SIDECAR}/" --files-with-matches {} \; -print | \
64-
xargs sed -E -i".bak" "s%github.com/kubernetes-csi/external-${SIDECAR}/(v[0-9]+/)?%github.com/kubernetes-csi/csi-sidecars/pkg/${SIDECAR}/%g")
65+
(
66+
cd pkg/${SIDECAR}
67+
find . -type f -exec grep -q "github.com/kubernetes-csi/external-${SIDECAR}/" --files-with-matches {} \; -print |
68+
xargs sed -E -i".bak" "s%github.com/kubernetes-csi/external-${SIDECAR}/(v[0-9]+/)?%github.com/kubernetes-csi/csi-sidecars/pkg/${SIDECAR}/%g"
69+
)
6570
fi
6671

6772
for FILE in pkg/${SIDECAR}/cmd/csi-${SIDECAR}/*.go; do
@@ -90,15 +95,21 @@ for i in attacher,master provisioner,master resizer,master; do
9095
sed -i".bak" '/utilfeature.DefaultMutableFeatureGate/,/}/d' "${NEW_FILE}"
9196
sed -i".bak" '/flag.CommandLine.AddGoFlagSet/d' "${NEW_FILE}"
9297

98+
# TODO: handle setting the automaxproc flag from each sidecar>
99+
# In the meantime remove setting the flag and handle it in the AIO sidecar.
100+
# https://github.com/mauriciopoppe/csi-sidecars-aio-poc/issues/14
101+
sed -i".bak" '/standardflags.AddAutomaxprocs/d' "${NEW_FILE}"
102+
93103
# Dead imports
94104
sed -i".bak" '/goflag/d' "${NEW_FILE}"
95105
sed -i".bak" '/flag"/d' "${NEW_FILE}"
96106
sed -i".bak" '/featuregate"/d' "${NEW_FILE}"
97107
sed -i".bak" '/logs/d' "${NEW_FILE}"
108+
sed -i".bak" '/csi-lib-utils\/standardflags/d' "${NEW_FILE}"
109+
98110
if [ "${SIDECAR}" = "resizer" ]; then
99111
sed -i".bak" '/strings/d' "${NEW_FILE}"
100112
fi
101-
102113
done
103114

104115
# This is a temporary change that tests what it'd be to make a refactor
@@ -123,12 +134,12 @@ go 1.23.1
123134
124135
require (
125136
EOF
126-
cat tmp/gomod-require.txt | sort | uniq >> go.mod
137+
cat tmp/gomod-require.txt | sort | uniq >>go.mod
127138
cat <<EOF >>go.mod
128139
)
129140
130141
EOF
131-
cat tmp/gomod-replace.txt | sort | uniq >> go.mod
142+
cat tmp/gomod-replace.txt | sort | uniq >>go.mod
132143
go mod tidy
133144

134145
cat <<EOF >Makefile
@@ -148,7 +159,7 @@ if [[ ! -d ${csi_lib_utils} ]]; then
148159
${TRASH} ${csi_lib_utils}/release-tools
149160

150161
if ! grep -q "./staging/src/github.com/kubernetes-csi/csi-lib-utils" go.mod; then
151-
echo "replace github.com/kubernetes-csi/csi-lib-utils => ./staging/src/github.com/kubernetes-csi/csi-lib-utils" >> go.mod
162+
echo "replace github.com/kubernetes-csi/csi-lib-utils => ./staging/src/github.com/kubernetes-csi/csi-lib-utils" >>go.mod
152163
fi
153164
fi
154165

@@ -166,7 +177,7 @@ make build
166177
go build -a -ldflags ' -X main.version=foo -extldflags "-static"' -o ./bin/csi-attacher ./pkg/attacher/cmd/csi-attacher
167178
./bin/csi-attacher --help || true
168179

169-
cat <<'EOF' > Dockerfile
180+
cat <<'EOF' >Dockerfile
170181
FROM gcr.io/distroless/static:latest
171182
LABEL maintainers="Kubernetes Authors"
172183
LABEL description="CSI Sidecars"

hack/pkg/attacher/cmd/csi-attacher/config/flags.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import (
66
)
77

88
type AttacherConfiguration struct {
9-
MaxEntries int
10-
ReconcileSync time.Duration
9+
MaxEntries int
10+
ReconcileSync time.Duration
1111
MaxGRPCLogLength int
12-
WorkerThreads int
13-
DefaultFSType string
14-
Timeout time.Duration
12+
WorkerThreads int
13+
DefaultFSType string
14+
Timeout time.Duration
1515
}
1616

1717
func registerAttacherFlags(flags *flag.FlagSet, configuration *AttacherConfiguration, prefix string) {

0 commit comments

Comments
 (0)