Open shulin-sq opened 2 months ago
When the namespace isn't present, I think it would be better to use the namespace of the access log policy rather than "default" as the code implies above. I think the AccessLogPolicy CRD even documents this behaviour.
using this sample accesslogpolicy
https://github.com/aws/aws-application-networking-k8s/blob/086bcb0e3fd8281b37e03fcec4be0169c4d178bf/docs/api-types/access-log-policy.md?plain=1#L37-L47
results in an NPE
this is because in the controller: https://github.com/aws/aws-application-networking-k8s/blob/086bcb0e3fd8281b37e03fcec4be0169c4d178bf/pkg/controllers/accesslogpolicy_controller.go#L177-L183
namespace is nullchecked, but then the nil value is reused in
string(*alp.Spec.TargetRef.Namespace)
I looked at all other objects and it seems that they do not require the operator to specify target ref namespace. I'm wondering why in this accesslogpolicy we require target ref namespace instead of just defaulting it to the access log policy's namespace if it's missing. This is also the only place that uses
k8s.NamespaceOrDefault
for now.I would make a contribution to fix this but I'm not sure if the maintainers would prefer