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-15356: Ensure filenames are distinct between openshift and manifest directories. #5382
MGMT-15356: Ensure filenames are distinct between openshift and manifest directories. #5382
Conversation
@paul-maidment: This pull request references MGMT-15356 which is a valid jira issue. In response to this:
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. |
Skipping CI for Draft Pull Request. |
@paul-maidment: This pull request references MGMT-15356 which is a valid jira issue. In response to this:
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. |
internal/manifests/manifests.go
Outdated
@@ -229,6 +234,15 @@ func (m *Manifests) UpdateClusterManifestInternal(ctx context.Context, params op | |||
return nil, err | |||
} | |||
|
|||
if srcFolder != destFolder && srcFileName != destFileName { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to check this if the filename changes, even if the folder name doesn't.
State before: manifests/foo openshift/bar
Rename openshift/bar to openshift/foo
I renamed the file in the same directory, but it's no longer distinct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree there is a problem here, discussing in comment below as this supercedes this point somewhat
if srcFolder != destFolder && srcFileName != destFileName { | ||
// We will be performing a delete of the srcFolder/srcFilename, which will result in the files being distinct across folders. | ||
// so only perform this check if both the folder and filename are changing. | ||
err = m.validateFileDistinct(ctx, params.ClusterID, destFolder, destFileName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this break the ability to rename directories?
Let's say I want to rename openshift/foo to manifests/foo. We call m.validateFileDistinct(ctx, clusterID, "manifests", "foo"). This checks the existence of the openshift/foo object, which of course exists, so the call fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, this needs more thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
srcfolder | srcfilename | destfolder | destfilename | distinctness check needed? |
---|---|---|---|---|
openshift | foo | manifests | foo | No - openshift/foo will be deleted |
openshift | foo | openshift | bar | Yes, need to check for manifests/bar |
openshift | foo | manifests | bar | Yes, need to check for openshift/bar |
manifests | foo | manifests | bar | Yes, need to check for openshift/bar |
manifests | foo | manifests | foo | No - paths will not change |
So seems that the only time we need the check is when srcFilename != destFilename
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which agrees with your comment above We need to check this if the filename changes, even if the folder name doesn't.
98367bb
to
b0bc248
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #5382 +/- ##
==========================================
+ Coverage 67.67% 67.70% +0.02%
==========================================
Files 226 227 +1
Lines 33361 33492 +131
==========================================
+ Hits 22578 22676 +98
- Misses 8747 8777 +30
- Partials 2036 2039 +3
|
internal/manifests/manifests.go
Outdated
@@ -229,6 +234,15 @@ func (m *Manifests) UpdateClusterManifestInternal(ctx context.Context, params op | |||
return nil, err | |||
} | |||
|
|||
if srcFileName != destFileName { | |||
// We will be performing a delete of the srcFolder/srcFilename, which will result in the files being distinct across folders. | |||
// so only perform this check if both the folder and filename are changing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is no longer accurate
directories. In MGMT-15336 it was reported that it is possible to upload a file with the same name to the openshift and manifests directories when creating or updating a manifest. Because of the way in which manifest files are later merged into a single directory, this leads to a scenario where the user may not be aware that a manifest uploaded to "openshift" has overwritten a manifest that was uploaded to "manifests". To prevent any confusion, we should ensure that filenames are distinct between the two directories when attempting to create or upload a manifest. This PR implements this functionality.
b0bc248
to
5d8c8c6
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: avishayt, 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:
Approvers can indicate their approval by writing |
/retest |
1 similar comment
/retest |
@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. |
…est (openshift#5382) directories. In MGMT-15336 it was reported that it is possible to upload a file with the same name to the openshift and manifests directories when creating or updating a manifest. Because of the way in which manifest files are later merged into a single directory, this leads to a scenario where the user may not be aware that a manifest uploaded to "openshift" has overwritten a manifest that was uploaded to "manifests". To prevent any confusion, we should ensure that filenames are distinct between the two directories when attempting to create or upload a manifest. This PR implements this functionality.
…est (openshift#5382) directories. In MGMT-15336 it was reported that it is possible to upload a file with the same name to the openshift and manifests directories when creating or updating a manifest. Because of the way in which manifest files are later merged into a single directory, this leads to a scenario where the user may not be aware that a manifest uploaded to "openshift" has overwritten a manifest that was uploaded to "manifests". To prevent any confusion, we should ensure that filenames are distinct between the two directories when attempting to create or upload a manifest. This PR implements this functionality.
In MGMT-15336 it was reported that it is possible to upload a file with the same name to the openshift and manifests directories when creating or updating a manifest.
Because of the way in which manifest files are later merged into a single directory, this leads to a scenario where the user may not be aware that a manifest uploaded to "openshift" has overwritten a manifest that was uploaded to "manifests".
To prevent any confusion, we should ensure that filenames are distinct between the two directories when attempting to create or upload a manifest.
This PR implements this functionality.
List all the issues related to this PR
What environments does this code impact?
How was this code tested?
Checklist
docs
, README, etc)Reviewers Checklist