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 controller ClusterRole file generation #363

Merged
merged 1 commit into from
Sep 9, 2022

Conversation

a-hilaly
Copy link
Member

@a-hilaly a-hilaly commented Sep 9, 2022

This patch fixes the tail command to properly cut the generated
role.yaml file and avoid deleteng the rules section.

Context:

Recently we bumped controller-tools version to v0.9.2 to support
building controller with go1.19. This change sneakily impacted the
build-controller-release.sh script, which caused our prow testing jobs
to fail.

To summarize the bug we can generate the role.yaml file using
controller-gen 0.7.0 and 0.9.2 and inspect the differences:

diff role-controller-gen0.9.2.yaml role-controller-gen0.7.0.yaml
0a1
>

We can observe that the new line that used it be generated at the top of
each file is no longer there, due to the fix introduced in 0.8.0 more
precisely in kubernetes-sigs/controller-tools#626

This change combined with the command tail -n +8 in the build
controller release script
causes the script to cut an extra line which
happens to be declaration of rules section in a controller ClusterRole
manifest. Hence the error observed in the prow logs:

Error: INSTALLATION FAILED: YAML parse error on emrcontainers-chart/templates/cluster-role-controller.yaml: error converting YAML to JSON: yaml: line 8: did not find expected key

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

Recently we bumped `controller-tools` version to `v0.9.2` to support
building controller with go1.19. This change sneakily impacted the
`build-controller-release.sh` script, which caused our prow testing jobs
to fail.

To summarize the bug we can generate the `role.yaml` file using
controller-gen `0.7.0` and `0.9.2` and inspect the differences:

```bash
diff role-controller-gen0.9.2.yaml role-controller-gen0.7.0.yaml
0a1
>
```

We can observe that the new line that used it be generated at the top of
each file is no longer there, due to the fix introduced in 0.8.0 more
precisely in kubernetes-sigs/controller-tools#626

This change combined with the command `tail -n +8` in
https://github.com/aws-controllers-k8s/code-generator/blob/v0.20.0/scripts/build-controller-release.sh#L237
causes the script to cut an extra line which happens to be declaration
of rules section in a controller ClusterRole manifest. Hence the error
observed in the prow logs:

```bash
Error: INSTALLATION FAILED: YAML parse error on emrcontainers-chart/templates/cluster-role-controller.yaml: error converting YAML to JSON: yaml: line 8: did not find expected key
```

This patch fixes the `tail` command to properly cut the generated
`role.yaml` file and avoid deleteng the `rules` section.
@ack-bot
Copy link
Collaborator

ack-bot commented Sep 9, 2022

@a-hilaly: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
dynamodb-controller-test c3dcc6c link /test dynamodb-controller-test

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@RedbackThomson
Copy link
Contributor

Wow what a great catch. Well done!

/lgtm

@ack-bot ack-bot added the lgtm Indicates that a PR is ready to be merged. label Sep 9, 2022
@ack-bot
Copy link
Collaborator

ack-bot commented Sep 9, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: A-Hilaly, RedbackThomson

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [A-Hilaly,RedbackThomson]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-bot ack-bot merged commit 210ca46 into aws-controllers-k8s:main Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants