Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bazel build issues #1083

Open
jsakil14 opened this issue Oct 3, 2024 Discussed in #1082 · 10 comments
Open

bazel build issues #1083

jsakil14 opened this issue Oct 3, 2024 Discussed in #1082 · 10 comments

Comments

@jsakil14
Copy link

jsakil14 commented Oct 3, 2024

Discussed in https://github.com/orgs/kubev2v/discussions/1082

Originally posted by jsakil14 October 3, 2024
I am getting errors: when running below

bazel run push-forklift-operator
Starting local Bazel server and connecting to it...
ERROR: /root/.cache/bazel/_bazel_root/3d084ffa320f6dc5a80a67e2b78d0f1c/external/io_bazel_rules_docker/platforms/BUILD:78:9: in constraint_values attribute of platform rule @@io_bazel_rules_docker//platforms:image_transition: '@@io_bazel_rules_docker//platforms:image_transition_cpu' does not have mandatory providers: 'ConstraintValueInfo'
ERROR: /root/.cache/bazel/_bazel_root/3d084ffa320f6dc5a80a67e2b78d0f1c/external/io_bazel_rules_docker/platforms/BUILD:78:9: in constraint_values attribute of platform rule @@io_bazel_rules_docker//platforms:image_transition: '@@io_bazel_rules_docker//platforms:image_transition_os' does not have mandatory providers: 'ConstraintValueInfo'
ERROR: /root/.cache/bazel/_bazel_root/3d084ffa320f6dc5a80a67e2b78d0f1c/external/io_bazel_rules_docker/platforms/BUILD:78:9: Analysis of target '@@io_bazel_rules_docker//platforms:image_transition' failed
ERROR: /root/forklift/operator/BUILD.bazel:37:16: Target @@io_bazel_rules_docker//platforms:image_transition was referenced as a platform, but does not provide PlatformInfo
ERROR: Analysis of target '//:push-forklift-operator' failed; build aborted: Analysis failed
INFO: Elapsed time: 3.524s, Critical Path: 0.02s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target
```</div>
@jsakil14
Copy link
Author

jsakil14 commented Oct 8, 2024

bump!

@jsakil14
Copy link
Author

jsakil14 commented Oct 8, 2024

@mnecas Is this relevant with #1046

@mnecas
Copy link
Member

mnecas commented Oct 8, 2024

@jsakil14 have you tried the make push-operator-image?

@mnecas
Copy link
Member

mnecas commented Oct 8, 2024

I just run the make build-operator-image and without a problem

@mnecas
Copy link
Member

mnecas commented Oct 8, 2024

We should update the readme, but also running the bazel run push-forklift-operator worked for me.
Have you set all env variables? Which bazel version are you using?

@jsakil14
Copy link
Author

jsakil14 commented Oct 9, 2024

https://github.com/kubev2v/forklift#runing-operator-build I followed this -

I dont have REGISTRY_ORG , so ignored this...

export REGISTRY=internal artifcatory local registry
export REGISTRY_TAG=latest
CONTROLLER_IMAGE=${REGISTRY}/forklift-controller:${REGISTRY_TAG}
OPERATOR_IMAGE=${REGISTRY}/forklift-operator:${REGISTRY_TAG}

My install is on a kubevirt cluster running on bare metal k8s nodes.

bazel version

bazel 7.3.2

From the error: Do we need to set this values? somewhere?

ERROR: /root/.cache/bazel/_bazel_root/3d084ffa320f6dc5a80a67e2b78d0f1c/external/io_bazel_rules_docker/platforms/BUILD:78:9: in constraint_values attribute of platform rule @@io_bazel_rules_docker//platforms:image_transition: '@@io_bazel_rules_docker//platforms:image_transition_os' does not have mandatory providers: 'ConstraintValueInfo'

@mnecas
Copy link
Member

mnecas commented Oct 14, 2024

@jsakil14 if you have some problems with the bazel please try the new dockerfiles, I have not tested them personally but they should correspond to the forklift bazel build. We are slowly moving away from bazel so some stuff might be broken.
https://github.com/kubev2v/forklift/tree/main/build

@jsakil14
Copy link
Author

@jsakil14 if you have some problems with the bazel please try the new dockerfiles, I have not tested them personally but they should correspond to the forklift bazel build. We are slowly moving away from bazel so some stuff might be broken. https://github.com/kubev2v/forklift/tree/main/build

Could you guide me on how to install using dockerfiles? I installed forklift using olm and not with bazel. @mnecas

@jsakil14
Copy link
Author

I had to run it like below

bazel run push-forklift-operator --@io_bazel_rules_docker//transitions:enable=false

then it works!

@jsakil14
Copy link
Author

docker

Is this expected? I am building image file using podman...

ls
Dockerfile
4744262@4744262-de197 v2v % cat Dockerfile 
FROM registry.access.redhat.com/ubi9:9.4-1214.1729773476 AS appliance

ENV LIBGUESTFS_BACKEND direct

RUN subscription-manager register --org $(cat "/activation-key/org") --activationkey $(cat "/activation-key/activationkey")

RUN subscription-manager repos --enable=codeready-builder-for-rhel-9-x86_64-rhui-rpms

RUN dnf update -y && \
   dnf install -y --setopt=install_weak_deps=False \
       qemu-img \
       libguestfs-devel \
       libguestfs-winsupport \
       libguestfs-xfs

# Create tarball for the appliance.
RUN mkdir -p /usr/local/lib/guestfs/appliance && \
   cd /usr/local/lib/guestfs/appliance && \
   libguestfs-make-fixed-appliance . && \
   qemu-img convert -c -O qcow2 root root.qcow2 && \
   mv -vf root.qcow2 root

FROM registry.access.redhat.com/ubi9/go-toolset:1.21.13-2.1727893526 AS builder
WORKDIR /app
COPY --chown=1001:0 ./ ./
ENV GOFLAGS "-mod=vendor -tags=strictfipsruntime"
ENV GOEXPERIMENT strictfipsruntime

RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o virt-v2v-monitor github.com/konveyor/forklift-controller/cmd/virt-v2v-monitor
RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o image-converter github.com/konveyor/forklift-controller/cmd/image-converter
RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o virt-v2v-wrapper virt-v2v/cmd/entrypoint.go

FROM registry.access.redhat.com/ubi9:9.4-1214.1729773476

# RUN rm /etc/pki/tls/fips_local.cnf && \
#     echo -e '[fips_sect]\ntls1-prf-ems-check = 0\nactivate = 1' > /etc/pki/tls/fips_local.cnf && \
#     sed -i '/^\\[ crypto_policy \\]/a Options=RHNoEnforceEMSinFIPS' /etc/pki/tls/openssl.cnf
# RUN mv /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt.bak && \
#     ln -sf /opt/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt

# RUN microdnf install -y subscription-manager
RUN subscription-manager register --org $(cat "/activation-key/org") --activationkey $(cat "/activation-key/activationkey")
RUN mkdir /disks && \
   source /etc/os-release && \
   dnf install -y \
       virt-v2v \
       virtio-win && \
   dnf clean all

ENV LIBGUESTFS_BACKEND=direct

RUN mkdir -p /usr/lib64/guestfs/appliance
COPY --from=appliance /usr/local/lib/guestfs/appliance /usr/lib64/guestfs/appliance

COPY --from=builder /app/virt-v2v-monitor /usr/local/bin/virt-v2v-monitor

COPY --from=builder /app/image-converter /usr/local/bin/image-converter

COPY --from=builder /app/virt-v2v-wrapper /usr/bin/virt-v2v-wrapper

ENTRYPOINT ["/usr/bin/virt-v2v-wrapper"]

LABEL \
       com.redhat.component="mtv-virt-v2v-container" \
       name="migration-toolkit-virtualization/mtv-virt-v2v-rhel9" \
       license="Apache License 2.0" \
       io.k8s.display-name="Migration Toolkit for Virtualization" \
       io.k8s.description="Migration Toolkit for Virtualization - Virt-V2V" \
       io.openshift.tags="migration,mtv,forklift" \
       summary="Migration Toolkit for Virtualization - Virt-V2V" \
       description="Migration Toolkit for Virtualization - Virt-V2V" \
       vendor="Red Hat, Inc." \
       maintainer="Migration Toolkit for Virtualization Team <migtoolkit-virt@redhat.com>" \
       distribution-scope="public" \
       release="v2.7" \
       url="https://github.com/kubev2v/forklift" \
       version="v2.7.1"

4744262@4744262-de197 v2v % podman build -t forklift-virt-v2v-rhel9 . --tls-verify=false   
[1/3] STEP 1/6: FROM registry.access.redhat.com/ubi9:9.4-1214.1729773476 AS appliance
[1/3] STEP 2/6: ENV LIBGUESTFS_BACKEND direct
--> Using cache a6ec4c6b4c9cc4238289ba6af7401e831e56dc3a1d0b6db1aae9b2db6f0740e0
--> a6ec4c6b4c9c
[1/3] STEP 3/6: RUN subscription-manager register --org $(cat "/activation-key/org") --activationkey $(cat "/activation-key/activationkey")
cat: /activation-key/org: No such file or directory
cat: /activation-key/activationkey: No such file or directory
usage: subscription-manager register [OPTIONS]
subscription-manager: error: argument --org: expected one argument
Error: building at STEP "RUN subscription-manager register --org $(cat "/activation-key/org") --activationkey $(cat "/activation-key/activationkey")": while running runtime: exit status 2

@jsakil14 jsakil14 reopened this Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants