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

Migrate plugins to new Backstage Backend system #1325

Open
5 of 15 tasks
punkle opened this issue Apr 5, 2024 · 19 comments
Open
5 of 15 tasks

Migrate plugins to new Backstage Backend system #1325

punkle opened this issue Apr 5, 2024 · 19 comments
Labels
help wanted Extra attention is needed kind/enhancement New feature or request

Comments

@punkle
Copy link
Contributor

punkle commented Apr 5, 2024

The new backstage backend system is ready to be used at this point. The old backend system will be deprecated and is scheduled to be removed at the end of this year. As such this repo needs its backend plugins migrated to use the new Backstage Backend system.

If you would like to take ownership of migrating a plugin in this repo please, write a comment on this issue expressing your interest in helping out. Then create a pull request referencing this issue.

Here is an example of the pull request for the rag-ai-backend plugin #1319

@punkle punkle added the kind/enhancement New feature or request label Apr 5, 2024
@punkle
Copy link
Contributor Author

punkle commented Apr 5, 2024

@drodil here is the issue we discussed.

@punkle punkle added the help wanted Extra attention is needed label Apr 5, 2024
@david-heidema
Copy link
Contributor

I have interest on updating scoffolder-backend-module-http-request and scaffolder-backend-module-utils. I will share the PR once the work is complete.

@clementblaise
Copy link

Opened #1341

@david-heidema
Copy link
Contributor

david-heidema commented Apr 26, 2024

#1348, #1349 , and #1361 complete the migration of scoffolder-backend-module-http-request and scaffolder-backend-module-utils.

@supersol
Copy link

@kissmikijr @vanessap-aa could you advice if there is a way to use argocd backend plugin with the new backstage backend system? or do you have any migration plans?
I attempted to manage it to work but without any success and at the same time I have a very little js/ts coding experience :)

@clementblaise
Copy link

Is it possible to re-open #1341 and get a review?

@kissmikijr
Copy link
Contributor

@kissmikijr @vanessap-aa could you advice if there is a way to use argocd backend plugin with the new backstage backend system? or do you have any migration plans? I attempted to manage it to work but without any success and at the same time I have a very little js/ts coding experience :)

I think you should be able to use the legacyPlugin and register not migrated plugins yet to your backstage if you already use the new backend-system. I did not test it yet but something like this:

import { legacyPlugin } from '@backstage/backend-common';

backend.add(legacyPlugin('argoCd', import('./plugins/argocd')));

@supersol
Copy link

supersol commented Jun 3, 2024

@kissmikijr @vanessap-aa could you advice if there is a way to use argocd backend plugin with the new backstage backend system? or do you have any migration plans? I attempted to manage it to work but without any success and at the same time I have a very little js/ts coding experience :)

I think you should be able to use the legacyPlugin and register not migrated plugins yet to your backstage if you already use the new backend-system. I did not test it yet but something like this:

import { legacyPlugin } from '@backstage/backend-common';

backend.add(legacyPlugin('argoCd', import('./plugins/argocd')));

@kissmikijr First of all thanks for the reply.

I tried that way, unfortunately it doesn't work.
In the beginning when it failed there was PluginEnvironment entity dependency from types.ts file, so I tried to bring back that file,

import { createRouter } from '@roadiehq/backstage-plugin-argo-cd-backend';
import { PluginEnvironment } from '../types';

export default async function createPlugin({
  logger,
  config,
}: PluginEnvironment) {
  return await createRouter({ logger, config });
}

it didn't work, then I tried to remove that entity completely, so it doesn't depend on PluginEnvironment and just import the plugin, it still didn't work

tried like this:
backend.add(legacyPlugin('argocd', import('@roadiehq/backstage-plugin-argo-cd-backend')));

it gave me some incompatibilities at the compile time.

#8 18.22 packages/backend/src/index.ts:60:36 - error TS2345: Argument of type 'Promise<{ default: typeof import("/backstage/node_modules/@roadiehq/backstage-plugin-argo-cd-backend/dist/index"); ArgoService: typeof ArgoService; createRouter: ({ logger, config, }: RouterOptions) => Promise<...>; }>' is not assignable to parameter of type 'Promise<{ default: LegacyCreateRouter<TransformedEnv<{ cache: CacheService; config: RootConfigService; database: DatabaseService; discovery: DiscoveryService; ... 5 more ...; identity: IdentityService; }, { ...; }>>; }>'.
#8 18.22   Type '{ default: typeof import("/backstage/node_modules/@roadiehq/backstage-plugin-argo-cd-backend/dist/index"); ArgoService: typeof ArgoService; createRouter: ({ logger, config, }: RouterOptions) => Promise<...>; }' is not assignable to type '{ default: LegacyCreateRouter<TransformedEnv<{ cache: CacheService; config: RootConfigService; database: DatabaseService; discovery: DiscoveryService; ... 5 more ...; identity: IdentityService; }, { ...; }>>; }'.
#8 18.22     Types of property 'default' are incompatible.
#8 18.22       Type 'typeof import("/backstage/node_modules/@roadiehq/backstage-plugin-argo-cd-backend/dist/index")' is not assignable to type 'LegacyCreateRouter<TransformedEnv<{ cache: CacheService; config: RootConfigService; database: DatabaseService; discovery: DiscoveryService; ... 5 more ...; identity: IdentityService; }, { ...; }>>'.
#8 18.22         Type 'typeof import("/backstage/node_modules/@roadiehq/backstage-plugin-argo-cd-backend/dist/index")' provides no match for the signature '(deps: TransformedEnv<{ cache: CacheService; config: RootConfigService; database: DatabaseService; discovery: DiscoveryService; ... 5 more ...; identity: IdentityService; }, { ...; }>): Promise<...>'.
#8 18.22 

@martina-equinix
Copy link
Contributor

Hey @supersol

I got the backend plugin working with this:

// backend/src/plugins/argocd.ts

import { createRouter } from '@roadiehq/backstage-plugin-argo-cd-backend';
import { PluginEnvironment } from '../types';
import {Router} from "express";

export default async function createPlugin(
  env: PluginEnvironment,
): Promise<Router> {
  return await createRouter({
    logger: env.logger,
    config: env.config,
  });
}
// backend/src/index.ts

+import {legacyPlugin} from '@backstage/backend-common';
...
+backend.add(legacyPlugin('argocd', import('./plugins/argocd')));

@kissmikijr
Copy link
Contributor

kissmikijr commented Jun 6, 2024

If you have a custom environment for your plugins you will need to use the following way to provide the custom environment to your plugins

An example custom env config.

// backend/src/index.ts

import { coreServices } from '@backstage/backend-plugin-api';
import {
  makeLegacyPlugin,
  loggerToWinstonLogger,
  cacheToPluginCacheManager,
} from '@backstage/backend-common';
...
const legacyPlugin = makeLegacyPlugin(
  {
    logger: coreServices.logger,
    cache: coreServices.cache,
    database: coreServices.database,
    auth: coreServices.auth,
    config: coreServices.config,
    reader: coreServices.urlReader,
    discovery: coreServices.discovery,
    tokenManager: coreServices.tokenManager,
    permissions: coreServices.permissions,
    scheduler: coreServices.scheduler,
    // ... and your own additions

  },
  {
    logger: log => loggerToWinstonLogger(log),
    cache: cache => cacheToPluginCacheManager(cache),
  },
);


...
backend.add(legacyPlugin('argocd', import('./plugins/argocd')));

@clementblaise
Copy link

Hello @kissmikijr is it possible to get a review on #1341 ?

@supersol
Copy link

supersol commented Jul 9, 2024

thanks @kissmikijr @martina-equinix for your replies.

After some time I managed to make it work with the new backend, in case it will help to someone, I'll leave it here.
I made some tricks which mime the behavior for the new backend, it also looks like a part of migration actually.
I added 2 files to the plugins folder,

  1. argocd_index.ts (name could be any)
export { argocdPlugin as default } from './argocd';
  1. argocd.ts (name should match export)
    Basically I wrapped a router with the new function for the plugins
import { createRouter } from '@roadiehq/backstage-plugin-argo-cd-backend';
import { loggerToWinstonLogger } from '@backstage/backend-common';
import {
  coreServices,
  createBackendPlugin,
} from '@backstage/backend-plugin-api';

export const argocdPlugin = createBackendPlugin({
  pluginId: 'argocd',
  register(env) {
    env.registerInit({
      deps: {
        logger: coreServices.logger,
        config: coreServices.rootConfig,
        reader: coreServices.urlReader,
        discovery: coreServices.discovery,
        auth: coreServices.auth,
        tokenManager: coreServices.tokenManager,
        httpRouter: coreServices.httpRouter,
      },
      async init({
        logger,
        config,
        httpRouter,
      }) {
        httpRouter.use(
          await createRouter({
            logger: loggerToWinstonLogger(logger),
            config,
          }),
        );
      },
    });
  },
});

3 . index.ts - added this "custom plugin" ( add parameters should match then name from 1. step)

...
backend.add(import('./plugins/argocd_index'));
...

Then the build didn't fail and the argocd cards in the UI were showing apps state and some history.

@fjudith
Copy link
Contributor

fjudith commented Aug 27, 2024

Hello,

We're working on a port of the RAG-AI to backend system of Backstage v1.30.x which includes a lot of deprecated API removals.
We backend modules to remove the dependency on CreateLegacyPlugin.

If you're interresed we can make PR once we update the doc ?

link to the repo: https://github.com/alithya-oss/backstage-plugins/tree/main/workspaces/rag-ai/plugins

@Xantier
Copy link
Contributor

Xantier commented Aug 28, 2024

Thanks @fjudith, a pull request would be very welcome for that yeah.

@fjudith
Copy link
Contributor

fjudith commented Sep 17, 2024

Thanks @fjudith, a pull request would be very welcome for that yeah.

I battled for a week trying pass the Backstage tinter locally, it seems that relying on the old backend system will make our life worst and worst over time. Considering that Backstage 1.31.0 will officially declare the v1 of the new backend system.
what do you the of migrating the current packages/backend/src/index.ts to use the new declarative plugin implementation see ?

I guess this will make the plugin migration tracking a bit more easier as well as keeping consistent documentation during the transition process

@vmahe35
Copy link

vmahe35 commented Oct 1, 2024

Hello,

We're working on a port of the RAG-AI to backend system of Backstage v1.30.x which includes a lot of deprecated API removals. We backend modules to remove the dependency on CreateLegacyPlugin.

If you're interresed we can make PR once we update the doc ?

link to the repo: https://github.com/alithya-oss/backstage-plugins/tree/main/workspaces/rag-ai/plugins

Hello @fjudith
I am trying to test your new implementation of rag-ai plugins.
The doc regarding OpenAI backend configuration does not seem to be updated because I have some errors if I create a packages/backend/src/plugins/ai.ts file containing what is suggested.
Could you provide a sample example file or update the doc ?
Thanks.

P.S. : it is really great that you also added distinct baseURL configuration parameters in order to set the OpenAI endpoints, because personally I am using my locally hosted VLLM instance that provides an OpenAI compatible API. See https://docs.vllm.ai/en/latest/serving/openai_compatible_server.html and I have different endpoints for LLM model and Embedding model.

@SonilPro
Copy link

SonilPro commented Oct 9, 2024

RSS plugin also needs to be migrated. I am willing to open a PR for it

@fjudith
Copy link
Contributor

fjudith commented Oct 25, 2024

Sorry i still did'nt submitted the PR for Rag-AI.

I will first submit one for backstage-aws-backend.

In the coming hours.

@O5ten
Copy link

O5ten commented Nov 4, 2024

@fjudith How are you faring with the aws-backend? We're curious about adopting it and if it is just hours away then i'd be glad to try it out. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests