Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ gazelle(name = "gazelle")

bazeldnf(name = "bazeldnf")

alias(
name = "buildozer",
actual = "@buildifier_prebuilt//:buildozer",
)

go_library(
name = "go_default_library",
srcs = ["doc.go"],
Expand Down
72 changes: 49 additions & 23 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,54 @@ register_all_toolchains()

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")

# Bazel buildtools prebuilt binaries
http_archive(
name = "buildifier_prebuilt",
sha256 = "7f85b688a4b558e2d9099340cfb510ba7179f829454fba842370bccffb67d6cc",
strip_prefix = "buildifier-prebuilt-7.3.1",
urls = [
"http://github.com/keith/buildifier-prebuilt/archive/7.3.1.tar.gz",
"https://storage.googleapis.com/builddeps/7f85b688a4b558e2d9099340cfb510ba7179f829454fba842370bccffb67d6cc",
],
)

load("@buildifier_prebuilt//:deps.bzl", "buildifier_prebuilt_deps")

buildifier_prebuilt_deps()

load("@buildifier_prebuilt//:defs.bzl", "buildifier_prebuilt_register_toolchains", "buildtools_assets")

buildifier_prebuilt_register_toolchains(
assets = buildtools_assets(
arches = [
"amd64",
"arm64",
"s390x",
],
names = ["buildozer"],
platforms = [
"darwin",
"linux",
"windows",
],
sha256_values = {
"buildozer_darwin_amd64": "854c9583efc166602276802658cef3f224d60898cfaa60630b33d328db3b0de2",
"buildozer_darwin_arm64": "31b1bfe20d7d5444be217af78f94c5c43799cdf847c6ce69794b7bf3319c5364",
"buildozer_linux_amd64": "3305e287b3fcc68b9a35fd8515ee617452cd4e018f9e6886b6c7cdbcba8710d4",
"buildozer_linux_arm64": "0b5a2a717ac4fc911e1fec8d92af71dbb4fe95b10e5213da0cc3d56cea64a328",
"buildozer_linux_s390x": "7e28da8722656e800424989f5cdbc095cb29b2d398d33e6b3d04e0f50bc0bb10",
"buildozer_windows_amd64": "58d41ce53257c5594c9bc86d769f580909269f68de114297f46284fbb9023dcf",
},
version = "v7.3.1",
),
)

http_archive(
name = "io_bazel_rules_go",
sha256 = "80a98277ad1311dacd837f9b16db62887702e9f1d1c4c9f796d0121a46c8e184",
sha256 = "130739704540caa14e77c54810b9f01d6d9ae897d53eedceb40fd6b75efc3c23",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.46.0/rules_go-v0.46.0.zip",
"https://storage.googleapis.com/builddeps/80a98277ad1311dacd837f9b16db62887702e9f1d1c4c9f796d0121a46c8e184",
"https://github.com/bazel-contrib/rules_go/releases/download/v0.54.1/rules_go-v0.54.1.zip",
"https://storage.googleapis.com/builddeps/130739704540caa14e77c54810b9f01d6d9ae897d53eedceb40fd6b75efc3c23",
],
)

Expand All @@ -46,29 +87,14 @@ go_register_toolchains(
go_version = "host",
)

http_archive(
name = "com_google_protobuf",
sha256 = "cd218dc003eacc167e51e3ce856f6c2e607857225ef86b938d95650fcbb2f8e4",
strip_prefix = "protobuf-6d4e7fd7966c989e38024a8ea693db83758944f1",
# version 3.10.0
urls = [
"https://github.com/google/protobuf/archive/6d4e7fd7966c989e38024a8ea693db83758944f1.zip",
"https://storage.googleapis.com/builddeps/cd218dc003eacc167e51e3ce856f6c2e607857225ef86b938d95650fcbb2f8e4",
],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

# gazelle rules
http_archive(
name = "bazel_gazelle",
sha256 = "d3fa66a39028e97d76f9e2db8f1b0c11c099e8e01bf363a923074784e451f809",
sha256 = "b760f7fe75173886007f7c2e616a21241208f3d90e8657dc65d36a771e916b6a",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.33.0/bazel-gazelle-v0.33.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.33.0/bazel-gazelle-v0.33.0.tar.gz",
"https://storage.googleapis.com/builddeps/d3fa66a39028e97d76f9e2db8f1b0c11c099e8e01bf363a923074784e451f809",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.39.1/bazel-gazelle-v0.39.1.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.39.1/bazel-gazelle-v0.39.1.tar.gz",
"https://storage.googleapis.com/builddeps/b760f7fe75173886007f7c2e616a21241208f3d90e8657dc65d36a771e916b6a",
],
)

Expand Down
3 changes: 1 addition & 2 deletions cmd/cdi-apiserver/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@rules_oci//oci:defs.bzl", "oci_image")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("//pkg/version:def.bzl", "version_x_defs")

go_library(
name = "go_default_library",
Expand Down Expand Up @@ -32,8 +33,6 @@ go_library(
],
)

load("//pkg/version:def.bzl", "version_x_defs")

go_binary(
name = "cdi-apiserver",
embed = [":go_default_library"],
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module kubevirt.io/containerized-data-importer

go 1.23.0
go 1.24.0

require (
cloud.google.com/go/storage v1.38.0
Expand Down
7 changes: 3 additions & 4 deletions hack/build/bazel-build-builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@ source "${script_dir}"/config.sh

if [ "${CDI_CONTAINER_BUILDCMD}" = "buildah" ]; then
BUILDAH_PLATFORM_FLAG="--platform linux/amd64"

if rpm -qa | grep -q qemu-user-static-aarch64; then
BUILDAH_PLATFORM_FLAG="${BUILDAH_PLATFORM_FLAG},linux/arm64"
fi

if rpm -qa | grep -q qemu-user-static-s390x; then
BUILDAH_PLATFORM_FLAG="${BUILDAH_PLATFORM_FLAG},linux/s390x"
fi

echo "Building with $BUILDAH_PLATFORM_FLAG"
fi


# Instead of hard-coding the UNTAGGED_BUILDER_IMAGE, we're going
# to use DOCKER_PREFIX as it is set in config.sh and used elsewhere in
# the build system, to introduce a little more consistency
Expand Down
2 changes: 1 addition & 1 deletion hack/build/bazel-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fi
pullcount=0
until ${CDI_CRI} pull ${BUILDER_IMAGE}; do
((pullcount++)) && ((pullcount == 5)) && echo "Couldn't pull builder image" && exit 1
sleep $((2**pullcount))
sleep $((2 ** pullcount))
done

# Make sure that the output directory exists
Expand Down
4 changes: 2 additions & 2 deletions hack/build/bazel-generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ bazel run \
if [[ "$@" =~ "vendor" ]]; then
bazel run \
--config=${HOST_ARCHITECTURE} \
-- @com_github_bazelbuild_buildtools//buildozer 'add clinkopts -lnbd' //$HOME/go/src/kubevirt.io/containerized-data-importer/vendor/libguestfs.org/libnbd/:go_default_library
-- :buildozer 'add clinkopts -lnbd' //vendor/libguestfs.org/libnbd/:go_default_library

bazel run \
--config=${HOST_ARCHITECTURE} \
-- @com_github_bazelbuild_buildtools//buildozer 'add copts -D_GNU_SOURCE=1' //$HOME/go/src/kubevirt.io/containerized-data-importer/vendor/libguestfs.org/libnbd/:go_default_library
-- :buildozer 'add copts -D_GNU_SOURCE=1' //vendor/libguestfs.org/libnbd/:go_default_library
fi
20 changes: 10 additions & 10 deletions hack/build/bazel-push-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ if [ -n "$DOCKER_CA_CERT_FILE" ]; then
fi

BASE_TEST_IMAGES=(
"cdi-func-test-bad-webserver"
"cdi-func-test-proxy"
"cdi-func-test-sample-populator"
"cdi-func-test-file-host-init"
"cdi-func-test-file-host-http"
"cdi-func-test-registry-init"
"cdi-func-test-tinycore"
"cdi-func-test-registry-populate"
"cdi-func-test-registry"
"cdi-func-test-bad-webserver"
"cdi-func-test-proxy"
"cdi-func-test-sample-populator"
"cdi-func-test-file-host-init"
"cdi-func-test-file-host-http"
"cdi-func-test-registry-init"
"cdi-func-test-tinycore"
"cdi-func-test-registry-populate"
"cdi-func-test-registry"
)

declare -A ARCH_ADDITIONAL_IMAGES
Expand All @@ -46,7 +46,7 @@ ARCH_ADDITIONAL_IMAGES[s390x]="vcenter-simulator"
TEST_IMAGES=("${BASE_TEST_IMAGES[@]}")

for img in ${ARCH_ADDITIONAL_IMAGES[$ARCHITECTURE]}; do
TEST_IMAGES+=("$img")
TEST_IMAGES+=("$img")
done

PUSH_TARGETS=(${PUSH_TARGETS:-$CONTROLLER_IMAGE_NAME $IMPORTER_IMAGE_NAME $CLONER_IMAGE_NAME $APISERVER_IMAGE_NAME $UPLOADPROXY_IMAGE_NAME $UPLOADSERVER_IMAGE_NAME $OPERATOR_IMAGE_NAME})
Expand Down
2 changes: 1 addition & 1 deletion hack/build/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ FUNC_TEST_PROXY="cdi-func-test-proxy"
FUNC_TEST_POPULATOR="cdi-func-test-sample-populator"

# update this whenever new builder tag is created
BUILDER_IMAGE=${BUILDER_IMAGE:-quay.io/kubevirt/kubevirt-cdi-bazel-builder:2503021312-67d1f3d4d}
BUILDER_IMAGE=${BUILDER_IMAGE:-quay.io/kubevirt/kubevirt-cdi-bazel-builder:2512231948-0d192d17c}

BINARIES="cmd/${OPERATOR} cmd/${CONTROLLER} cmd/${IMPORTER} cmd/${CLONER} cmd/${APISERVER} cmd/${UPLOADPROXY} cmd/${UPLOADSERVER} cmd/${OPERATOR} tools/${FUNC_TEST_INIT} tools/${FUNC_TEST_REGISTRY_INIT} tools/${FUNC_TEST_BAD_WEBSERVER} tools/${FUNC_TEST_PROXY} tools/${FUNC_TEST_POPULATOR}"
CDI_PKGS="cmd/ pkg/ test/"
Expand Down
4 changes: 2 additions & 2 deletions hack/build/in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ source "${script_dir}"/config.sh
WORK_DIR="/go/src/kubevirt.io/containerized-data-importer"

if [ ! -d "${CACHE_DIR}" ]; then
echo "Creating cache directory: ${CACHE_DIR}"
mkdir -p "${CACHE_DIR}"
echo "Creating cache directory: ${CACHE_DIR}"
mkdir -p "${CACHE_DIR}"
fi

# Execute the build
Expand Down
1 change: 0 additions & 1 deletion hack/build/rpm-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,3 @@ bazel run \
bazel run \
--config=s390x \
//:bazeldnf -- prune

2 changes: 1 addition & 1 deletion hack/build/run-functional-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@ fi
fi

${TESTS_OUT_DIR}/ginkgo "${ginkgo_args[@]}" ${TESTS_OUT_DIR}/tests.test -- ${test_args}
)
)
6 changes: 3 additions & 3 deletions hack/build/run-linters.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/sh -ex

GOLANGCI_VERSION="${GOLANGCI_VERSION:-v1.60.3}"
MONITORING_LINTER_VERSION="${MONITORING_LINTER_VERSION:-e2be790}"
GOLANGCI_VERSION="${GOLANGCI_VERSION:-v1.64.8}"
MONITORING_LINTER_VERSION="${MONITORING_LINTER_VERSION:-a4b5158}"

go install "github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_VERSION}"
go install "github.com/kubevirt/monitoring/monitoringlinter/cmd/monitoringlinter@${MONITORING_LINTER_VERSION}"

golangci-lint run ./... "$@"
golangci-lint run ./... "$@"
monitoringlinter ./...
26 changes: 13 additions & 13 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,40 +47,40 @@ mkdir "${SCRIPT_ROOT}/pkg/client/listers"
${SCRIPT_ROOT}/hack/build/build-go.sh generate

deepcopy-gen \
--output-file zz_generated.deepcopy.go \
--go-header-file "${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt" \
--output-file zz_generated.deepcopy.go \
--go-header-file "${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt" \
kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1alpha1 \
kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1 \
kubevirt.io/containerized-data-importer-api/pkg/apis/upload/v1beta1 \
kubevirt.io/containerized-data-importer-api/pkg/apis/forklift/v1beta1

client-gen \
--clientset-name versioned \
--input-base kubevirt.io/containerized-data-importer-api/pkg/apis \
--clientset-name versioned \
--input-base kubevirt.io/containerized-data-importer-api/pkg/apis \
--output-dir "${SCRIPT_ROOT}/pkg/client/clientset" \
--output-pkg kubevirt.io/containerized-data-importer/pkg/client/clientset \
--apply-configuration-package '' \
--go-header-file "${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt" \
--output-pkg kubevirt.io/containerized-data-importer/pkg/client/clientset \
--apply-configuration-package '' \
--go-header-file "${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt" \
--input core/v1alpha1 \
--input core/v1beta1 \
--input upload/v1beta1 \
--input forklift/v1beta1

lister-gen \
--output-dir "${SCRIPT_ROOT}/pkg/client/listers" \
--output-dir "${SCRIPT_ROOT}/pkg/client/listers" \
--output-pkg kubevirt.io/containerized-data-importer/pkg/client/listers \
--go-header-file "${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt" \
--go-header-file "${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt" \
kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1alpha1 \
kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1 \
kubevirt.io/containerized-data-importer-api/pkg/apis/upload/v1beta1 \
kubevirt.io/containerized-data-importer-api/pkg/apis/forklift/v1beta1

informer-gen \
--versioned-clientset-package kubevirt.io/containerized-data-importer/pkg/client/clientset/versioned \
--listers-package kubevirt.io/containerized-data-importer/pkg/client/listers \
--output-dir "${SCRIPT_ROOT}/pkg/client/informers" \
--versioned-clientset-package kubevirt.io/containerized-data-importer/pkg/client/clientset/versioned \
--listers-package kubevirt.io/containerized-data-importer/pkg/client/listers \
--output-dir "${SCRIPT_ROOT}/pkg/client/informers" \
--output-pkg kubevirt.io/containerized-data-importer/pkg/client/informers \
--go-header-file "${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt" \
--go-header-file "${SCRIPT_ROOT}/hack/custom-boilerplate.go.txt" \
kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1alpha1 \
kubevirt.io/containerized-data-importer-api/pkg/apis/core/v1beta1 \
kubevirt.io/containerized-data-importer-api/pkg/apis/upload/v1beta1 \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module kubevirt.io/containerized-data-importer-api

go 1.23.0
go 1.24.0

require (
k8s.io/api v0.30.2
Expand Down
2 changes: 1 addition & 1 deletion tests/adopt-volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var _ = Describe("PVC adoption tests", func() {
}
}
return nil
}, timeout, pollingInterval).Should(BeNil())
}, timeout, pollingInterval).Should(Succeed())

By("Deleting source DV")
err = utils.DeleteDataVolume(f.CdiClient, dv.Namespace, dv.Name)
Expand Down
2 changes: 1 addition & 1 deletion tests/datavolume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,7 @@ var _ = Describe("[vendor:cnv-qe@redhat.com][level:component]DataVolume tests",
Expect(err).ToNot(HaveOccurred())
storageProfile.Spec = spec
return client.Update(context.TODO(), storageProfile)
}, 15*time.Second, time.Second).Should(BeNil())
}, 15*time.Second, time.Second).Should(Succeed())
}

configureStorageProfile := func(client client.Client,
Expand Down
2 changes: 1 addition & 1 deletion tests/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,5 +796,5 @@ func (f *Framework) updateCDIConfig() {
return utils.UpdateCDIConfig(f.CrClient, func(config *cdiv1.CDIConfigSpec) {
config.FeatureGates = f.FeatureGates
})
}, timeout, pollingInterval).Should(gomega.BeNil())
}, timeout, pollingInterval).Should(gomega.Succeed())
}
2 changes: 1 addition & 1 deletion tests/import_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ var _ = Describe("Import Proxy tests", func() {
Eventually(func() error {
_, err := f.K8sClient.CoreV1().ConfigMaps(f.Namespace.Name).Get(context.TODO(), trustedCAProxy, metav1.GetOptions{})
return err
}, time.Second*60, time.Second).Should(BeNil())
}, time.Second*60, time.Second).Should(Succeed())
}

verifyImportProxyConfigMapIsDeletedOnPodDeletion := func(pvc *corev1.PersistentVolumeClaim) {
Expand Down
7 changes: 4 additions & 3 deletions tests/monitoring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,12 @@ var _ = Describe("[Destructive] Monitoring Tests", Serial, func() {
if cron.Annotations == nil {
cron.Annotations = make(map[string]string)
}
// notarealsha
Comment thread
Acedus marked this conversation as resolved.
// not a real hash

cron.Annotations[controller.AnnSourceDesiredDigest] = "sha256:c616e1c85568b1f1d528da2b3dbc257fd2035ada441e286a8c42606491442a5d"
cron, err = f.CdiClient.CdiV1beta1().DataImportCrons(f.Namespace.Name).Update(context.TODO(), cron, metav1.UpdateOptions{})
return err
}, dataImportCronTimeout, pollingInterval).Should(BeNil())
}, dataImportCronTimeout, pollingInterval).Should(Succeed())
By(fmt.Sprintf("Ensuring metric value incremented to %d", i))
Eventually(func() int {
return getMetricValue(f, "kubevirt_cdi_dataimportcron_outdated")
Expand Down Expand Up @@ -689,7 +690,7 @@ func getPrometheusRule(f *framework.Framework) *promv1.PrometheusRule {
}
Eventually(func() error {
return f.CrClient.Get(context.TODO(), crclient.ObjectKeyFromObject(promRule), promRule)
}, 5*time.Minute, 1*time.Second).Should(BeNil())
}, 5*time.Minute, 1*time.Second).Should(Succeed())
return promRule
}

Expand Down
4 changes: 2 additions & 2 deletions tests/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ var _ = Describe("ALL Operator tests", func() {
nn := crclient.ObjectKey{Namespace: dv.Namespace, Name: dv.Name}
err = f.CrClient.Get(context.TODO(), nn, u)
return err
}, 1*time.Minute, 2*time.Second).Should(BeNil())
}, 1*time.Minute, 2*time.Second).Should(Succeed())

By("Scaling up CDI operator")
scaleDeployment(f, deploymentName, originalReplicaVal)
Expand Down Expand Up @@ -1126,7 +1126,7 @@ var _ = Describe("ALL Operator tests", func() {
Eventually(func() error {
_, err := utils.FindPodByPrefix(f.K8sClient, f.CdiInstallNs, cdiDeploymentPodPrefix, common.CDILabelSelector)
return err
}, 2*time.Minute, 1*time.Second).Should(BeNil())
}, 2*time.Minute, 1*time.Second).Should(Succeed())

pod, err := utils.FindPodByPrefix(f.K8sClient, f.CdiInstallNs, cdiDeploymentPodPrefix, common.CDILabelSelector)
Expect(err).ToNot(HaveOccurred())
Expand Down
Loading