devfile / api

Kube-native API for cloud development workspaces specification
Apache License 2.0
235 stars 58 forks source link

Registry operator errors out if ingress domain is not set #1520

Open michael-valdron opened 1 month ago

michael-valdron commented 1 month ago

Which area this feature is related to?

/kind bug

Which area this bug is related to?

/area registry

What versions of software are you using?

Go project

Operating System and version: Fedora 39

Go Pkg Version: 1.19

Bug Summary

Describe the bug:

When deploying to a k8s environment such as Kubernetes or minikube, the operator produces an error when the given CR field DevfileRegistry.spec.k8s.ingress.domain is unset. There should be something stopping this from happening.

To Reproduce:

  1. Start minikube
  2. Run make install-cert and wait until cert-manager is ready
  3. Run make install && make deploy and wait until registry-operator-system is ready
  4. Run the follow command to attempt a deployment without DevfileRegistry.spec.k8s.ingress.domain set:
    cat <<EOF | kubectl apply -f -
    apiVersion: registry.devfile.io/v1alpha1
    kind: DevfileRegistry
    metadata:
    name: devfile-registry
    spec:
    devfileIndex:
    image: quay.io/devfile/devfile-index:next
    telemetry:
    registryName: test
    EOF

Expected behavior

Should either refuse to deploy without this field set (for k8s clusters) or should deploy without creating an ingress resource and log why its skipping this resource.

Any logs, error output, screenshots etc? Provide the devfile that sees this bug, if applicable

2024-04-12T15:37:32Z    ERROR   Reconciler error        {"controller": "devfileregistry", "controllerGroup": "registry.devfile.io",
 "controllerKind": "DevfileRegistry", "DevfileRegistry": {"name":"test-registry","namespace":"dr"}, "namespace": "dr", "name": 
"test-registry", "reconcileID": "0868b66d-16d7-48b0-90cc-380a4ed351dc", "error": "Ingress.extensions \"test-registry-devfile-
registry\" is invalid: spec.rules[0].host: Invalid value: \"test-registry-devfile-registry-dr.\": a lowercase RFC 1123 subdomain must 
consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 
'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')"}

Additional context

Any workaround?

Add webhook validation to refuse the deployment without DevfileRegistry.spec.k8s.ingress.domain.

Suggestion on how to fix the bug

Add control logic to skip the generation of the ingress resource if DevfileRegistry.spec.k8s.ingress.domain unset, additionally provide logging to explain why the ingress generation was skipped.