argo-events icon indicating copy to clipboard operation
argo-events copied to clipboard

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

Open bkanuka opened this issue 3 months ago • 4 comments

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 avatar Mar 12 '24 21:03 bkanuka

It looks like git was added to an old image in this PR: https://github.com/argoproj/argo-events/pull/521 It's possible when moving to a single image, git was left out.

bkanuka avatar Mar 12 '24 21:03 bkanuka

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 :wink: ). 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" ]

bkanuka avatar Mar 13 '24 01:03 bkanuka

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[bot] avatar May 12 '24 02:05 github-actions[bot]

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

bkanuka avatar May 13 '24 15:05 bkanuka