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

feat(backend): add service factories by default #1881

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gashcrumb
Copy link
Member

@gashcrumb gashcrumb commented Nov 5, 2024

Description

This change explicitely adds the default service factories to the backend statically to prevent dynamic plugins from being able to override them by default. It's possible to override each statically added service factory via an environment variable derived from the service factory ID. So for example to add a "core.rootHttpService" service factory configuration from a dynamic plugin, set ENABLE_CORE_ROOTHTTPSERVICE_OVERRIDE to "true". This change also adds a logger to the backend main. Finally, a unit test has been added that checks the installed backend-defaults value for the defaultServiceFactories list against what this change adds to catch future regressions.

Which issue(s) does this PR fix

PR acceptance criteria

Please make sure that the following steps are complete:

  • GitHub Actions are completed and successful
  • Unit Tests are updated and passing
  • E2E Tests are updated and passing
  • Documentation is updated if necessary (requirement for new features)
  • Add a screenshot if the change is UX/UI related

How to test changes / Special notes to the reviewer

It's enough to just check that this doesn't break anything, however an example exists here that has a plugin that can be used to try this out. I'll add some documentation to the dynamic plugins docs in a later PR, we've a plan to refactor those a bit.

Copy link
Contributor

github-actions bot commented Nov 5, 2024

The image is available at: quay.io/janus-idp/backstage-showcase:pr-1881!

Copy link
Contributor

github-actions bot commented Nov 6, 2024

Copy link
Contributor

github-actions bot commented Nov 6, 2024

@PatAKnight
Copy link
Member

/test e2e-tests

Copy link
Member

@davidfestal davidfestal left a comment

Choose a reason for hiding this comment

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

Shouldn't we do something more general than that, for all the default services added in the createdBackend()method ?
With environment variables like:
ENABLE_OVERRIDING_SERVICE_ (serviceFactoryName being the service factory name mentioned in the list of default services: https://github.com/backstage/backstage/blob/master/packages/backend-defaults/src/CreateBackend.ts#L37)

packages/backend/src/index.ts Outdated Show resolved Hide resolved
@gashcrumb
Copy link
Member Author

Shouldn't we do something more general than that, for all the default services added in the createdBackend()method ? With environment variables like: ENABLE_OVERRIDING_SERVICE_ (serviceFactoryName being the service factory name mentioned in the list of default services: backstage/backstage@master/packages/backend-defaults/src/CreateBackend.ts#L37)

I can look at doing that, certainly. I didn't see the same customization options offered for some of the other services when I was looking through them in preparation for this, so I opted to keep the scope for this much more narrow. But I'll take another look. Thanks!

Copy link

openshift-ci bot commented Nov 7, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from davidfestal. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gashcrumb gashcrumb changed the title feat(backend): add default root http router config feat(backend): add service factories by default Nov 7, 2024
@davidfestal
Copy link
Member

I like the last commit: 4a76ffa

Would it be possible to add a unit test that would simply extract the upstream source file based on the backstage.json of the showcase, and check that the service factories are the same ?

Copy link
Contributor

github-actions bot commented Nov 7, 2024

@gashcrumb
Copy link
Member Author

I like the last commit: 4a76ffa

Cool!

Would it be possible to add a unit test that would simply extract the upstream source file based on the backstage.json of the showcase, and check that the service factories are the same ?

yeah good call, lemme look into that.

Copy link
Contributor

github-actions bot commented Nov 7, 2024

Copy link
Contributor

github-actions bot commented Nov 8, 2024

Copy link
Contributor

github-actions bot commented Nov 8, 2024

Copy link
Contributor

Copy link

openshift-ci bot commented Nov 11, 2024

@gashcrumb: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-tests 8db2907 link true /test e2e-tests

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-sigs/prow repository. I understand the commands that are listed here.

This change explicitely adds the default service factories to the
backend statically to prevent dynamic plugins from being able to
override them by default.  It's possible to override each statically
added service factory via an environment variable derived from the
service factory ID.  So for example to add a "core.rootHttpService"
service factory configuration from a dynamic plugin, set
ENABLE_CORE_ROOTHTTPSERVICE_OVERRIDE to "true".  This change also adds a
logger to the backend main.  Finally, a unit test has been added that
checks the installed backend-defaults value for the
defaultServiceFactories list against what this change adds to catch
future regressions.

Signed-off-by: Stan Lewis <[email protected]>
Copy link

sonarcloud bot commented Nov 12, 2024

Copy link
Contributor

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