Invalid address error in googlepubsub-provider
manhvo opened this issue · comments
When trying to create a Provider resource as below:
apiVersion: notification.toolkit.fluxcd.io/v1beta2
kind: Provider
metadata:
name: googlepubsub-provider
spec:
type: googlepubsub
address: myprojectid
channel: flux-notification
I keep getting this error:
NAME AGE READY STATUS
googlepubsub-provider 2d20h False invalid address myprojectid parse "myprojectid": invalid URI for request
This is debug logs from notification-controller pod:
{"level":"error","ts":"2023-12-11T21:13:00.099Z","msg":"Reconciliation has stalled","controller":"provider","controllerGroup":"notification.toolkit.fluxcd.io","controllerKind":"Provider","Provider":{"name":"googlepubsub-provider","namespace":"flux-system"},"namespace":"flux-system","name":"googlepubsub-provider","reconcileID":"5f6f438d-78f8-4113-8de5-d1ee18dc8052","error":"invalid address myprojectid: parse \"myprojectid\": invalid URI for request","stacktrace":"github.com/fluxcd/notification-controller/internal/controller.(*ProviderReconciler).Reconcile.func1\n\tgithub.com/fluxcd/notification-controller/internal/controller/provider_controller.go:115\ngithub.com/fluxcd/notification-controller/internal/controller.(*ProviderReconciler).Reconcile\n\tgithub.com/fluxcd/notification-controller/internal/controller/provider_controller.go:147\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile\n\tsigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:118\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\tsigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:314\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\tsigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:265\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\tsigs.k8s.io/controller-runtime@v0.15.0/pkg/internal/controller/controller.go:226"}
{"level":"debug","ts":"2023-12-11T21:13:00.099Z","logger":"events","msg":"invalid address myprojectid: parse \"myprojectid\": invalid URI for request","type":"Warning","object":{"kind":"Provider","namespace":"flux-system","name":"googlepubsub-provider","uid":"3628d627-de61-45c5-b3e8-09e4110aaee3","apiVersion":"notification.toolkit.fluxcd.io/v1beta2","resourceVersion":"1397382868"},"reason":"Failed"}
Can someone let me know what is the valid value for spec.address?
This document shows I should put project id, but it is not working.
https://fluxcd.io/flux/components/notification/providers/#google-pubsub
Hi, assuming that you're using the latest stable version of notification-controller v1.1.0, google pubsub and azure event hub are the only providers that don't have a URL for address. Looking at the code https://github.com/fluxcd/notification-controller/blob/v1.1.0/internal/controller/provider_controller.go#L181 and the examples in the docs, these two providers are expected to have secret refs which are required for the providers to work. Without secret refs, they are validated like other providers and are expected to have valid URL as address.
Notification-controller v1.2 is available which changes some of these validations and you may not see this same error anymore. But this version will be usable only with Flux v2.2, which is planned to release this week.
Hope this helps.
Thanks for your response @darkowlzz .
We are using notification-controller v1.0.0.
Regarding the secret, we are using GCP Workload Identity so I don't think we need to specify the secret.
https://fluxcd.io/flux/components/notification/providers/#google-pubsub
If no JSON credentials are specified, then the automatic authentication methods of the Google libraries will take place, and therefore methods like Workload Identity will be automatically attempted.
For now, looks like we need to upgrade notification-controller to v1.1.0, and then v1.2 later.
Seems like that may have missed during testing. Flux v2.2.0 was just released today. If you update you'll get notification-controller v1.2 which should no longer have the URL validation. Can you give it a try?
Maybe @matheuscscp can also provide some information on this topic.
Looks like in this pull request https://github.com/fluxcd/notification-controller/pull/565/files I forgot to remove the URL validation in some places. @darkowlzz after the googlepubsub
Provider was published we decided to lift this URL syntax validation for the address. I'm filing a hotfix PR here.
I upgraded to 2.2.2 and it works well.
However there isn't a status column as before:
NAME AGE
googlepubsub-provider 23h
Same thing with kubectl describe
$ kubectl describe providers.notification.toolkit.fluxcd.io googlepubsub-provider
Name: googlepubsub-provider
Namespace: flux-system
Labels: kustomize.toolkit.fluxcd.io/name=flux-system
kustomize.toolkit.fluxcd.io/namespace=flux-system
Annotations: <none>
API Version: notification.toolkit.fluxcd.io/v1beta3
Kind: Provider
Metadata:
Creation Timestamp: 2023-12-20T00:08:38Z
Generation: 1
Resource Version: 1410010580
UID: 227c1212-4dac-4f06-a137-74aa0b79fcfb
Spec:
Address: myprojectid
Channel: flux-notification
Type: googlepubsub
Events: <none>
Are these expected behavior?
Yes, that's the new static v1beta3 API, see https://github.com/fluxcd/notification-controller/blob/main/CHANGELOG.md#static-alerts-and-providers .