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

Examples provided in this repo are not getting synced #26

Open
vdveldet opened this issue May 12, 2023 · 5 comments
Open

Examples provided in this repo are not getting synced #26

vdveldet opened this issue May 12, 2023 · 5 comments

Comments

@vdveldet
Copy link

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
  1. 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
  1. 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:       <none>
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
Copy link
Collaborator

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

@vdveldet
Copy link
Author

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
Copy link
Author

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/[email protected]/pkg/controller/external.go:113\ngithub.com/crossplane/crossplane-runtime/pkg/reconciler/managed.(*Reconciler).Reconcile\n\tgithub.com/crossplane/[email protected]/pkg/reconciler/managed/reconciler.go:780\ngithub.com/crossplane/crossplane-runtime/pkg/ratelimiter.(*Reconciler).Reconcile\n\tgithub.com/crossplane/[email protected]/pkg/ratelimiter/reconciler.go:54\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile\n\tsigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:121\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\tsigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:320\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\tsigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:273\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\tsigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:234\nruntime.goexit\n\truntime/asm_amd64.s:1594"}

@oblogic7
Copy link

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
Copy link
Contributor

@oblogic7 this solves the rate limit issue for 401 case
#81

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

4 participants