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

Add a table to keep product channel versions and APIs to update them #1465

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

gabrielBusta
Copy link
Member

@gabrielBusta gabrielBusta commented May 9, 2024

This is an API that lets us store the current versions of FIREFOX_NIGHTLY, instead of hard-coding it, so we can update this data using an API from a shipitscript task. This is part of the solution to #1462

@gabrielBusta gabrielBusta changed the title Add a table to keep the firefox-nightly version Add a table to keep the firefox-nightly version and APIs to update it May 9, 2024
@gabrielBusta gabrielBusta force-pushed the 1462 branch 4 times, most recently from 4b3649d to 933ff85 Compare May 16, 2024 21:46
@gabrielBusta gabrielBusta changed the title Add a table to keep the firefox-nightly version and APIs to update it Add a table to keep product channel versions and APIs to update them May 16, 2024
@gabrielBusta
Copy link
Member Author

gabrielBusta commented May 16, 2024

To grant shipitscript scopes to call the API to update versions we'd need a patch in ci-configuration:

diff --git a/clients.yml b/clients.yml
--- a/clients.yml
+++ b/clients.yml
@@ -862,6 +862,8 @@ project/releng/scriptworker/v2/shipit/de
     - project:releng:services/shipit_api/add_release/devedition
     - project:releng:services/shipit_api/add_release/fennec
     - project:releng:services/shipit_api/add_release/firefox
+    - project:releng:services/shipit_api/update_product_channel_version/firefox
     - project:releng:services/shipit_api/dev/add_release/devedition
     - project:releng:services/shipit_api/dev/add_release/firefox
     - project:releng:services/shipit_api/dev/schedule_phase/devedition/ship_devedition
@@ -897,6 +899,8 @@ project/releng/scriptworker/v2/shipit/pr
     - project:releng:services/shipit_api/add_release/devedition
     - project:releng:services/shipit_api/add_release/fennec
     - project:releng:services/shipit_api/add_release/firefox
+    - project:releng:services/shipit_api/update_product_channel_version/firefox
     - project:releng:services/shipit_api/dev/add_release/devedition
     - project:releng:services/shipit_api/dev/add_release/firefox
     - project:releng:services/shipit_api/dev/schedule_phase/devedition/ship_devedition
@@ -918,6 +922,8 @@ project/releng/scriptworker/v2/shipit/pr
     - project:releng:services/shipit_api/add_release/devedition
     - project:releng:services/shipit_api/add_release/fennec
     - project:releng:services/shipit_api/add_release/firefox
+    - project:releng:services/shipit_api/update_product_channel_version/firefox
     - project:releng:services/shipit_api/production/add_release/devedition
     - project:releng:services/shipit_api/production/add_release/firefox
     - project:releng:services/shipit_api/production/schedule_phase/devedition/ship_devedition

@gabrielBusta
Copy link
Member Author

This needs to be followed by a commit 7fef0f6 to use the Firefox Nightly version stored in the database when rebuilding product details. The reason this has to land first is that I need to seed the initial Firefox Nightly version in the database. Otherwise product details will fail because the new table is empty.

@@ -99,7 +99,8 @@
AUTH0_AUTH_SCOPES = assign_ldap_groups_to_scopes()

# other scopes
AUTH0_AUTH_SCOPES.update({"rebuild_product_details": LDAP_GROUPS["firefox-signoff"], "update_release_status": []})
AUTH0_AUTH_SCOPES.update({"rebuild_product_details": LDAP_GROUPS["firefox-signoff"], "update_release_status": [], "create_product_channel_version/firefox": []})
Copy link
Member Author

Choose a reason for hiding this comment

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

Another follow-up: We will need to grant releng scopes to seed the initial Thunderbird version once the Thunderbird bits are implemented.

Suggested change
AUTH0_AUTH_SCOPES.update({"rebuild_product_details": LDAP_GROUPS["firefox-signoff"], "update_release_status": [], "create_product_channel_version/firefox": []})
AUTH0_AUTH_SCOPES.update(
{
"rebuild_product_details": LDAP_GROUPS["firefox-signoff"],
"update_release_status": [],
"create_product_channel_version/firefox": [],
"create_product_channel_version/thunderbird": [],
}
)

@gabrielBusta gabrielBusta marked this pull request as ready for review June 6, 2024 17:21
@gabrielBusta
Copy link
Member Author

I ran a staging Nightly to try out this APIs in dev.

Here's a run when the Nightly version has not changed.

Here's a run with a simulated Nightly version bump.

@gabrielBusta gabrielBusta requested a review from hneiva June 6, 2024 17:26
Copy link
Contributor

@hneiva hneiva left a comment

Choose a reason for hiding this comment

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

LGTM - just a few nits/questions, but nothing blocking this from merging

def get_product_channel_version(product, channel):
version = Version.query.filter_by(product_name=product, product_channel=channel).first()
if version:
return version.current_version
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: All other functions here seem to return a tuple with (data, exitcode) should we follow the same pattern here?

required_permission = f"{SCOPE_PREFIX}/update_product_channel_version/{product}"
if not current_user.has_permissions(required_permission):
user_permissions = ", ".join(current_user.get_permissions())
abort(401, f"required permission: {required_permission}, user permissions: {user_permissions}")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: What's the difference between aborting and returning an error?
Also, seems like (data, exitcode) should be the pattern used?

required_permission = f"{SCOPE_PREFIX}/create_product_channel_version/{product}"
if not current_user.has_permissions(required_permission):
user_permissions = ", ".join(current_user.get_permissions())
abort(401, f"required permission: {required_permission}, user permissions: {user_permissions}")
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

user_permissions = ", ".join(current_user.get_permissions())
abort(401, f"required permission: {required_permission}, user permissions: {user_permissions}")
existing_version = Version.query.filter_by(product_name=product, product_channel=channel).first()
if existing_version:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could improve readability here:

if Version.query.filter_by(product_name=product, product_channel=channel).first():
    return {"error": f"A {product} {channel} version already exists."}, 409
# code here without else

@gabrielBusta
Copy link
Member Author

LGTM - just a few nits/questions, but nothing blocking this from merging

Thanks, I will address on a follow-up

@gabrielBusta gabrielBusta merged commit b6e7334 into main Jun 11, 2024
6 checks passed
@gabrielBusta gabrielBusta deleted the 1462 branch June 11, 2024 16:49
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.

2 participants