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

Fixes 2702,2887: Add orgID to snapshot list endpoint #435

Merged
merged 7 commits into from
Nov 13, 2023

Conversation

Andrewgdewar
Copy link
Member

@Andrewgdewar Andrewgdewar commented Oct 19, 2023

Summary

HMS-2702

  • Adds orgID as a requirement to snapshot list

HMS 2887

  • Allows the package list and snapshotList endpoint to return red hat repository (orgID of "-1") related data.

Additional changes:

  • Adds the new variable "any" to the "fetchRepoConfig" method.
  • Updated dao methods using the above function as needed, create/delete/update are now prevented from taking effect on red_hat repositories.

Testing steps

  • Easiest testing method would be to checkout the accompanied front-end PR here, and follow steps there-in.

@jlsherrill
Copy link
Member

@Andrewgdewar Andrewgdewar force-pushed the HMS-2702 branch 2 times, most recently from 1da5d1b to 07951b1 Compare October 19, 2023 20:42
@Andrewgdewar Andrewgdewar marked this pull request as ready for review October 20, 2023 16:40
pkg/dao/snapshots.go Outdated Show resolved Hide resolved
@Andrewgdewar Andrewgdewar changed the title Fixes 2702: Add orgID to snapshot list endpoint Fixes 2702,Fixes 2887: Add orgID to snapshot list endpoint Oct 25, 2023
@jlsherrill
Copy link
Member

@jlsherrill jlsherrill changed the title Fixes 2702,Fixes 2887: Add orgID to snapshot list endpoint Fixes 2702,2887: Add orgID to snapshot list endpoint Oct 31, 2023
@jlsherrill
Copy link
Member

@rverdile
Copy link
Contributor

rverdile commented Nov 3, 2023

I'm not sure why, but it looks like most of the test didn't run. Do you see that too?

@swadeley
Copy link
Member

swadeley commented Nov 6, 2023

I'm not sure why, but it looks like most of the test didn't run. Do you see that too?

Hi, test_validate_repo_parameters failed because the same repo was used in the previous filter test and not cleaned up. I have added another repo with invalid metadata to the filter test to avoid this conflict.

Not sure why test run was incomplete (I see 28 selected and I counted 26 PASSED. Then later I see = 1 failed, 26 passed, 1 skipped, 9 deselected).

@swadeley
Copy link
Member

swadeley commented Nov 6, 2023

/retest

1 similar comment
@jlsherrill
Copy link
Member

/retest

Copy link
Contributor

@rverdile rverdile left a comment

Choose a reason for hiding this comment

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

It says in your summary that create/update/delete do not have an effect for red hat repositories. Right now, if my org ID is -1, I can delete/update but not create. Obviously, that's not a real use case, but I feel the behavior should probably be consistent unless there's a reason for it not to be.

Do we expect to want to delete/update red hat repositories from the API? Or should that be blocked the way create is blocked?

@@ -587,7 +606,7 @@ func (r repositoryConfigDaoImpl) bulkDelete(tx *gorm.DB, orgID string, uuids []s
var err error
var repoConfig models.RepositoryConfiguration

if repoConfig, err = r.fetchRepoConfig(orgID, uuids[i]); err != nil {
if repoConfig, err = r.fetchRepoConfig(orgID, uuids[i], false); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

If I try to bulk delete a red hat repo, I correctly get the "not found" error. BUT it's returning a 500 response code instead of a 404

Copy link
Member Author

Choose a reason for hiding this comment

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

I was able to fix this issue, I think we largely just weren't hitting it before, and it was pre-existing.

@jlsherrill
Copy link
Member

@swadeley we've added a command to run when deploying to ephemeral that should snapshot a small rhel repo (Red Hat Ansible Engine 2 for RHEL 8 x86_64 (RPMs)) Hopefully there's enough memory for it to snapshot. Note that it doesn't 'block' deployment on the snapshot, it happens in the background.

I'll spin it up to verify as well once the image is built

@jlsherrill
Copy link
Member

I've updated the init container to first wait until pulp is up before triggering the task. I haven't been able to test this in ephemeral, as i can't seem to get the deployment.yaml changes to take effect when pointing to it with my local bonfire config. I'm not 100% sure why.

@jlsherrill
Copy link
Member

So i got it working, about half the time :/ the other half the time, there is some timing issue and the snapshot task is not scheduled. Pushing up some debugging

@swadeley
Copy link
Member

swadeley commented Nov 8, 2023

@swadeley we've added a command to run when deploying to ephemeral that should snapshot a small rhel repo (Red Hat Ansible Engine 2 for RHEL 8 x86_64 (RPMs)) Hopefully there's enough memory for it to snapshot. Note that it doesn't 'block' deployment on the snapshot, it happens in the background.

I'll spin it up to verify as well once the image is built

Hi, I have had this PR and the frontend [1] deployed for over 24 hours. I saw the Ansible repo was snapshotted right away, but still no RHEL repos due to "Killed by signal 9." as mentioned before [2].

Let me know when I should redeploy to test a new image.

Thank you

[1] content-services/content-sources-frontend#156
[2] content-services/content-sources-frontend#156 (comment)

@jlsherrill
Copy link
Member

@swadeley yes, we'll likely not ever see these large rhel repos be snapshotable in ephemeral.

@jlsherrill
Copy link
Member

@swadeley so this should be good to merge if you are okay with it. I have removed my debugging output

@swadeley
Copy link
Member

swadeley commented Nov 9, 2023

/retest

1 similar comment
@swadeley
Copy link
Member

/retest

@Andrewgdewar
Copy link
Member Author

Andrewgdewar commented Nov 10, 2023

It says in your summary that create/update/delete do not have an effect for red hat repositories. Right now, if my org ID is -1, I can delete/update but not create. Obviously, that's not a real use case, but I feel the behavior should probably be consistent unless there's a reason for it not to be.

Do we expect to want to delete/update red hat repositories from the API? Or should that be blocked the way create is blocked?

@rverdile
If you can highlight somewhere that the dao layer would allow this, please do.
I think I covered all cases of CrUD not being possible.

oh...
I think I see what you mean in your comment now.
if the ordID is -1, then you could delete/update repositories.
So to prevent that we would need to specifically check that is not the orgID
Is that necessary? auth gives us the ordID (not the user) so I couldn't really see this happening.

Copy link
Contributor

@rverdile rverdile left a comment

Choose a reason for hiding this comment

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

nice!!

@swadeley swadeley merged commit ab41987 into content-services:main Nov 13, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants