DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Keep Your Application Secrets Secret
  • How Sigma Rules Can Help Address the Cybersecurity Skills Shortage
  • Member Spotlight: Shai Almong
  • AI-Era Cybersecurity, Part 1: Mapping Glasswing, Daybreak, Lightwell and the Tools Racing to Find and Fix Bugs

Trending

  • Closing the Drift Loop: An AI Agent That Drafts Terraform Fixes
  • The Permission Was Valid. The Action Was Not Authorized.
  • The Window Closes: Why I Switched to Kotlin Before the Codebase Got Too Big
  • Batching Strategies: Throughput vs Latency in Practice

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Popular
  3. Open Source
  4. Make Your Backstage Templates Resilient

Make Your Backstage Templates Resilient

Learn what actions you can follow from Backstage release v1.23.0-next.0 to make your templates resilient to redeployment or any accidental server failures.

By 
Bogdan Nechyporenko
DZone Core CORE ·
Jan. 25, 24 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
3.7K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

I suppose that you are a user of Backstage and have your own templates that automate some repetitive and/or complicated flows of your organization. Some of your templates take a long time to be executed. For example, you provision your infrastructure, and your template guards the process along the way. Now, you are happy that you provided your engineers with these templates to lessen their burden, but you have to be careful with redeploying Backstage because you might fail ongoing tasks and make your engineers angry.

Here, I’ll explain what actions you can follow from release v1.23.0-next.0 to make your templates resilient to redeployment or any accidental server failures.

Steps

Since release v1.23.0-next.0 (or you can wait for a monthly release 1.23.0, which will happen at the end of February), you can mark your templates as recoverable, but you have to be sure that all your actions are idempotent. That means that your action can be running multiple times and having the same result as being called once. 

Let’s go step by step what you have to do:

1. Enable recoverability in your app-config-local.yaml file:

YAML
 
scaffolder:
   EXPERIMENTAL_recoverTasks: true


2. Open your template which you would like to make recoverable and there, add EXPERIMENTAL_recovery config as follows:

YAML
 
apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: docs-mocks-idempotent-template
  title: Documentation Mock Idempotent running Template
  description: Create a new standalone documentation project
  tags:
    - recommended
    - techdocs
    - mkdocs
spec:
  owner: backstage/techdocs-core
  type: documentation
  lifecycle: experimental
  EXPERIMENTAL_recovery:
    EXPERIMENTAL_strategy: 'startOver'


At the moment, only the startOver strategy is supported. To switch it off, you can remove the EXPERIMENTAL_recovery block or provide the value 'none'.

3. Make each of your actions idempotent. Let's assume your template is simplistic and has the following actions inside:

YAML
 
  steps:
    - id: fetch
      name: Template Docs Skeleton
      action: fetch:template
      input:
        url: ./skeleton
        values:
          name: ${{ parameters.name }}
          description: ${{ parameters.description }}
          destination: ${{ parameters.repoUrl | parseRepoUrl }}
          owner: ${{ parameters.owner }}
    - id: publish
      name: Publish
      action: publish:github
      input:
        allowedHosts: [ "github.com" ]
        description: This is ${{ parameters.name }}
        repoUrl: ${{ parameters.repoUrl }}
    - id: register
      name: Register
      action: catalog:register
      input:
        repoContentsUrl: ${{ steps.publish.output.repoContentsUrl }}
        catalogInfoPath: "/catalog-info.yaml"


  • fetch:template - This will be idempotent for your case, as at this moment, Backstage doesn't preserve the workspace; on each run, it will create a new one.
  • publish:github - This has to be replaced with your custom action. The modification to this action can look like this:

Action modification

  • catalog:register - This has to be also replaced with your custom action, and inside, prior to registering a new location, check if the location hasn't been registered yet. If yes, skip it, instead of throwing an error.

Give it a try. If you have more complicated templates, most probably you have more of your custom actions than default ones, and you are quite comfortable working with such customizations. 

In future releases, you can find the most used default actions supporting idempotency, but creating more complicated templates will require homework from your side in any case. 

Don't waste your time: start your journey now! Drop your feedback on what you think about it or if you need some more clarification on certain things as to how to make it fly on your end.

YAML Template Enterprise portal Open source Collaboration tool

Opinions expressed by DZone contributors are their own.

Related

  • Keep Your Application Secrets Secret
  • How Sigma Rules Can Help Address the Cybersecurity Skills Shortage
  • Member Spotlight: Shai Almong
  • AI-Era Cybersecurity, Part 1: Mapping Glasswing, Daybreak, Lightwell and the Tools Racing to Find and Fix Bugs

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook