fluxcd / flux2

Open and extensible continuous delivery solution for Kubernetes. Powered by GitOps Toolkit.
https://fluxcd.io
Apache License 2.0
6.6k stars 609 forks source link

failed to checkout and determine revision: unable to clone authentication required #4292

Open dbacademy opened 1 year ago

dbacademy commented 1 year ago

Describe the bug

After generating new PAT for my Git repo ... reconcile is failing and unable to create gitrepo in my fluxcd instance.

Surprise the PAT i am using able to write while using with git push but it is failing while using in craeteing basing auth secret and use that to authenticate git repo defination.

{"level":"error","ts":"2023-10-02T14:10:45.352Z","msg":"Reconciler error","controller":"gitrepository","controllerGroup":"source.toolkit.fluxcd.io","controllerKind":"GitRepository","GitRepository":{"name":"git-repo-openshift-gitops","namespace":"flux-system"},"namespace":"flux-system","name":"git-repo-openshift-gitops","reconcileID":"69d86133-8e7c-4e5a-8f1b-d218a4129c52","error":"failed to checkout and determine revision: unable to clone 'https://github.com/dbacademy/openshift-gitops': authentication required"}

flux get all

NAME REVISION SUSPENDED READY MESSAGE
gitrepository/flux-system master@sha1:d67b28b4 False True stored artifact for revision 'master@sha1:d67b28b4' gitrepository/git-repo-openshift-gitops False False failed to checkout and determine revision: unable to clone 'https://github.com/dbacademy/openshift-gitops': authentication required

NAME

Steps to reproduce

  1. bootstrapping flux instance for my openshift cluster using git repository
  2. Flux installation is successful by other repositoty i am creating is failing

Expected behavior

New git repo should create and reconcile

Screenshots and recordings

No response

OS / Distro

Ubuntu 20.04

Flux version

flux version 2.0.1

Flux check

► checking prerequisites ✗ flux 2.0.1 <2.1.1 (new version is available, please upgrade) ✔ Kubernetes 1.25.10+8c21020 >=1.24.0-0 ✔ prerequisites checks passed

Git provider

No response

Container Registry provider

No response

Additional context

No response

Code of Conduct

aryan9600 commented 1 year ago

could you post kubectl describe gitrepository -n flux-system git-repo-openshift-gitops here?

dbacademy commented 10 months ago

it looks repeated error .. may be something wrong I am doing while creating secret with BASE64 PAT value ? anyway it was resolved but into a new enviornment again same issue .. I lost what i did to fix earlier :)

dbiswas@jumpbox:~$ oc describe gitrepository -n flux-system git-repo-openshift-gitops Name: git-repo-openshift-gitops Namespace: flux-system Labels: kustomize.toolkit.fluxcd.io/name=flux-system kustomize.toolkit.fluxcd.io/namespace=flux-system Annotations: API Version: source.toolkit.fluxcd.io/v1 Kind: GitRepository Metadata: Creation Timestamp: 2024-02-01T22:11:54Z Finalizers: finalizers.fluxcd.io Generation: 1 Managed Fields: API Version: source.toolkit.fluxcd.io/v1 Fields Type: FieldsV1 fieldsV1: f:metadata: f:labels: f:kustomize.toolkit.fluxcd.io/name: f:kustomize.toolkit.fluxcd.io/namespace: f:spec: f:interval: f:ref: f:branch: f:secretRef: f:name: f:url: Manager: kustomize-controller Operation: Apply Time: 2024-02-01T22:11:54Z API Version: source.toolkit.fluxcd.io/v1 Fields Type: FieldsV1 fieldsV1: f:metadata: f:finalizers: .: v:"finalizers.fluxcd.io": Manager: source-controller Operation: Update Time: 2024-02-01T22:11:54Z API Version: source.toolkit.fluxcd.io/v1 Fields Type: FieldsV1 fieldsV1: f:status: f:conditions: Manager: source-controller Operation: Update Subresource: status Time: 2024-02-01T22:18:19Z Resource Version: 1579125435 UID: d63d45d2-3121-4a33-b14a-b175bbb64938 Spec: Interval: 5m0s Ref: Branch: master Secret Ref: Name: git-access-auth Timeout: 60s URL: https://github.com/dbacademy/openshift-gitops.git Status: Conditions: Last Transition Time: 2024-02-01T22:18:19Z Message: building artifact Observed Generation: 1 Reason: ProgressingWithRetry Status: True Type: Reconciling Last Transition Time: 2024-02-01T22:18:19Z Message: failed to checkout and determine revision: unable to clone 'https://github.com/dbacademy/openshift-gitops.git': authentication required Observed Generation: 1 Reason: GitOperationFailed Status: False Type: Ready Last Transition Time: 2024-02-01T22:11:55Z Message: failed to checkout and determine revision: unable to clone 'https://github.com/dbacademy/openshift-gitops.git': authentication required Observed Generation: 1 Reason: GitOperationFailed Status: True Type: FetchFailed Observed Generation: -1 Events: Type Reason Age From Message


Warning GitOperationFailed 1s (x9 over 6m25s) source-controller failed to checkout and determine revision: unable to clone 'https://github.com/dbacademy/openshift-gitops.git': authentication required dbiswas@jumpbox:~$

stefanprodan commented 10 months ago

Delete the git-access-auth secret from the cluster and recreate it with the Flux CLI like so:

  flux -n flux-system create secret git git-access-auth \
    --url=https://github.com/dbacademy/openshift-gitops \
    --username=dbacademy \
    --password=YOUR-GH-PAT
ahalsudev commented 4 months ago

@stefanprodan what should the username be for a private repo in an organization? my username (to which the PAT is created)? or the org name?