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

Using git as a source for k8s trigger: git executable not found #3065

Open
bkanuka opened this issue Mar 12, 2024 · 4 comments
Open

Using git as a source for k8s trigger: git executable not found #3065

bkanuka opened this issue Mar 12, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@bkanuka
Copy link

bkanuka commented Mar 12, 2024

Using git as a source for k8s trigger fails with error: "failed to fetch artifact, failed after retries: failed to fetch. err: exec: "git": executable file not found"

I'm using the following Sensor:

apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
  name: github-auto-build
spec:
  template:
    container:
      env:
        - name: DEBUG_LOG
          value: "true"
      volumeMounts:
        - mountPath: /git
          name: git
    volumes:
      - name: git
        emptyDir: {}
    serviceAccountName: operate-workflow-sa
  dependencies:
    - name: github
      eventSourceName: github
      eventName: github-climateengine
      filters:
        data:
          - path: headers.X-Github-Event
            type: string
            value:
              - push
  triggers:
    - template:
        name: workflow-trigger
        k8s:
          operation: create
          source:
            git:
              url: "https://github.com/argoproj/argo-workflows.git"
              cloneDirectory: "/git/argoproj"
              namespace: argo-events
              filePath: "examples/hello-world.yaml"
              branch: "master"

The template fails with the message:

2024-03-12T21:09:14.490Z ERROR argo-events.sensor sensors/listener.go:379 Failed to execute a trigger {"sensorName": "github-auto-build", "error": "failed to fetch artifact, failed after retries: failed to fetch. err: exec: \"git\": executable file not found in $PATH", "triggerName": "build-workflow", "triggeredBy": ["github"], "triggeredByEvents": ["34383866653034612d383330372d346161312d383264302d633730643666363239613730"]}

I can confirm that the Sensor is running a Pod with image quay.io/argoproj/argo-events:v1.9.1

Environment:

  • Kubernetes: v1.26.13
  • Argo Workflows: v3.5.5
  • Argo Events: v1.9.1

Message from the maintainers:

If you wish to see this enhancement implemented please add a 👍 reaction to this issue! We often sort issues this way to know what to prioritize.

@bkanuka bkanuka added the bug Something isn't working label Mar 12, 2024
@bkanuka
Copy link
Author

bkanuka commented Mar 12, 2024

It looks like git was added to an old image in this PR: #521
It's possible when moving to a single image, git was left out.

@bkanuka
Copy link
Author

bkanuka commented Mar 13, 2024

I can confirm that this is simply a matter of the git binary not being on the argo-events image. I used the following Dockerfile as the Sensor image and was able to use git sources successfully!

Ignore the hack of downloading argo-events in the Dockerfile (I didn't want to build the whole project from scratch 😉 ). The important part is simply installing git in the base and copying it to the final image like all the other binaries:

ARG ARCH=$TARGETARCH
####################################################################################################
# base
####################################################################################################
FROM alpine:3.16.2 as base
ARG ARCH
RUN apk update && apk upgrade && \
    apk add ca-certificates && \
    apk --no-cache add tzdata git

ENV ARGO_VERSION=v3.4.8

RUN wget -q https://github.com/argoproj/argo-workflows/releases/download/${ARGO_VERSION}/argo-linux-${ARCH}.gz
RUN gunzip -f argo-linux-${ARCH}.gz
RUN chmod +x argo-linux-${ARCH}
RUN mv ./argo-linux-${ARCH} /usr/local/bin/argo

RUN wget -q https://github.com/argoproj/argo-events/releases/download/v1.9.1/argo-events-linux-${ARCH}.gz
RUN gunzip -f argo-events-linux-${ARCH}.gz
RUN chmod +x argo-events-linux-${ARCH}
RUN mv ./argo-events-linux-${ARCH} /bin/argo-events

####################################################################################################
# argo-events
####################################################################################################
FROM scratch as argo-events
ARG ARCH
COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=base /usr/local/bin/argo /usr/local/bin/argo
COPY --from=base /bin/argo-events /bin/argo-events
COPY --from=base /usr/bin/git /usr/bin/git
ENTRYPOINT [ "/bin/argo-events" ]

Copy link
Contributor

This issue has been automatically marked as stale because it has not had
any activity in the last 60 days. It will be closed if no further activity
occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label May 12, 2024
@bkanuka
Copy link
Author

bkanuka commented May 13, 2024

This still exists and is a relatively easy fix. I will look into making a PR if I have time

@github-actions github-actions bot removed the stale label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant