8000 Fix: Deployment status by Meldiron · Pull Request #9580 · appwrite/appwrite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix: Deployment status #9580

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

Merged
merged 10 commits into from
Mar 27, 2025
Merged

Fix: Deployment status #9580

merged 10 commits into from
Mar 27, 2025

Conversation

Meldiron
Copy link
Contributor
@Meldiron Meldiron commented Mar 26, 2025

What does this PR do?

  • Marks status ready only once screenshot is done
  • Update logs to indicate screenshot is being made
  • Concurrency for screenshots (dark & light)

Test Plan

Cant find any easy way to add tests for this. Manual QA and existing tests is good enough IMO

Related PRs and Issues

x

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

Summary by CodeRabbit

  • New Features

    • Enabled flexible deployment status handling using API keys.
    • Adopted parallel processing for capturing screenshots, improving build efficiency.
    • Enhanced typography with new font imports and fallback options across various components.
  • Bug Fixes

    • Improved validation of deployment completion details in testing.
  • Refactor

    • Adjusted screenshot timing for Vue applications to enhance build reliability.
    • Enhanced error reporting during deployments for clearer build failure insights.

Copy link
coderabbitai bot commented Mar 26, 2025

Walkthrough

This pull request updates several components of the deployment process. The configuration file now waits longer before taking a screenshot. The router function in the controller has been enhanced with conditions to bypass the deployment status check when an API key indicates it can be ignored. Additionally, the Key class now stores a flag for deployment status and provides a method to access it. Finally, the build deployment process has been refactored to handle screenshot requests concurrently and update status after all operations complete.

Changes

File(s) Change Summary
app/config/frameworks.php Updated the screenshotSleep value for Vue from 3000ms to 5000ms.
app/controllers/general.php Enhanced deployment status logic by modifying status check to allow bypass if an API key indicates it can be ignored.
src/Appwrite/Auth/Key.php Added deploymentStatusIgnored property and isDeploymentStatusIgnored() method to the Key class.
src/Appwrite/Platform/Modules/Functions/Workers/Builds.php Refactored screenshot handling using Swoole Coroutine batch calls, adjusted status update timing, and improved error handling.
app/views/general/404.phtml,
src/Appwrite/Transformation/Adapter/Preview.php
Added font import and updated font-family properties for various elements to include fallback options.
tests/e2e/Services/Realtime/RealtimeConsoleClientTest.php Simplified deployment status assertions and enhanced validation for deployment completion details.

Possibly related PRs

  • Add fallbackfile and adapter to deployments collection #9570: The changes in the main PR are related to those in the retrieved PR as both involve modifications to the deployment process, specifically regarding the handling of deployment attributes, including the introduction of new attributes in the deployment logic.

Suggested reviewers

  • vermakhushboo

Poem

I'm a rabbit quick on my feet,
Hopping through code so neat.
Screenshots now take a longer nap,
While deployments avoid a trap.
With lines refined and changes grand,
I'm snuggling carrots and giving a happy band!
🥕🐇


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1946fca and 8348728.

📒 Files selected for processing (1)
  • src/Appwrite/Platform/Modules/Functions/Workers/Builds.php (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: E2E Service Test (Account)
  • GitHub Check: E2E Service Test (Users)
  • GitHub Check: E2E Service Test (VCS)
  • GitHub Check: E2E Service Test (Locale)
  • GitHub Check: E2E Service Test (Messaging)
  • GitHub Check: E2E Service Test (Functions)
  • GitHub Check: E2E Service Test (Storage)
  • GitHub Check: E2E Service Test (Proxy)
  • GitHub Check: E2E Service Test (Teams)
  • GitHub Check: E2E Service Test (Databases)
  • GitHub Check: E2E Service Test (Projects)
  • GitHub Check: E2E Service Test (Console)
  • GitHub Check: E2E Service Test (Sites)
  • GitHub Check: E2E Service Test (Realtime)
  • GitHub Check: E2E Service Test (FunctionsSchedule)
  • GitHub Check: E2E Service Test (Health)
  • GitHub Check: E2E Service Test (Avatars)
  • GitHub Check: Benchmark
  • GitHub Check: E2E General Test
  • GitHub Check: Unit Test
🔇 Additional comments (7)
src/Appwrite/Platform/Modules/Functions/Workers/Builds.php (7)

44-44: Good addition of Swoole Coroutine batch functionality.

The import of Swoole\Coroutine\batch is essential for implementing the concurrent screenshot processing.


796-797: Clear user feedback message added.

Adding a log message to indicate that screenshots are being captured provides better visibility of the deployment process status to users.


843-844: Key enhancement for seamless screenshot processing.

Adding the deploymentStatusIgnored flag to the JWT allows the screenshot service to process the deployment even though it's not yet marked as ready, which is crucial to prevent circular dependencies.


846-919: Excellent implementation of concurrent screenshot processing.

Using Swoole's batch functionality to process screenshots concurrently is a significant improvement over sequential processing. This approach reduces the overall deployment time by capturing screenshots in parallel for both dark and light modes.

The error handling is well-implemented, capturing and propagating any screenshot errors that might occur during the process.


920-926: Good error handling for screenshot process.

The code properly checks for screenshot errors before proceeding and throws an exception if any screenshot failed. It then updates the deployment with the screenshot file IDs for successful captures.


940-958: Critical fix: Deployment status now correctly set after all processes complete.

This is the core improvement of the PR. The deployment status is now marked as "ready" only after all operations are completed, including the screenshot capture. This ensures that the deployment is truly ready for use when its status indicates so.


1097-1102: Enhanced error logging improves debugging experience.

The expanded console warnings with file, line, and stack trace information will be helpful for diagnosing deployment failures.

✨ Finishing Touches
  • 📝 Docstrings were successfully generated. (🔄 Check again to generate docstrings again)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
github-actions bot commented Mar 26, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
binutils 2.42-r0 CVE-2025-0840 HIGH
libexpat 2.6.4-r0 CVE-2024-8176 HIGH
libxml2 2.12.7-r0 CVE-2024-56171 HIGH
libxml2 2.12.7-r0 CVE-2025-24928 HIGH
libxml2 2.12.7-r0 CVE-2025-27113 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

Copy link
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/Appwrite/Platform/Modules/Functions/Workers/Builds.php (3)

796-800: Consider removing or clarifying ANSI escape code.
Appending the raw ANSI reset code (\x1b[0m) could print unintelligible characters in logs that do not support color escape sequences. Consider either removing it or ensuring log viewers can interpret ANSI codes.


854-924: Leverage concurrency with partial-failure handling.
Using batch() for screenshot generation is a good optimization. However, consider handling partial failures more gracefully (for example, capturing any successful screenshots even if one screenshot request fails), as throwing an exception will stop processing of subsequent tasks.


938-950: Provide fallback when screenshots fail.
This change correctly delays the "ready" status until after screenshot generation, but in the catch block above, a failure to generate screenshots simply logs a warning without preventing the deployment from becoming "ready." If a failed screenshot is a concern, consider adding an option to mark the status as partially successful or to retry before finalizing.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0235978 and 2c55f5a.

📒 Files selected for processing (4)
  • app/config/frameworks.php (1 hunks)
  • app/controllers/general.php (1 hunks)
  • src/Appwrite/Auth/Key.php (4 hunks)
  • src/Appwrite/Platform/Modules/Functions/Workers/Builds.php (6 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
app/controllers/general.php (1)
src/Appwrite/Auth/Key.php (1)
  • isDeploymentStatusIgnored (83-86)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: scan
🔇 Additional comments (10)
app/config/frameworks.php (1)

141-141: Increased screenshot sleep time for Vue.js framework

The sleep time before taking a screenshot for Vue.js applications has been increased from 3000ms to 5000ms. This change allows for more time for the Vue application to fully render before capturing the screenshot, which should improve the reliability of the screenshot process.

src/Appwrite/Auth/Key.php (4)

27-27: Added new deploymentStatusIgnored property to Key class

This property has been added to the constructor parameters with a default value of false. It will allow certain API keys to bypass deployment status checks when accessing resources.


83-86: Added new isDeploymentStatusIgnored method

This accessor method returns the value of the deploymentStatusIgnored property, allowing other parts of the application to check if an API key should ignore deployment status.


148-148: Added deploymentStatusIgnored to payload extraction

This extracts the deploymentStatusIgnored flag from the JWT payload with a fallback to false if not present, maintaining backward compatibility with existing keys.


166-167: Updated Key constructor call to include deploymentStatusIgnored

This passes the extracted deploymentStatusIgnored value to the Key constructor, ensuring the property is properly initialized from the JWT payload.

app/controllers/general.php (1)

272-273: Enhanced deployment status check to support status bypass

This change allows API requests with keys that have deploymentStatusIgnored=true to bypass the deployment status check. The addition of the $allowAnyStatus variable provides a clear and readable condition for when to skip the status check.

This enhancement supports the PR objective to improve deployment status functionality by allowing certain API keys to access deployments regardless of their status, which is useful for taking screenshots in both dark and light modes concurrently.

src/Appwrite/Platform/Modules/Functions/Workers/Builds.php (4)

812-812: Docblock addition is fine.
Adding a short docblock comment here for clarity is helpful.


850-850: Re-check the security implications of ignoring deployment status.
Setting 'deploymentStatusIgnored' => true can allow calls to bypass standard deployment-status checks. Verify that this does not introduce security holes or unintended behavior downstream.


1090-1095: Validate exposure of sensitive data in failure logs.
Logging the exception message, file path, and trace is valuable for debugging but can leak details in shared logs. Confirm that these logs are not exposed to unauthorized users or in end-user-facing environments.


44-45:

❓ Verification inconclusive

Confirm Swoole extension availability.
The usage of Swoole\Coroutine\batch introduces concurrency benefits. Please verify that the production and staging environments have the Swoole extension installed and correctly configured.


🏁 Script executed:

#!/bin/bash
# Description: Check if the Swoole extension is loaded.

php -m | grep -i swoole

Length of output: 25


Action Required: Manually Verify Swoole Extension Installation

The use of Swoole\Coroutine\batch relies on having the Swoole extension available. The initial automated check (using php -m | grep -i swoole) produced no output, which is inconclusive. Please verify manually that the Swoole extension is installed and correctly configured in both production and staging environments. For example, you might run:

  • php --ri swoole
  • php -r "echo extension_loaded('swoole') ? 'Swoole is loaded' : 'Swoole is not loaded';"

Manually confirming this will ensure that the concurrency features provided by Swoole function as expected.

8000

Copy link
github-actions bot commented Mar 26, 2025

✨ Benchmark results

  • Requests per second: 953
  • Requests with 200 status code: 171,651
  • P99 latency: 0.193454478

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 953 1,310
200 171,651 235,845
P99 0.193454478 0.140513872

@Meldiron Meldiron merged commit 3d1ea6d into feat-sites Mar 27, 2025
31 checks passed
coderabbitai bot added a commit that referenced this pull request Mar 28, 2025
Docstrings generation was requested by @Meldiron.

* #9580 (comment)

The following files were modified:

* `app/controllers/general.php`
* `src/Appwrite/Auth/Key.php`
* `src/Appwrite/Platform/Modules/Functions/Workers/Builds.php`
* `src/Appwrite/Transformation/Adapter/Preview.php`
Copy link
coderabbitai bot commented Mar 28, 2025

Note

Generated docstrings for this pull request at #9589

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
0