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

What is the proper way to observe a Group created outside of crossplane (without knowing the ID) #163

Closed
patpicos opened this issue Oct 21, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@patpicos
Copy link

What happened?

I would like to observe a group that was pre-created outside of Crossplane. I wish to look it up based on its name or path, or a combination there of. The goal is to avoid users from populating the group id (they are easy to misconfigure).

I have tried a few approaches without success.

How can we reproduce it?

Attempt that was closest to get an outcome:

apiVersion: groups.gitlab.crossplane.io/v1alpha1
kind: Group
metadata:
  name: nk-rdc-charts-dev
  namespace: isv-onboarding-continuous-deployment
spec:
  deletionPolicy: Delete
  forProvider:
    name: nk-rdc-charts-dev
    path: nk-rdc-dev
    parentId: 741
  managementPolicies:
  - Observe
  providerConfigRef:
    name: gitlab-provider-config

The logs show that it found the resource (ID 870), but would not update due to mgmt policies..

2024-10-21T14:20:46.717Z        DEBUG   provider-gitlab Skipping update due to managementPolicies. Reconciliation succeeded     {"controller": "managed/group", "request": {"name":"nk-rdc-jzsqb-charts-grp"}, "uid": "fb1adeb6-6d19-4078-b430-b93c2c133b19", "version": "1704501", "external-name": "870", "requeue-after": "2024-10-21T14:21:46.717Z"}

The example below failed because the external-name is not an integer (i cant put "870" because thats what i wish to lookup!)

apiVersion: groups.gitlab.crossplane.io/v1alpha1
kind: Group
metadata:
  annotations:
    crossplane.io/external-name: nk-rdc-charts-dev
  name: test-observe
  namespace: isv-onboarding-continuous-deployment
spec:
  deletionPolicy: Delete
  # forProvider:
  #   name: nk-rdc-charts-dev
  #   path: nk-rdc-dev
  #   parentId: 741
  managementPolicies:
  - Observe
  providerConfigRef:
    name: gitlab-provider-config

Then i tried uncommenting the forProvider because they are required...but that did not work because metadata.name took precedence

I am starting to think i need to create myself a lookup table rather than trying to observe it..

What environment did it happen in?

Crossplane version: v1.16
Crossplane Provider GitLab version: v0.9.0

@patpicos patpicos added the bug Something isn't working label Oct 21, 2024
@MisterMX
Copy link
Collaborator

The only way to observe an external resource that has not been created by the provider itself is to set manually set crossplane.io/external-name annotation to the corresponding ID / resource name. Normally this would be automatically by the provider before or after the creation of the resource, depending on whether it is an auto-generated ID or not.

@patpicos
Copy link
Author

gotcha. observing a resource will not work for what I am trying to do. I went a different route.

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

2 participants