How to ensure the consistency of serverless business deployment updates

Since I started working as a serverless tool, I have often encountered people asking the question of how to ensure consistency in serverless business deployment updates.

The so-called consistency here refers to: if we deploy the project locally through tools, and someone updates the project through other means (such as the console), will it be directly covered when I deploy the project locally?

For example, when user A updates the business locally, due to some special circumstances, an online abnormal situation "x" occurs. At this time, user B updates again and fixes the content, but B does not synchronize with A in a timely manner. A updates a new function and directly overwrites B's content. At this time, the previous abnormal situation x reappears. If at this time, when A updates, It can be perceived that online resources have changed, so this kind of thing will not happen again.

Currently, the Alibaba Cloud functional computing component based on Serverless Devs has supported the perception of online "abnormal changes", including the following situations:

1. Create and deploy a resource locally that is not available online

2. Local deployment completed, online update, and local re deployment

3. Create and deploy an existing online resource locally

Experimental preparation

Create a function through init (select Alibaba Cloud Serverless, select HTTP Function - Python 3 Example):

At this point, let's take a look at s.yaml:

After the project is deployed online, the performance is to create an FC deploy service and HTTP trigger function in the CN Hangzhou area

Create and deploy a resource locally that is not available online

At this point, we have determined that there are no corresponding resources online, so we will deploy them as follows:

Deployment completed and went smoothly:

Open the browser and view the custom address provided to us:

At this point, we can update the function code locally:

Save deployment:

After completing, check the online resources again:

The entire process is still quite close to the traditional basic process and has not triggered any online changes, making it an ideal process that is just right.

Local deployment completed, updated online, and deployed again locally

At this point, we make changes to the online resources by first finding the function on the console:

Modify the code and deploy it.

After the deployment is completed, let's refresh the previous address:

You can see that it has been updated. At this point, we will deploy locally:

As can be seen, the system has sensed a change in our code. At this point, we select yes and after completing it, we will view the online resources:

It should be noted that as long as there is a change in the service, function, or trigger of function calculation, it can be sensed here, whether it is configuration or code.

Create and deploy an existing online resource locally

At this point, we will proceed with the final experiment, deleting the local project and rebuilding it. Then execute the deployment. Due to the reasons we just experimented with, we already have these resources online, so it is considered to be deploying an online resource at this time.

At this point, it can be seen that the system perceives that this resource has not been deployed locally, is online, and already exists, so it is necessary to determine whether to overwrite it at this time.

Summary

The update of the code in other scenarios requires us to be aware of it currently, which is actually very important and closely related to the safe release of the code. At this point, it can be achieved through Serverless Devs.

So the question is, if I already have a project and want to integrate it into the CD process, and I don't want interactive operations, what should I do?

At this point, we provide a - use local parameter to forcibly override the online configuration. By using this instruction, we can achieve non interactive, local priority.

The birth of every tool requires a process of growth, and Serverless Devs is constantly growing. Looking forward to more and better features appearing.

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00

phone Contact Us