coopnorge / provider-github

Apache License 2.0
23 stars 13 forks source link

Examples provided in this repo are not getting synced #26

Open vdveldet opened 1 year ago

vdveldet commented 1 year ago

I basically followed the examples in the repo here but my hello-provider-github is not getting in sync.

  1. Installed provider
    apiVersion: pkg.crossplane.io/v1
    kind: Provider
    metadata:
    name: provider-github
    spec:
    package: xpkg.upbound.io/coopnorge/provider-github:v0.3.2
  2. Added the credentials and connection to github
    
    ---
    apiVersion: v1
    kind: Secret
    metadata:
    name: provider-secret
    namespace: crossplane-system
    type: Opaque
    stringData:
    credentials: "{\"token\":\"${GH_TOKEN}\",\"owner\":\"${GH_OWNER}\"}"

apiVersion: github.upbound.io/v1beta1 kind: ProviderConfig metadata: name: default spec: credentials: source: Secret secretRef: name: provider-secret namespace: crossplane-system key: credentials

3. Added the hello-provider-github repository

apiVersion: repo.github.upbound.io/v1alpha1 kind: Repository metadata: name: hello-provider-github spec: forProvider: visibility: public gitignoreTemplate: Terraform

# securityAndAnalysis:
#   - advancedSecurity:
#     - status: enabled
#     secretScanning:
#     - status: disabled
#     secretScanningPushProtection:
#     - status: disabled  

providerConfigRef: name: default

kubectl -n crossplane-system get Repository hello-provider-github NAME READY SYNCED EXTERNAL-NAME AGE hello-provider-github False hello-provider-github 18m

kubectl -n crossplane-system describe Repository hello-provider-github Name: hello-provider-github Namespace:
Labels: Annotations: crossplane.io/external-name: hello-provider-github API Version: repo.github.upbound.io/v1alpha1 Kind: Repository Metadata: Creation Timestamp: 2023-05-12T06:42:05Z Generation: 1 Managed Fields: API Version: repo.github.upbound.io/v1alpha1 Fields Type: FieldsV1 fieldsV1: f:metadata: f:annotations: .: f:kubectl.kubernetes.io/last-applied-configuration: f:spec: .: f:deletionPolicy: f:forProvider: .: f:gitignoreTemplate: f:visibility: f:providerConfigRef: .: f:name: Manager: kubectl Operation: Update Time: 2023-05-12T06:42:05Z API Version: repo.github.upbound.io/v1alpha1 Fields Type: FieldsV1 fieldsV1: f:metadata: f:annotations: f:crossplane.io/external-name: Manager: provider Operation: Update Time: 2023-05-12T06:42:05Z API Version: repo.github.upbound.io/v1alpha1 Fields Type: FieldsV1 fieldsV1: f:status: .: f:atProvider: f:conditions: Manager: provider Operation: Update Subresource: status Time: 2023-05-12T06:42:06Z Resource Version: 59230867 UID: 709fc2cc-560a-4a84-93fe-2696d7a10eb5 Spec: Deletion Policy: Delete For Provider: Gitignore Template: Terraform Visibility: public Provider Config Ref: Name: default Status: At Provider: Conditions: Last Transition Time: 2023-05-12T06:42:06Z Message: observe failed: cannot run refresh: refresh failed: Invalid reference: A reference to a resource type must be followed by at least one attribute access, specifying the resource name. Invalid reference: A reference to a resource type must be followed by at least one attribute access, specifying the resource name. Reason: ReconcileError Status: False Type: Synced Events: Type Reason Age From Message


Warning CannotObserveExternalResource 3s (x24 over 18m) managed/repo.github.upbound.io/v1alpha1, kind=repository cannot run refresh: refresh failed: Invalid reference: A reference to a resource type must be followed by at least one attribute access, specifying the resource name. Invalid reference: A reference to a resource type must be followed by at least one attribute access, specifying the resource name.

AtzeDeVries commented 1 year ago

Sorry for the late reply. Is the repository being created? Are you sure the credentials injected are correct?

vdveldet commented 1 year ago

Hi,

Thanks for the reply, sorry for my late reply now ...

When performing the curl below I get the response. The GH_TOKEN is used in the secret that is set to the ProviderConfig but nothing is created.

curl --request GET --url "https://api.github.com/octocat" --header "Authorization: Bearer ${GH_TOKEN}" --header "X-GitHub-Api-Version: 2022-11-28"

               MMM.           .MMM
               MMMMMMMMMMMMMMMMMMM
               MMMMMMMMMMMMMMMMMMM      ______________________________________
              MMMMMMMMMMMMMMMMMMMMM    |                                      |
             MMMMMMMMMMMMMMMMMMMMMMM   | Mind your words, they are important. |
            MMMMMMMMMMMMMMMMMMMMMMMM   |_   __________________________________|
            MMMM::- -:::::::- -::MMMM    |/
             MM~:~ 00~:::::~ 00~:~MM
        .. MMMMM::.00:::+:::.00::MMMMM ..
              .MM::::: ._. :::::MM.
                 MMMM;:::::;MMMM
          -MM        MMMMMMM
          ^  M+     MMMMMMMMM
              MMMMMMM MM MM MM
                   MM MM MM MM
                   MM MM MM MM
                .~~MM~MM~MM~MM~~.
             ~~~~MM:~MM~~~MM~:MM~~~~
            ~~~~~~==~==~~~==~==~~~~~~
             ~~~~~~==~==~==~==~~~~~~
                 :~==~==~==~==~~
vdveldet commented 1 year ago

When running in debug mode it will show

1.6923536305638356e+09  DEBUG   events  Warning {"object": {"kind":"Repository","name":"hello-provider-github","uid":"3ce8e639-fbbe-4d72-902a-1d06e873f85b","apiVersion":"repo.github.upbound.io/v1alpha1","resourceVersion":"16837787"}, "reason": "CannotObserveExternalResource", "message": "cannot run refresh: refresh failed: Invalid reference: A reference to a resource type must be followed by at least one attribute access, specifying the resource name.\nInvalid reference: A reference to a resource type must be followed by at least one attribute access, specifying the resource name."}
1.6923536307647905e+09  DEBUG   provider-github Reconciling {"controller": "managed/repo.github.upbound.io/v1alpha1, kind=repository", "request": "/hello-provider-github"}
1.6923536311121776e+09  DEBUG   provider-github refresh ended   {"workspace": "/tmp/3ce8e639-fbbe-4d72-902a-1d06e873f85b", "out": "{\"@level\":\"info\",\"@message\":\"Terraform 1.3.6\",\"@module\":\"terraform.ui\",\"@timestamp\":\"2023-08-18T10:13:50.802903Z\",\"terraform\":\"1.3.6\",\"type\":\"version\",\"ui\":\"1.0\"}\n{\"@level\":\"error\",\"@message\":\"Error: Invalid reference\",\"@module\":\"terraform.ui\",\"@timestamp\":\"2023-08-18T10:13:51.107617Z\",\"diagnostic\":{\"severity\":\"error\",\"summary\":\"Invalid reference\",\"detail\":\"A reference to a resource type must be followed by at least one attribute access, specifying the resource name.\",\"range\":{\"filename\":\"main.tf.json\",\"start\":{\"line\":1,\"column\":35,\"byte\":34},\"end\":{\"line\":1,\"column\":43,\"byte\":42}},\"snippet\":{\"context\":\"provider.github\",\"code\":\"{\\\"provider\\\":{\\\"github\\\":{\\\"owner\\\":\\\"REDACTED\\\",\\\"token\\\":\\\"REDACTED\\\"}},\\\"resource\\\":{\\\"github_repository\\\":{\\\"hello-provider-github\\\":{\\\"gitignore_template\\\":\\\"Terraform\\\",\\\"lifecycle\\\":{\\\"prevent_destroy\\\":true},\\\"name\\\":\\\"hello-provider-github\\\",\\\"visibility\\\":\\\"public\\\"}}},\\\"terraform\\\":{\\\"required_providers\\\":{\\\"github\\\":{\\\"source\\\":\\\"integrations/github\\\",\\\"version\\\":\\\"5.15.0\\\"}}}}\",\"start_line\":1,\"highlight_start_offset\":34,\"highlight_end_offset\":42,\"values\":[]}},\"type\":\"diagnostic\"}\n{\"@level\":\"error\",\"@message\":\"Error: Invalid reference\",\"@module\":\"terraform.ui\",\"@timestamp\":\"2023-08-18T10:13:51.107851Z\",\"diagnostic\":{\"severity\":\"error\",\"summary\":\"Invalid reference\",\"detail\":\"A reference to a resource type must be followed by at least one attribute access, specifying the resource name.\",\"range\":{\"filename\":\"main.tf.json\",\"start\":{\"line\":1,\"column\":57,\"byte\":56},\"end\":{\"line\":1,\"column\":65,\"byte\":64}},\"snippet\":{\"context\":\"provider.github\",\"code\":\"{\\\"provider\\\":{\\\"github\\\":{\\\"owner\\\":\\\"REDACTED\\\",\\\"token\\\":\\\"REDACTED\\\"}},\\\"resource\\\":{\\\"github_repository\\\":{\\\"hello-provider-github\\\":{\\\"gitignore_template\\\":\\\"Terraform\\\",\\\"lifecycle\\\":{\\\"prevent_destroy\\\":true},\\\"name\\\":\\\"hello-provider-github\\\",\\\"visibility\\\":\\\"public\\\"}}},\\\"terraform\\\":{\\\"required_providers\\\":{\\\"github\\\":{\\\"source\\\":\\\"integrations/github\\\",\\\"version\\\":\\\"5.15.0\\\"}}}}\",\"start_line\":1,\"highlight_start_offset\":56,\"highlight_end_offset\":64,\"values\":[]}},\"type\":\"diagnostic\"}\n"}
1.6923536311122892e+09  DEBUG   provider-github Cannot observe external resource    {"controller": "managed/repo.github.upbound.io/v1alpha1, kind=repository", "request": "/hello-provider-github", "uid": "3ce8e639-fbbe-4d72-902a-1d06e873f85b", "version": "16837787", "external-name": "hello-provider-github", "error": "cannot run refresh: refresh failed: Invalid reference: A reference to a resource type must be followed by at least one attribute access, specifying the resource name.\nInvalid reference: A reference to a resource type must be followed by at least one attribute access, specifying the resource name.", "errorVerbose": "refresh failed: Invalid reference: A reference to a resource type must be followed by at least one attribute access, specifying the resource name.\nInvalid reference: A reference to a resource type must be followed by at least one attribute access, specifying the resource name.\ncannot run refresh\ngithub.com/upbound/upjet/pkg/controller.(*external).Observe\n\tgithub.com/upbound/upjet@v0.8.0-rc.0.0.20221024111721-c82119f5ef34/pkg/controller/external.go:113\ngithub.com/crossplane/crossplane-runtime/pkg/reconciler/managed.(*Reconciler).Reconcile\n\tgithub.com/crossplane/crossplane-runtime@v0.19.0-rc.0.0.20221012013934-bce61005a175/pkg/reconciler/managed/reconciler.go:780\ngithub.com/crossplane/crossplane-runtime/pkg/ratelimiter.(*Reconciler).Reconcile\n\tgithub.com/crossplane/crossplane-runtime@v0.19.0-rc.0.0.20221012013934-bce61005a175/pkg/ratelimiter/reconciler.go:54\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile\n\tsigs.k8s.io/controller-runtime@v0.12.1/pkg/internal/controller/controller.go:121\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\tsigs.k8s.io/controller-runtime@v0.12.1/pkg/internal/controller/controller.go:320\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\tsigs.k8s.io/controller-runtime@v0.12.1/pkg/internal/controller/controller.go:273\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\tsigs.k8s.io/controller-runtime@v0.12.1/pkg/internal/controller/controller.go:234\nruntime.goexit\n\truntime/asm_amd64.s:1594"}
oblogic7 commented 8 months ago

I've run into a similar issue. In my case, the API rate limit is being hit and causing that message. You can check your API usage with the following command.

curl -H "Authorization: token ${TOKEN}" https://api.github.com/rate_limit
lacroi-m-insta commented 1 month ago

@oblogic7 this solves the rate limit issue for 401 case https://github.com/coopnorge/provider-github/pull/81