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

MGMT-14634: Ensure that empty manifest may not be added. #5348

Merged
merged 1 commit into from Jul 10, 2023

Conversation

paul-maidment
Copy link
Contributor

Presently, if a manifest has no content then it passes validation. This breaks bootkube when empty content is submitted.

This PR validates that manifest content is not empty before accepting it.

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
    Submitted an empty file to the API endpoint and observed that validation now fails.
  • [] No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

Presently, if a manifest has no content then it passes validation.
This breaks bootkube when empty content is submitted.

This PR validates that manifest content is not empty before accepting
it.
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 10, 2023
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jul 10, 2023

@paul-maidment: This pull request references MGMT-14634 which is a valid jira issue.

In response to this:

Presently, if a manifest has no content then it passes validation. This breaks bootkube when empty content is submitted.

This PR validates that manifest content is not empty before accepting it.

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
    Submitted an empty file to the API endpoint and observed that validation now fails.
  • [] No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

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.

@openshift-ci openshift-ci bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 10, 2023
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 10, 2023
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 10, 2023
@openshift-ci
Copy link

openshift-ci bot commented Jul 10, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: carbonin, paul-maidment

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 [carbonin,paul-maidment]

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

@codecov
Copy link

codecov bot commented Jul 10, 2023

Codecov Report

Merging #5348 (f084d55) into master (820a271) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5348      +/-   ##
==========================================
- Coverage   67.54%   67.53%   -0.01%     
==========================================
  Files         226      226              
  Lines       33278    33280       +2     
==========================================
- Hits        22476    22475       -1     
- Misses       8775     8778       +3     
  Partials     2027     2027              
Impacted Files Coverage Δ
internal/manifests/manifests.go 72.06% <100.00%> (+0.19%) ⬆️

... and 3 files with indirect coverage changes

@@ -412,6 +412,11 @@ func (m *Manifests) validateAllowedToModifyManifests(ctx context.Context, cluste
}

func (m *Manifests) validateUserSuppliedManifest(ctx context.Context, clusterID strfmt.UUID, manifestContent []byte, fileName string) error {
// If the manifest content size is zero then some of the content validations might pass when they should not
// We need to reject zero size content
if len(manifestContent) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we go one step further and validate that there's (exactly? at-least?) a single parsable YAML document within the manifest file?

@openshift-ci
Copy link

openshift-ci bot commented Jul 10, 2023

@paul-maidment: all tests passed!

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.

@openshift-merge-robot openshift-merge-robot merged commit 10a88f5 into openshift:master Jul 10, 2023
14 checks passed
paul-maidment added a commit to paul-maidment/assisted-service that referenced this pull request Jul 12, 2023
…dded. (openshift#5348)"

This reverts commit 10a88f5.

It was found that this validation is causing issues for the UI.
We have some mitigations planned for the issues, however this commit
needs to be rolled back for now to prevent ongoing breakage while the
issues are addressed.
openshift-merge-robot pushed a commit that referenced this pull request Jul 12, 2023
…dded. (#5348)" (#5353)

This reverts commit 10a88f5.

It was found that this validation is causing issues for the UI.
We have some mitigations planned for the issues, however this commit
needs to be rolled back for now to prevent ongoing breakage while the
issues are addressed.
CrystalChun pushed a commit to CrystalChun/assisted-service that referenced this pull request Jul 12, 2023
…dded. (openshift#5348)" (openshift#5353)

This reverts commit 10a88f5.

It was found that this validation is causing issues for the UI.
We have some mitigations planned for the issues, however this commit
needs to be rolled back for now to prevent ongoing breakage while the
issues are addressed.
CrystalChun pushed a commit to CrystalChun/assisted-service that referenced this pull request Aug 25, 2023
)

Presently, if a manifest has no content then it passes validation.
This breaks bootkube when empty content is submitted.

This PR validates that manifest content is not empty before accepting
it.
CrystalChun pushed a commit to CrystalChun/assisted-service that referenced this pull request Aug 25, 2023
…dded. (openshift#5348)" (openshift#5353)

This reverts commit 10a88f5.

It was found that this validation is causing issues for the UI.
We have some mitigations planned for the issues, however this commit
needs to be rolled back for now to prevent ongoing breakage while the
issues are addressed.
danielerez pushed a commit to danielerez/assisted-service that referenced this pull request Oct 15, 2023
)

Presently, if a manifest has no content then it passes validation.
This breaks bootkube when empty content is submitted.

This PR validates that manifest content is not empty before accepting
it.
danielerez pushed a commit to danielerez/assisted-service that referenced this pull request Oct 15, 2023
…dded. (openshift#5348)" (openshift#5353)

This reverts commit 10a88f5.

It was found that this validation is causing issues for the UI.
We have some mitigations planned for the issues, however this commit
needs to be rolled back for now to prevent ongoing breakage while the
issues are addressed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants