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

Clean up outdated applications (bootstrap-pull-request) #1189

Merged
merged 2 commits into from
Oct 25, 2023

Conversation

int128
Copy link
Member

@int128 int128 commented Oct 25, 2023

Problem to solve

When a service has been removed from the prebuilt branch, it will remain in the existing namespace branches. It may waste the infrastructure cost.

For example,

  1. We remove a service from the prebuilt branch.
  2. We add a commit to the existing pull request.
  3. The outdated service still exists in the namespace branch of the pull request.

How to solve

Clean up the outdated applications before copying the services.

@int128 int128 force-pushed the int128/cleanup-outdated-applications branch from 27427b2 to d174cf5 Compare October 25, 2023 01:29
@int128 int128 changed the title int128/cleanup outdated applications Clean up outdated applications (bootstrap-pull-request) Oct 25, 2023
const readContentOrNull = async (f: string): Promise<string | null> =>
await catchENOENT(async () => (await fs.readFile(f)).toString())

const catchENOENT = async <T>(f: () => Promise<T>): Promise<T | null> => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Refactoring to extract catch.


const readContent = async (filename: string) => (await fs.readFile(filename)).toString()

describe('copyServicesFromPrebuilt', () => {
const createEmptyDirectory = async () => await fs.mkdtemp(path.join(os.tmpdir(), 'bootstrap-pull-request-'))
Copy link
Member Author

Choose a reason for hiding this comment

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

Refactoring to extract the common function.

// deleteExistingApplications() deletes the existing applications, and then
// copyServicesFromPrebuilt() recreates the applications.
await deleteExistingApplications(inputs)
await copyServicesFromPrebuilt(inputs)
Copy link
Member Author

Choose a reason for hiding this comment

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

copyServicesFromPrebuilt is the original function.
In this pull request, I have added deleteExistingApplications.

@int128 int128 marked this pull request as ready for review October 25, 2023 01:40
@int128 int128 requested review from aoi1, semnil, panicboat, 44smkn and a team October 25, 2023 01:43
@int128 int128 merged commit 21bc2ed into main Oct 25, 2023
3 checks passed
@int128 int128 deleted the int128/cleanup-outdated-applications branch October 25, 2023 05:32
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.

3 participants