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

[Bug] create cluster datacenter relation failed #427

Closed
n-rodriguez opened this issue Jan 22, 2025 · 6 comments · Fixed by #521
Closed

[Bug] create cluster datacenter relation failed #427

n-rodriguez opened this issue Jan 22, 2025 · 6 comments · Fixed by #521
Labels
bug Something isn't working vmware Vmware source

Comments

@n-rodriguez
Copy link
Contributor

Is this urgent?

Yes, it's critical

How are you running netbox-ssot?

From source (Go)

What is the version of netbox-ssot

latest

Which module has the issue?

General (not module-specific)

Share your configuration

---
logger:
  level: 3
  dest: ""

netbox:
  apiToken: "foo"
  hostname: "netbox.foo.corp"
  httpScheme: http
  port: 80
  timeout: 30
  sourcePriority: ["vcenter67.corp"]
  removeOrphans: false

source:
  - name: vcenter67.corp
    type: vmware
    hostname: vcenter67.corp
    username: [email protected]
    password: "password"
    clusterSiteRelations:
      - .* = Foo
    hostSiteRelations:
      - .* = Foo
    clusterTenantRelations:
      - .* = ACME
    hostTenantRelations:
      - .* = ACME
    vmTenantRelations:
      - .* = ACME
    hostRoleRelations:
      - .* = Hypervisor ESX
    vmRoleRelations:
      - .* = Virtual Machine ESX
    vlanTenantRelations:
      - .* = ACME
    vlanSiteRelations:
      - .* = Foo

What is the problem?

2025/01/20 15:27:14 main.go:102         INFO    (vcenter.corp): Initializing source
2025/01/20 15:27:14 vmware.go:79        DEBUG   (vcenter.corp): vmware source vcenter.corp
2025/01/20 15:27:14 vmware.go:132       DEBUG   (vcenter.corp): Connection to vmware source vcenter.corp established successfully
2025/01/20 15:27:14 main.go:105         ERROR   (vcenter.corp): create cluster datacenter relation failed: finder failed finding clusters for datacenter: cluster '*' not found
2025/01/20 15:27:14 main.go:136         INFO    (main): Skipping removing orphaned objects because run failed...
2025/01/20 15:27:14 main.go:146         INFO    (main): ⚠ syncing of source vcenter.corp failed

Steps to reproduce

  1. run netbox-ssot -config ./config.yml

What did you expect to happen?

No failure

What actually happened?

2025/01/20 15:27:14 main.go:102         INFO    (vcenter.corp): Initializing source
2025/01/20 15:27:14 vmware.go:79        DEBUG   (vcenter.corp): vmware source vcenter.corp
2025/01/20 15:27:14 vmware.go:132       DEBUG   (vcenter.corp): Connection to vmware source vcenter.corp established successfully
2025/01/20 15:27:14 main.go:105         ERROR   (vcenter.corp): create cluster datacenter relation failed: finder failed finding clusters for datacenter: cluster '*' not found
2025/01/20 15:27:14 main.go:136         INFO    (main): Skipping removing orphaned objects because run failed...
2025/01/20 15:27:14 main.go:146         INFO    (main): ⚠ syncing of source vcenter.corp failed

Share DEBUG-level logs (remove sensitive information)


Share your environment details

No response

@bl4ko bl4ko added bug Something isn't working vmware Vmware source labels Jan 24, 2025
@bl4ko
Copy link
Member

bl4ko commented Jan 27, 2025

Hello, this error occurs when trying to find all clusters for a datacenter (see code). I am using wildcard character for searching, which in my local setups returns all clusters for the datacenter.

What datacenter/cluster relations do you have on this source?

@n-rodriguez
Copy link
Contributor Author

I think it comes from the fact that it's not a real VMware cluster (we don't have the license for this one).

Image
Image

@n-rodriguez
Copy link
Contributor Author

@n-rodriguez
Copy link
Contributor Author

I've made this dirty patch and it works :

diff --git a/internal/source/vmware/vmware.go b/internal/source/vmware/vmware.go
index fe31f00..35b458f 100644
--- a/internal/source/vmware/vmware.go
+++ b/internal/source/vmware/vmware.go
@@ -269,11 +269,19 @@ func (vc *VmwareSource) CreateClusterDataCenterRelation(
                finder.SetDatacenter(dc)
                clusters, err := finder.ClusterComputeResourceList(ctx, "*")
                if err != nil {
-                       return fmt.Errorf(
-                               "finder failed finding clusters for datacenter %s: %s",
-                               dc.InventoryPath,
-                               err,
-                       )
+                       clusters, err := finder.ComputeResourceList(ctx, "*")
+
+                       if err != nil {
+                               return fmt.Errorf(
+                                       "finder failed finding clusters for datacenter %s: %s",
+                                       dc.InventoryPath,
+                                       err,
+                               )
+                       }
+
+                       for _, cluster := range clusters {
+                               vc.Cluster2Datacenter[cluster.Reference().Value] = dc.Reference().Value
+                       }
                }

@bl4ko
Copy link
Member

bl4ko commented Feb 28, 2025

Thanks for the debug. Will you be willing to make a PR for this, since you have already created a patch?

@n-rodriguez
Copy link
Contributor Author

@bl4ko done! #521

@bl4ko bl4ko closed this as completed Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vmware Vmware source
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants