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
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Enterprise AI Trend Report: Gain insights on ethical AI, MLOps, generative AI, large language models, and much more.

2024 Cloud survey: Share your insights on microservices, containers, K8s, CI/CD, and DevOps (+ enter a $750 raffle!) for our Trend Reports.

PostgreSQL: Learn about the open-source RDBMS' advanced capabilities, core components, common commands and functions, and general DBA tasks.

AI Automation Essentials. Check out the latest Refcard on all things AI automation, including model training, data security, and more.

Related

  • Keep Your Application Secrets Secret
  • How Sigma Rules Can Help Address the Cybersecurity Skills Shortage
  • Empowering Developers Through Collaborative Vulnerability Management: Insights From VulnCon 2024
  • An Explanation of Jenkins Architecture

Trending

  • Spring Strategy Pattern Example
  • Enhancing Secure Software Development With ASOC Platforms
  • Test Parameterization With JUnit 5.7: A Deep Dive Into @EnumSource
  • Effective Communication Strategies Between Microservices: Techniques and Real-World Examples
  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 user avatar
Bogdan Nechyporenko
DZone Core CORE ·
Jan. 25, 24 · Tutorial
Like (1)
Save
Tweet
Share
2.2K Views

Join the DZone community and get the full member experience.

Join For Free

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
  • Empowering Developers Through Collaborative Vulnerability Management: Insights From VulnCon 2024
  • An Explanation of Jenkins Architecture

Partner Resources


Comments

ABOUT US

  • About DZone
  • Send feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: