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

Allow multiple ingress hosts to be defined when using ingress #1377

Merged
merged 31 commits into from
Jan 5, 2024

Conversation

guillaumelfv
Copy link
Contributor

SUMMARY

Deprecate hostname and ingress_tls_secret spec. Add a new spec ingress_hosts which allow multiple ingress hosts to be defined when using ingress.

ingress_hosts:
  - hostname: awx-demo.example.com
    tls_secret: example-com-tls
  - hostname: awx-sample.example.io
  • ingress_hosts default to empty and when defined hostname is mandatory but tls_secret is optional.
  • ingress_hosts has priority in case both ingress_hosts and hostname/ingress_tls_secret are defined
  • hostname and ingress_tls_secret marked as deprecated

For example the above ingress_hosts definition will be render as follow:

spec:
  rules:
  - host: awx-demo.example.com
    http:
      paths:
      - backend:
          service:
            name: awx-service
            port:
              number: 80
        path: /
        pathType: Prefix
  - host: awx-sample.example.io
    http:
      paths:
      - backend:
          service:
            name: awx-service
            port:
              number: 80
        path: /
        pathType: Prefix
  tls:
  - hosts:
    - awx-demo.example.com
    secretName: example-com-tls

fixes #897 #1318

ISSUE TYPE
  • New or Enhanced Feature
ADDITIONAL INFORMATION
  • Spec hostname is marked as deprecated but still supported
  • Spec ingress_tls_secret is marked as deprecated but still supported

This change is backward compatible and priority are as follow based on the spec definition:

hosname ingress_hosts Used
defined undefined hostname
undefined defined ingress_hosts
defined defined ingress_hosts

@fciava
Copy link

fciava commented May 3, 2023

Hi!
Any news on this? It would be really helpful for our company workload.
Thanks

@fosterseth fosterseth self-assigned this May 3, 2023
@guillaumelfv
Copy link
Contributor Author

@fosterseth i rebased and also push the fix for the molecule CI warnings and error. Can we rerun the CI ?

@guillaumelfv
Copy link
Contributor Author

guillaumelfv commented May 11, 2023

@fosterseth i am not sure what the CI failure are about.

The PR check https://github.com/ansible/awx-operator/actions/runs/4925590784/jobs/8831262726?pr=1377 just report This job failed with no log output and when i checked what it does, my PR does have New or Enhanced Feature in the issue type body of the PR.

For the molecule timing out not sure why it timeout, I am checking the logs but for now I can not find anything

@guillaumelfv
Copy link
Contributor Author

Hi, could I get help to have this merged please ?

@guillaumelfv
Copy link
Contributor Author

Anything blocking the merge of this PR ? Can we run the CI again ?

@guillaumelfv
Copy link
Contributor Author

guillaumelfv commented Jul 17, 2023

@fosterseth @rooftopcellist could I please get at least a new CI run on this MR ? Or any feedback on why it can not be merged ?

@fosterseth
Copy link
Member

when I tried your example, I got the following operator error

ingress_hosts:
  - hostname: awx-demo.example.com
    tls_secret: example-com-tls
  - hostname: awx-sample.example.io

The error was: 'dict object' has no attribute 'tls_secret'.

is tls_secret optional or required?

@guillaumelfv
Copy link
Contributor Author

@fosterseth it was supposed to be optional but it seems there was a mistake in my jinja. I fixed it just now (2331bbc)
and tls_secret should be optional, tested on my side

@fosterseth
Copy link
Member

tested again, looks like it works correctly now

@guillaumelfv
Copy link
Contributor Author

@fosterseth any update ? I just rebased again

@fosterseth
Copy link
Member

checked for backward compatibility, which seems to work fine
awx spec

---
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
  name: awx
spec:
  service_type: nodeport
  ingress_type: ingress
  ingress_tls_secret: example-com-tls
  hostname: awx-demo.example.com

generated ingress

spec:
  rules:
  - host: awx-demo.example.com
    http:
      paths:
      - backend:
          service:
            name: awx-service
            port:
              number: 80
        path: /
        pathType: Prefix
  tls:
  - hosts:
    - awx-demo.example.com
    secretName: example-com-tls

@rooftopcellist
Copy link
Member

Can we really mark hostname as deprecated if there is no other way to configure this for ingress_type: Route? I don't see any changes in the part of ingress.yaml.j2 that pertains to Routes.

@guillaumelfv
Copy link
Contributor Author

guillaumelfv commented Oct 26, 2023

Can we really mark hostname as deprecated if there is no other way to configure this for ingress_type: Route? I don't see any changes in the part of ingress.yaml.j2 that pertains to Routes.

@rooftopcellist i do not see anything in roles/installer/templates/networking/ingress.yaml.j2 for the ingress type route using the hostname variable no ? It seems to only use host: {{ route_host }}.

@rooftopcellist
Copy link
Member

@guillaumelfv Hey, thank you for following up on this. You are right, hostname is not referenced in Route, so it should be safe to deprecate. Thanks for pointing that out. Can you rebase one last time? Sorry for the churn.

This is ready to merge, we just need to get CI passing.

@rooftopcellist
Copy link
Member

I looks like I was able to rebase via the UI, so we can just wait for CI now.

@guillaumelfv
Copy link
Contributor Author

could we please run the CI again ? I want to see the latest logs to see if i can debug why the molecule tests failed.
@rooftopcellist care you able to run the molecule tests locally ?

@djyasin
Copy link
Member

djyasin commented Jan 3, 2024

@guillaumelfv Would you mind rebasing one more time for us? Once the conflicts are fixed we are happy to get this merged!

@guillaumelfv
Copy link
Contributor Author

@djyasin I rebased just now

@djyasin
Copy link
Member

djyasin commented Jan 4, 2024

@djyasin I rebased just now

Thank you so much! I am running the CI checks now and as long as those are passing I will merge this in!

@guillaumelfv
Copy link
Contributor Author

guillaumelfv commented Jan 5, 2024

@djyasin It timeout, same as any previous run before. According to the logs it silently fail for this task:

60058Z TASK [Create or update the awx.ansible.com/v1alpha1.AWX] ***********************
...
"msg": "\"AWX\" \"example-awx\": Timed out waiting on resource",�[0m
...

Then timeout. I can see the tasks use the following resource template. I will check further on my free time and run the molecule tests locally. Any help from the team, if possible, would be appreciated.

@guillaumelfv
Copy link
Contributor Author

@djyasin I just push the fix 72ff073. There was an issue when neither hostname or ingress_hosts were defined, which is the scenario the molecule tests use.

In this scenario the ingress rules would be invalid and the controller would throw:

failed: [localhost] (item=networking/ingress) => {"ansible_loop_var": "item", "changed": false, "item": "networking/ingress", "msg": "Failed to apply object: b'{\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"Ingress.extensions \\\\\"example-awx-ingress\\\\\" is invalid: spec: Invalid value: []networking.IngressRule(nil): either `defaultBackend` or `rules` must be specified\",\"reason\":\"Invalid\",\"details\":{\"name\":\"example-awx-ingress\",\"group\":\"extensions\",\"kind\":\"Ingress\",\"causes\":[{\"reason\":\"FieldValueInvalid\",\"message\":\"Invalid value: []networking.IngressRule(nil): either `defaultBackend` or `rules` must be specified\",\"field\":\"spec\"}]},\"code\":422}\\n'", "reason": "Unprocessable Entity"}

The jinja template needed to be change from:

{% if hostname and (not ingress_hosts) %}
    - host: {{ hostname }}
      http:
         paths:
          - path: '{{ ingress_path }}'
            pathType: '{{ ingress_path_type }}'
            backend:
              service:
                name: '{{ ansible_operator_meta.name }}-service'
                port:
                  number: 80
...

To:

{% if not ingress_hosts %}
    - http:
        paths:
          - path: '{{ ingress_path }}'
            pathType: '{{ ingress_path_type }}'
            backend:
              service:
                name: '{{ ansible_operator_meta.name }}-service'
                port:
                  number: 80
{% if hostname %}
      host: {{ hostname }}
{% endif %}

I did test the fix locally and the molecule tests passed. Sorry it took me so long to fix this regression, once I fixed the molecule tests to pass on my laptop the issue was easy to spot. Just for future reference I face the following running the molecule tests:

objc[18501]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

And it was fix following this thread rails/rails#38560 and adding:

export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

to my zshrc.

@djyasin could you please trigger a new CI run ?

@djyasin
Copy link
Member

djyasin commented Jan 5, 2024

@guillaumelfv thank you so much for making these additional changes! I am happy to run those checks again.

@djyasin djyasin merged commit 07427be into ansible:devel Jan 5, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Question: Multiple hostnames
6 participants