Skip to content

Commit 070bd01

Browse files
Implemented enhanced Volume Resize (#573)
Signed-off-by: Lukas Frank <lukas.frank@sap.com> Co-authored-by: ushabelgur <usha.belgur@t-systems.com>
1 parent 261935c commit 070bd01

File tree

16 files changed

+92
-382
lines changed

16 files changed

+92
-382
lines changed

Dockerfile

Lines changed: 7 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -30,37 +30,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
3030
&& update-ca-certificates \
3131
&& rm -rf /var/lib/apt/lists/*
3232

33-
# Install cross-compiler for ARM64 if building for arm64 on an amd64 host
34-
RUN if [ "$TARGETARCH" = "arm64" ] && [ "$BUILDARCH" = "amd64" ]; then \
35-
dpkg --add-architecture arm64 && \
36-
apt-get update && apt-get install -y --no-install-recommends \
37-
gcc-aarch64-linux-gnu librbd-dev:arm64 librados-dev:arm64 libc6-dev:arm64; \
38-
fi
3933

40-
# Install cross-compiler for AMD64 if building for amd64 on an arm64 host
41-
RUN if [ "$TARGETARCH" = "amd64" ] && [ "$BUILDARCH" = "arm64" ]; then \
42-
apt update && \
43-
apt-get install -y --no-install-recommends \
44-
gcc-x86-64-linux-gnu; \
45-
fi
34+
RUN --mount=type=cache,target=/root/.cache/go-build \
35+
--mount=type=cache,target=/go/pkg \
36+
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on go build -ldflags="-s -w" -a -o libvirt-provider ./cmd/libvirt-provider/main.go
4637

47-
# Set compiler and linker flags based on target architecture
48-
ENV CC=""
49-
ENV CGO_LDFLAGS=""
50-
51-
RUN if [ "$TARGETARCH" != "$BUILDARCH" ] && [ "$TARGETARCH" = "arm64" ]; then \
52-
export CC="/usr/bin/aarch64-linux-gnu-gcc"; \
53-
export CGO_LDFLAGS="-L/usr/lib/aarch64-linux-gnu -Wl,-lrados -Wl,-lrbd"; \
54-
elif [ "$TARGETARCH" != "$BUILDARCH" ] && [ "$TARGETARCH" = "amd64" ]; then \
55-
export CC="/usr/bin/x86_64-linux-gnu-gcc"; \
56-
export CGO_LDFLAGS="-L/usr/lib/x86_64-linux-gnu -Wl,-lrados -Wl,-lrbd"; \
57-
else \
58-
export CC="/usr/bin/gcc"; \
59-
export CGO_LDFLAGS=""; \
60-
fi && \
61-
CGO_ENABLED=1 GOOS=$TARGETOS GOARCH=$TARGETARCH \
62-
CC="$CC" CGO_LDFLAGS="$CGO_LDFLAGS" \
63-
go build -ldflags="-s -w -linkmode=external" -o libvirt-provider ./cmd/libvirt-provider/main.go
6438

6539
# Install irictl-machine
6640
RUN --mount=type=cache,target=/root/.cache/go-build \
@@ -75,63 +49,14 @@ RUN if [ "$TARGETARCH" = "$BUILDARCH" ]; then \
7549
mv /go/bin/linux_$TARGETARCH/irictl-machine /workspace/irictl-machine; \
7650
fi
7751

52+
53+
FROM busybox:1.37.0-uclibc AS busybox
54+
7855
# Since we're leveraging apt to pull in dependencies, we use `gcr.io/distroless/base` because it includes glibc.
79-
FROM gcr.io/distroless/base-debian11 AS distroless-base
80-
81-
# The distroless amd64 image has a target triplet of x86_64
82-
FROM distroless-base AS distroless-amd64
83-
ENV LIB_DIR_PREFIX=x86_64
84-
ENV LIB_DIR_PREFIX_MINUS=x86-64
85-
ENV LIB_DIR_SUFFIX_NUMBER=2
86-
ENV LIB_DIR=lib64
87-
88-
# The distroless arm64 image has a target triplet of aarch64
89-
FROM distroless-base AS distroless-arm64
90-
ENV LIB_DIR_PREFIX=aarch64
91-
ENV LIB_DIR_PREFIX_MINUS=aarch64
92-
ENV LIB_DIR_SUFFIX_NUMBER=1
93-
ENV LIB_DIR=lib
56+
FROM gcr.io/distroless/base-debian11 AS libvirt-provider
9457

95-
FROM busybox:1.37.0-uclibc AS busybox
96-
FROM distroless-$TARGETARCH AS libvirt-provider
9758
WORKDIR /
9859
COPY --from=busybox /bin/sh /bin/sh
99-
COPY --from=busybox /bin/mkdir /bin/mkdir
100-
COPY --from=builder /lib/${LIB_DIR_PREFIX}-linux-gnu/librados.so.2 \
101-
/lib/${LIB_DIR_PREFIX}-linux-gnu/librbd.so.1 \
102-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libc.so.6 \
103-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libfmt.so.9 \
104-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libstdc++.so.6 \
105-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libgcc_s.so.1 \
106-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libssl.so.3 \
107-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libcryptsetup.so.12 \
108-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libcrypto.so.3 \
109-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libresolv.so.2 \
110-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libboost_thread.so.1.74.0 \
111-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libboost_iostreams.so.1.74.0 \
112-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libblkid.so.1 \
113-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libudev.so.1 \
114-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libibverbs.so.1 \
115-
/lib/${LIB_DIR_PREFIX}-linux-gnu/librdmacm.so.1 \
116-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libm.so.6 \
117-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libuuid.so.1 \
118-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libdevmapper.so.1.02.1 \
119-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libargon2.so.1 \
120-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libjson-c.so.5 \
121-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libz.so.1 \
122-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libbz2.so.1.0 \
123-
/lib/${LIB_DIR_PREFIX}-linux-gnu/liblzma.so.5 \
124-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libzstd.so.1 \
125-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libnl-route-3.so.200 \
126-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libnl-3.so.200 \
127-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libselinux.so.1 \
128-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libpthread.so.0 \
129-
/lib/${LIB_DIR_PREFIX}-linux-gnu/libpcre2-8.so.0 /lib/${LIB_DIR_PREFIX}-linux-gnu/
130-
RUN mkdir -p /${LIB_DIR}
131-
COPY --from=builder /${LIB_DIR}/ld-linux-${LIB_DIR_PREFIX_MINUS}.so.${LIB_DIR_SUFFIX_NUMBER} /${LIB_DIR}/
132-
RUN mkdir -p /usr/lib/${LIB_DIR_PREFIX}-linux-gnu/ceph/
133-
COPY --from=builder /usr/lib/${LIB_DIR_PREFIX}-linux-gnu/ceph/libceph-common.so.2 /usr/lib/${LIB_DIR_PREFIX}-linux-gnu/ceph
134-
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
13560

13661
COPY --from=builder /workspace/libvirt-provider /libvirt-provider
13762
COPY --from=builder /workspace/irictl-machine /irictl-machine

api/machine.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,12 @@ type EmptyDiskSpec struct {
8484
}
8585

8686
type VolumeConnection struct {
87-
Driver string ` json:"driver,omitempty"`
88-
Handle string ` json:"handle,omitempty"`
89-
Attributes map[string]string ` json:"attributes,omitempty"`
90-
SecretData map[string][]byte ` json:"secret_data,omitempty"`
91-
EncryptionData map[string][]byte ` json:"encryption_data,omitempty"`
87+
Driver string ` json:"driver,omitempty"`
88+
Handle string ` json:"handle,omitempty"`
89+
Attributes map[string]string ` json:"attributes,omitempty"`
90+
SecretData map[string][]byte ` json:"secret_data,omitempty"`
91+
EncryptionData map[string][]byte ` json:"encryption_data,omitempty"`
92+
EffectiveStorageBytes int64 ` json:"effective_storage_bytes,omitempty"`
9293
}
9394

9495
type VolumeState string

cmd/libvirt-provider/app/app.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ type Options struct {
6868
RootDir string
6969

7070
PathSupportedMachineClasses string
71-
ResyncIntervalVolumeSize time.Duration
7271

7372
EnableHugepages bool
7473

@@ -111,7 +110,6 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
111110
fs.StringVar(&o.RootDir, "libvirt-provider-dir", filepath.Join(homeDir, ".libvirt-provider"), "Path to the directory libvirt-provider manages its content at.")
112111

113112
fs.StringVar(&o.PathSupportedMachineClasses, "supported-machine-classes", o.PathSupportedMachineClasses, "File containing supported machine classes.")
114-
fs.DurationVar(&o.ResyncIntervalVolumeSize, "volume-size-resync-interval", 1*time.Minute, "Interval to determine volume size changes.")
115113

116114
fs.StringVar(&o.StreamingAddress, "streaming-address", ":20251", "Address to run the streaming server on")
117115
fs.StringVar(&o.BaseURL, "base-url", "", "The base url to construct urls for streaming from. If empty it will be "+
@@ -314,7 +312,6 @@ func Run(ctx context.Context, opts Options) error {
314312
Raw: rawInst,
315313
VolumePluginManager: volumePlugins,
316314
NetworkInterfacePlugin: nicPlugin,
317-
ResyncIntervalVolumeSize: opts.ResyncIntervalVolumeSize,
318315
ResyncIntervalGarbageCollector: opts.ResyncIntervalGarbageCollector,
319316
EnableHugepages: opts.EnableHugepages,
320317
GCVMGracefulShutdownTimeout: opts.GCVMGracefulShutdownTimeout,

go.mod

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@ toolchain go1.24.1
66

77
require (
88
github.com/blang/semver/v4 v4.0.0
9-
github.com/ceph/go-ceph v0.33.0
109
github.com/containerd/containerd v1.7.27
11-
github.com/digitalocean/go-libvirt v0.0.0-20250417173424-a6a66ef779d6
10+
github.com/digitalocean/go-libvirt v0.0.0-20250512231903-57024326652b
1211
github.com/go-chi/chi/v5 v5.2.1
13-
github.com/go-logr/logr v1.4.2
12+
github.com/go-logr/logr v1.4.3
1413
github.com/google/uuid v1.6.0
1514
github.com/ironcore-dev/controller-utils v0.9.9
16-
github.com/ironcore-dev/ironcore v0.2.3
15+
github.com/ironcore-dev/ironcore v0.2.4-0.20250605101147-768826bd8776
1716
github.com/ironcore-dev/ironcore-image v0.2.4
1817
github.com/ironcore-dev/ironcore-net v0.2.3
19-
github.com/ironcore-dev/provider-utils v0.0.0-20250409071032-ef57cc16e3c6
18+
github.com/ironcore-dev/provider-utils v0.0.0-20250603083958-8628d8f587bc
2019
github.com/moby/term v0.5.2
2120
github.com/onsi/ginkgo/v2 v2.23.4
2221
github.com/onsi/gomega v1.37.0
@@ -25,13 +24,13 @@ require (
2524
github.com/shirou/gopsutil/v3 v3.24.5
2625
github.com/spf13/cobra v1.9.1
2726
github.com/spf13/pflag v1.0.6
28-
golang.org/x/sync v0.14.0
29-
google.golang.org/grpc v1.72.1
27+
golang.org/x/sync v0.15.0
28+
google.golang.org/grpc v1.73.0
3029
k8s.io/api v0.33.1
3130
k8s.io/apimachinery v0.33.1
3231
k8s.io/client-go v0.33.1
3332
k8s.io/kubectl v0.33.1
34-
k8s.io/utils v0.0.0-20250321185631-1f6e0b77f77e
33+
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397
3534
libvirt.org/go/libvirtxml v1.11004.0
3635
sigs.k8s.io/controller-runtime v0.21.0
3736
)
@@ -113,14 +112,14 @@ require (
113112
go.uber.org/automaxprocs v1.6.0 // indirect
114113
go.uber.org/multierr v1.11.0 // indirect
115114
go.uber.org/zap v1.27.0 // indirect
116-
golang.org/x/crypto v0.37.0 // indirect
117-
golang.org/x/net v0.39.0 // indirect
115+
golang.org/x/crypto v0.38.0 // indirect
116+
golang.org/x/net v0.40.0 // indirect
118117
golang.org/x/oauth2 v0.29.0 // indirect
119-
golang.org/x/sys v0.32.0 // indirect
120-
golang.org/x/term v0.31.0 // indirect
121-
golang.org/x/text v0.24.0 // indirect
118+
golang.org/x/sys v0.33.0 // indirect
119+
golang.org/x/term v0.32.0 // indirect
120+
golang.org/x/text v0.25.0 // indirect
122121
golang.org/x/time v0.11.0 // indirect
123-
golang.org/x/tools v0.32.0 // indirect
122+
golang.org/x/tools v0.33.0 // indirect
124123
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
125124
google.golang.org/genproto/googleapis/api v0.0.0-20250414145226-207652e42e2e // indirect
126125
google.golang.org/genproto/googleapis/rpc v0.0.0-20250421163800-61c742ae3ef0 // indirect

0 commit comments

Comments
 (0)