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

fix: Fixing Helm chart flower ingress service reference #41179

Merged
merged 5 commits into from
Sep 25, 2024

Conversation

andormarkus
Copy link
Contributor

closes #41175

What happened

We are sub charting the official airflow chart and for this reason we need to use fullnameOverride: "airflow" settings to achieve the desired k8s resource names. However when we are using it the flower ingress becomes invalid because it want's to connect to non existing service name. Root cause are in the ingress.yaml. The webserver ingress can handle it with no problem.

Incorrect code section

flower-ingress.yaml - code section

spec:
  rules:
    - http:
        paths:
          - backend:
              service:
                name: {{ $.Release.Name }}-flower
                port:
                  name: flower-ui

While in the correct code section

webserver-ingress.yaml - code section

spec:
  rules:
    - http:
        paths:
          - backend:
              service:
                name: {{ $fullname }}-webserver
                port:
                  name: airflow-ui

To overcome this issue we need to run this command on every deployment

kubectl patch ingress airflow-flower-ingress \
    --namespace "airflow" \
    --type='json' \
    -p='[{"op": "replace", "path": "/spec/rules/0/http/paths/0/backend/service/name", "value":"airflow-flower"}]'

What you think should happen instead

The following code should be updated to match how webserver ingress works
flower-ingress.yaml - code section

spec:
  rules:
    - http:
        paths:
          - backend:
              service:
                name: {{ $fullname }}-flower
                port:
                  name: flower-ui

@andormarkus
Copy link
Contributor Author

Can someone help my why this test failing?
https://github.com/apache/airflow/actions/runs/10195595534/job/28204650305?pr=41179

@eladkal eladkal requested a review from romsharon98 August 2, 2024 08:08
@romsharon98 romsharon98 force-pushed the fix/helm-flower-ingress branch from fc6bfe7 to 8efbcef Compare August 2, 2024 08:22
romsharon98
romsharon98 previously approved these changes Aug 2, 2024
@romsharon98
Copy link
Contributor

Can someone help my why this test failing? https://github.com/apache/airflow/actions/runs/10195595534/job/28204650305?pr=41179

rebase solved it 😄

Copy link
Contributor

@romsharon98 romsharon98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add tests for your change?

@romsharon98 romsharon98 self-requested a review August 2, 2024 09:06
@romsharon98 romsharon98 dismissed their stale review August 2, 2024 09:07

need to add tests

@andormarkus
Copy link
Contributor Author

Hi @romsharon98

I'm happy to add helm test for the modified ingress object, however the helm test framework is fully missing from the helm chart and we need to add the automated test runs to the CI/CD pipelines as well.

Helm testing documentation,

@romsharon98
Copy link
Contributor

romsharon98 commented Aug 2, 2024

You can add your tests here
You can see more in helm unit tests docs

@andormarkus
Copy link
Contributor Author

Hi @romsharon98

Sorry for the late reply I was on extended vacation.

I have run into to a problem when I added the "fullnameOverride": "test-basic" it looks like the chart/templates/_helpers.yaml is not executed when I run the tests.

Here are my tests
helm_tests/webserver/test_ingress_web.py

    def test_backend_service_name(self):
        docs = render_chart(
            values={"ingress": {"web": {"enabled": True}}},
            show_only=["templates/webserver/webserver-ingress.yaml"],
        )

        assert "release-name-webserver" == jmespath.search("spec.rules[0].http.paths[0].backend.service.name", docs[0])

    def test_backend_service_name_with_fullname_override(self):
        docs = render_chart(
            values={"fullnameOverride": "test-basic",
                    "ingress": {"web": {"enabled": True}}},
            show_only=["templates/webserver/webserver-ingress.yaml"],

        )

        assert "test-basic-webserver" == jmespath.search("spec.rules[0].http.paths[0].backend.service.name", docs[0])

helm_tests/webserver/test_ingress_flower.py

    def test_backend_service_name(self):
        docs = render_chart(
            values={"ingress": {"enabled": True}, "flower": {"enabled": True}},
            show_only=["templates/flower/flower-ingress.yaml"],
        )

        assert "release-name-flower" == jmespath.search("spec.rules[0].http.paths[0].backend.service.name", docs[0])

    def test_backend_service_name_with_fullname_override(self):
        docs = render_chart(
            values={"fullnameOverride": "test-basic",
                    "ingress": {"enabled": True}, "flower": {"enabled": True}},
            show_only=["templates/flower/flower-ingress.yaml"],

        )

        assert "test-basic-flower" == jmespath.search("spec.rules[0].http.paths[0].backend.service.name", docs[0])

I run the test using the following command

 breeze testing helm-tests --helm-test-package webserver  
FAILED helm_tests/webserver/test_ingress_flower.py::TestIngressFlower::test_backend_service_name_with_fullname_override - AssertionError: assert equals failed
  'test-basic-flower'    'release-name-flower'
FAILED helm_tests/webserver/test_ingress_web.py::TestIngressWeb::test_backend_service_name_with_fullname_override - AssertionError: assert equals failed
  'test-basic-webserver'    'release-name-webserver'

@romsharon98
Copy link
Contributor

Hi @romsharon98

Sorry for the late reply I was on extended vacation.

I have run into to a problem when I added the "fullnameOverride": "test-basic" it looks like the chart/templates/_helpers.yaml is not executed when I run the tests.

Here are my tests helm_tests/webserver/test_ingress_web.py

    def test_backend_service_name(self):
        docs = render_chart(
            values={"ingress": {"web": {"enabled": True}}},
            show_only=["templates/webserver/webserver-ingress.yaml"],
        )

        assert "release-name-webserver" == jmespath.search("spec.rules[0].http.paths[0].backend.service.name", docs[0])

    def test_backend_service_name_with_fullname_override(self):
        docs = render_chart(
            values={"fullnameOverride": "test-basic",
                    "ingress": {"web": {"enabled": True}}},
            show_only=["templates/webserver/webserver-ingress.yaml"],

        )

        assert "test-basic-webserver" == jmespath.search("spec.rules[0].http.paths[0].backend.service.name", docs[0])

helm_tests/webserver/test_ingress_flower.py

    def test_backend_service_name(self):
        docs = render_chart(
            values={"ingress": {"enabled": True}, "flower": {"enabled": True}},
            show_only=["templates/flower/flower-ingress.yaml"],
        )

        assert "release-name-flower" == jmespath.search("spec.rules[0].http.paths[0].backend.service.name", docs[0])

    def test_backend_service_name_with_fullname_override(self):
        docs = render_chart(
            values={"fullnameOverride": "test-basic",
                    "ingress": {"enabled": True}, "flower": {"enabled": True}},
            show_only=["templates/flower/flower-ingress.yaml"],

        )

        assert "test-basic-flower" == jmespath.search("spec.rules[0].http.paths[0].backend.service.name", docs[0])

I run the test using the following command

 breeze testing helm-tests --helm-test-package webserver  
FAILED helm_tests/webserver/test_ingress_flower.py::TestIngressFlower::test_backend_service_name_with_fullname_override - AssertionError: assert equals failed
  'test-basic-flower'    'release-name-flower'
FAILED helm_tests/webserver/test_ingress_web.py::TestIngressWeb::test_backend_service_name_with_fullname_override - AssertionError: assert equals failed
  'test-basic-webserver'    'release-name-webserver'

for this to be applied you need to set useStandardNaming to be true

@andormarkus
Copy link
Contributor Author

Hi @romsharon98

Thank you so much the help. Now my tests are passing.
Please let me know If I need to more test of where to adjust the code?

Thanks,
Andor

@romsharon98
Copy link
Contributor

Hi @romsharon98

Thank you so much the help. Now my tests are passing.

Please let me know If I need to more test of where to adjust the code?

Thanks,

Andor

You have static checks fail.
Better work with pre commit to see those errors before you commit.

You can see how to install it here

https://github.com/apache/airflow/blob/main/contributing-docs/08_static_code_checks.rst#installing-pre-commit-hooks

@andormarkus
Copy link
Contributor Author

Hi @romsharon98
All checks are now passing.

Thanks,
Andor

@romsharon98 romsharon98 force-pushed the fix/helm-flower-ingress branch from 03c4318 to d0279ce Compare September 25, 2024 09:45
@romsharon98 romsharon98 merged commit 42fa716 into apache:main Sep 25, 2024
67 checks passed
@andormarkus
Copy link
Contributor Author

Hi @romsharon98

When is the helm chart 1.16.0 scheduled for release?

Thanks,
Andor

@romsharon98
Copy link
Contributor

Hi @romsharon98

When is the helm chart 1.16.0 scheduled for release?

Thanks,

Andor

I think @jedcunningham will know better

@eladkal eladkal added this to the Airflow Helm Chart 1.16.0 milestone Sep 25, 2024
joaopamaral pushed a commit to joaopamaral/airflow that referenced this pull request Oct 21, 2024
* fix: Fixing Helm chart flower ingress service reference

* fix: Fixing Helm chart flower ingress service reference

* feat: Add helm unit test for the ingress backend service name

* feat: Add helm unit test for the ingress backend service name

* fix: Run linter for new files

---------

Co-authored-by: Andor Markus (AllCloud) <andor.rudolf-markus@glassbox.com>
ellisms pushed a commit to ellisms/airflow that referenced this pull request Nov 13, 2024
* fix: Fixing Helm chart flower ingress service reference

* fix: Fixing Helm chart flower ingress service reference

* feat: Add helm unit test for the ingress backend service name

* feat: Add helm unit test for the ingress backend service name

* fix: Run linter for new files

---------

Co-authored-by: Andor Markus (AllCloud) <andor.rudolf-markus@glassbox.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:helm-chart Airflow Helm Chart
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[helm] - Flower ingress incorrect when fullnameOverride applied
3 participants