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

Ignore nil objects occured when rendering a file #560

Conversation

vasrem
Copy link
Contributor

@vasrem vasrem commented Dec 15, 2023

This commits addresses an edge case where a nil object can occur while rendering a file. In that situation, in one of the places the renderer is used, it will try to add ownership to a nil object and fail.

Testing

Before:

$ go test ./pkg/render/ -run TestTemplateWithEmptyObject
--- FAIL: TestTemplateWithEmptyObject (0.00s)
    render_test.go:101:
        Expected
            <int>: 3
        to equal
            <int>: 2
FAIL
FAIL    github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/render       0.019s
FAIL

Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

This commits addresses an edge case where a nil object can occur
while rendering a file. In that situation, in one of the places the
renderer is used, it will try to add ownership to a nil object and
fail.

Signed-off-by: Vasilis Remmas <[email protected]>
@vasrem vasrem force-pushed the bugfix/ignore_null_objects_when_rendering branch from 4b45b6c to 1822145 Compare December 15, 2023 07:27
Copy link

Thanks for your PR,
To run vendors CIs use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 7219210136

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 25.706%

Totals Coverage Status
Change from base Build 7020180866: 0.02%
Covered Lines: 2359
Relevant Lines: 9177

💛 - Coveralls

Copy link
Member

@zeeke zeeke left a comment

Choose a reason for hiding this comment

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

nit: The problem this PR fixes occurs even without the dash (-):
i.e.:

{{ if .Enable }}
---
...

as the problem is related to the \n before ---, which ends up in a nil unstructured object.

BTW, the fix would remain the same. thanks for tackling this.
LGTM

Copy link
Collaborator

@adrianchiris adrianchiris left a comment

Choose a reason for hiding this comment

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

LGTM!

@adrianchiris adrianchiris merged commit c0a2f9c into k8snetworkplumbingwg:master Dec 17, 2023
11 checks passed
@vasrem vasrem deleted the bugfix/ignore_null_objects_when_rendering branch December 18, 2023 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants