spectrocloud / cluster-api-provider-maas

Cluster API Provider for MAAS (https://maas.io/)
Apache License 2.0
88 stars 24 forks source link

Error retrieving DNS resources #123

Open s0uky opened 7 months ago

s0uky commented 7 months ago

Hello, I'm forcing issue with retrieving DNS resources over API:

E0119 15:14:32.063206       1 maascluster_controller.go:242] controllers/MaasCluster "msg"="failed to reconcile load balancer" "error"="error retrieving dns resources \"maas1-k8s-dev-547d29.default\": parse \"http://maas-example.com:5240/MAAS\\n/api/2.0/dnsresources/\": net/url: invalid control character in URL" "maascluster"="maas1-k8s-dev-infra"
E0119 15:14:32.063703       1 controller.go:317] controller/maascluster "msg"="Reconciler error" "error"="error retrieving dns resources \"maas1-k8s-dev-infra-547d29.default\": parse \"http://maas-example.com:5240/MAAS\\n/api/2.0/dnsresources/\": net/url: invalid control character in URL" "name"="maas1-k8s-dev-infra" "namespace"="maas1-k8s-dev-infra" "reconciler group"="infrastructure.cluster.x-k8s.io" "reconciler kind"="MaasCluster"

I have only this in endpoint var: MAAS_ENDPOINT=http://maas-example.com:5240/MAAS Rest of URL is added automatically: \\n/api/2.0/dnsresources/\ and that newline sign could be the problem.

I'm using v0.5.0.

blackliner commented 7 months ago

Double check if your env variable contains a newline, maybe because you used echo to form it. The URL is likely just concatenated in the code.

https://github.com/spectrocloud/cluster-api-provider-maas/blob/4bc49a58344d25f916aef91e8d20881b0eac79bd/pkg/maas/scope/client.go#L28

s0uky commented 7 months ago

Correct, I used echo for it, my bad. MAAS_ENDPOINT is now correct, same as MAAS_API_KEY, but still no luck. I'm stuck on status: "error"="error retrieving dns resources', 'status:401, message: Authorization Error: 'Invalid signature. Expected signature base string. when I want retrieve DNS recources.

E0123 11:01:44.562268       1 maascluster_controller.go:242] controllers/MaasCluster "msg"="failed to reconcile load balancer" "error"="error retrieving dns resources \"maas1-k8s-dev-example-infra-3d6678.default\": status: 401, message: Authorization Error: 'Invalid signature. Expected signature base string: GET&http%3A%2F%2Fmaas.example.com%3A5240%2FMAAS%2Fapi%2F2.0%2Fdnsresources%2F&fqdn%3Dmaas1-k8s-dev-example-infra-3d6678.default%26oauth_consumer_key%3DMQC49M5b6WBUkXq2e2%26oauth_nonce%3Ddae91aa3-007f-409e-8498-02d168929736%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1706007704%26oauth_token%3DtULty7yqYkaGSdsVXH%26oauth_version%3D1.0'" "maascluster"="maas1-k8s-dev-example-infra"
sudharsanomprakash commented 6 months ago

@s0uky I guess it's issue with base64 encoding of your API key. Please check capmaas-manager-bootstrap-credentials