Skip to content

Commit

Permalink
Allow dynamic linking of binaries (kubevirt#205)
Browse files Browse the repository at this point in the history
* Allow dynamic linking of binaries

The release was creating statically linked binaries
and there is no particular reason for this. Doing
dynamically linked binaries would decrase the container
size.

Signed-off-by: Alexander Wels <[email protected]>

* Updated fedora to 37 so it has a recent enough glibc
Added glibc to the Dockerfile so the binaries can run
Fixed failing functional test that was not calculating
the size properly from the `df -Bk` command. It was
calculating from 1000 instead of 1024 and the size was
wrong because of it.

Signed-off-by: Alexander Wels <[email protected]>

---------

Signed-off-by: Alexander Wels <[email protected]>
  • Loading branch information
awels committed Jun 16, 2023
1 parent a54504a commit f386d1b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Dockerfile.controller
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
FROM registry.fedoraproject.org/fedora-minimal:34
FROM registry.fedoraproject.org/fedora-minimal:37
RUN microdnf install glibc -y
COPY _out/hostpath-provisioner /
CMD ["/hostpath-provisioner"]
3 changes: 2 additions & 1 deletion Dockerfile.csi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM registry.fedoraproject.org/fedora-minimal:34
FROM registry.fedoraproject.org/fedora-minimal:37
RUN microdnf install glibc -y
COPY _out/hostpath-csi-driver /
ENTRYPOINT ["/hostpath-csi-driver"]

2 changes: 1 addition & 1 deletion hack/build-csi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ script_dir="$(cd "$(dirname "$0")" && pwd -P)"
source "${script_dir}"/common.sh
setGoInProw $GOLANG_VER

CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o _out/hostpath-csi-driver cmd/plugin/plugin.go
CGO_ENABLED=1 go build -a -tags strictfipsruntime -ldflags '-extldflags' -o _out/hostpath-csi-driver cmd/plugin/plugin.go
2 changes: 1 addition & 1 deletion hack/build-provisioner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ script_dir="$(cd "$(dirname "$0")" && pwd -P)"
source "${script_dir}"/common.sh
setGoInProw $GOLANG_VER

CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o _out/hostpath-provisioner cmd/provisioner/hostpath-provisioner.go
CGO_ENABLED=1 go build -a -tags strictfipsruntime -ldflags '-extldflags' -o _out/hostpath-provisioner cmd/provisioner/hostpath-provisioner.go
21 changes: 11 additions & 10 deletions tests/pvc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -31,11 +31,12 @@ import (
)

const (
csiStorageClassName = "hostpath-csi"
legacyStorageClassName = "hostpath-provisioner"
csiStorageClassName = "hostpath-csi"
legacyStorageClassName = "hostpath-provisioner"
legacyStorageClassNameImmediate = "hostpath-provisioner-immediate"
testMountName = "testmount"
testMountName = "testmount"
)

func TestCreatePVCOnNode1(t *testing.T) {
RegisterTestingT(t)
tearDown, ns, k8sClient := setupTestCaseNs(t)
Expand Down Expand Up @@ -252,7 +253,7 @@ func TestFsGroup(t *testing.T) {
Eventually(func() string {
getPod, err = k8sClient.CoreV1().Pods(ns.Name).Get(context.TODO(), getPod.Name, metav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
out ,err := RunKubeCtlCommand("logs", getPod.GetName(), "-n", ns.Name)
out, err := RunKubeCtlCommand("logs", getPod.GetName(), "-n", ns.Name)
if err != nil {
return ""
}
Expand All @@ -264,8 +265,8 @@ func createPVCDef(namespace, storageClassName string, annotations map[string]str
return &corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "test-pvc",
Namespace: namespace,
Annotations: annotations,
Namespace: namespace,
Annotations: annotations,
},
Spec: corev1.PersistentVolumeClaimSpec{
AccessModes: []corev1.PersistentVolumeAccessMode{
Expand Down Expand Up @@ -301,7 +302,7 @@ func createPodUsingPVCWithCommand(namespace, name string, pvc *corev1.Persistent
Command: []string{"/bin/sh", "-c", command},
VolumeMounts: []v1.VolumeMount{
{
Name: testMountName,
Name: testMountName,
MountPath: "/data",
},
},
Expand All @@ -325,9 +326,9 @@ func createPodUsingPVCWithFsGroup(namespace, name string, pvc *corev1.Persistent
userId := int64(1000)
pod := createPodUsingPVCWithCommand(namespace, name, pvc, command, annotations)
pod.Spec.SecurityContext = &corev1.PodSecurityContext{
RunAsUser: &userId,
RunAsUser: &userId,
RunAsGroup: &groupId,
FSGroup: &groupId,
FSGroup: &groupId,
}
return pod
}
Expand Down

0 comments on commit f386d1b

Please sign in to comment.