Azure Pipelines Self Hosted Agent Workspace Permissions Denied Building Golang App

In this article I describe my problem with Azure Pipelines self hosted agent and workspace permissions denied when building golang application. I was creating a common pipeline for building Golang application when I got stuck because of a problem with removing files in workspace. The problem was occurred after one job finished and another started. In logs was information: Starting: Checkout mateoops/linkoln@feature/dockerize ============================================================================== Task : Get sources Description : Get sources from a repository. Supports Git, TfsVC, and SVN repositories. Version : 1.0.0 Author : Microsoft Help : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199) ============================================================================== Syncing repository: mateoops/linkoln (GitHub) git version git version 2.43.5 git config --get remote.origin.url git clean -ffdx warning: failed to remove pkg/mod/github.com/bytedance/sonic/[email protected]/funcdata.go: Permission denied ... warning: failed to remove pkg/mod/gopkg.in/[email protected]/go.mod: Permission denied warning: failed to remove pkg/mod/gopkg.in/[email protected]/limit_test.go: Permission denied warning: failed to remove pkg/mod/gopkg.in/[email protected]/node_test.go: Permission denied warning: failed to remove pkg/mod/gopkg.in/[email protected]/parserc.go: Permission denied warning: failed to remove pkg/mod/gopkg.in/[email protected]/readerc.go: Permission denied warning: failed to remove pkg/mod/gopkg.in/[email protected]/resolve.go: Permission denied warning: failed to remove pkg/mod/gopkg.in/[email protected]/scannerc.go: Permission denied warning: failed to remove pkg/mod/gopkg.in/[email protected]/sorter.go: Permission denied warning: failed to remove pkg/mod/gopkg.in/[email protected]/suite_test.go: Permission denied warning: failed to remove pkg/mod/gopkg.in/[email protected]/writerc.go: Permission denied warning: failed to remove pkg/mod/gopkg.in/[email protected]/yaml.go: Permission denied warning: failed to remove pkg/mod/gopkg.in/[email protected]/yamlh.go: Permission denied warning: failed to remove pkg/mod/gopkg.in/[email protected]/yamlprivateh.go: Permission denied ##[warning]Unable to run "git clean -ffdx" and "git reset --hard HEAD" successfully, delete source folder instead. ##[error]One or several exceptions have been occurred. ##[error]System.UnauthorizedAccessException: Access to the path '/opt/az-agent/_work/1/s/pkg/mod/google.golang.org/[email protected]/cmd/protoc-gen-go/testdata/imports/test_b_1/m2.pb.go' is denied. ---> System.IO.IOException: Permission denied --- End of inner exception stack trace --- at System.IO.FileSystem.DeleteFile(String fullPath) at System.IO.FileInfo.Delete() at Microsoft.VisualStudio.Services.Agent.Util.IOUtil.<>c__DisplayClass12_0.<DeleteDirectory>b__0(FileSystemInfo item) in /mnt/vss/_work/1/s/src/Agent.Sdk/Util/IOUtil.cs:line 156 at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey) at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork() at System.Linq.Parallel.SpoolingTaskBase.Work() at System.Linq.Parallel.QueryTask.BaseWork(Object unused) at System.Linq.Parallel.QueryTask.RunTaskSynchronously(Object o) at System.Threading.Tasks.Task.InnerInvoke() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) The error indicated that the Azure Pipelines task is attempting to clean the Git repository (git clean -ffdx) or reset it (git reset –hard HEAD) but is failing due to permission issues on some files and directories. This is causing the pipeline task to fail. ...

2024-24-02 · 3 min · 512 words · Mateoops

Linux Storage Management Tips and Tricks: Identify Storage Configuration

As you know there is not one correct way to organize disks. Devices, partitions, LVMs, and filesystems may be configured in many ways. Managing plenty of Linux servers requires the ability to fast identify their configuration by an administrator. Of course - the basic command is df -h which gives information about mounted filesystems. The best way to quickly get a big-picture look at our storage configuration on the system is to use the lsblk command. It displays information about block devices such as disks, partitions, and their relationships. It provides a tree-like view of storage devices and their attributes, making it easy to understand the storage configuration of a Linux system. ...

2024-24-28 · 3 min · 577 words · Mateoops

Linux Storage Management Tips and Tricks: Overview

Talking about Linux disk management we can write a fat handbook or at least a rich collection of articles. I planned to write a single article about this, but the topic turned out to be too broad. So, I decided to create a few smaller articles. Based on my experience, I focused on only a few killer tips and tricks that are really helpful in Linux administrator life without delving into details. I omitted basics topics. This collection of articles may be a good addon to existing cheat sheets for administrator work. ...

2024-24-28 · 2 min · 227 words · Mateoops

Easy way to build Canary Deployment using Kubernetes

In the realm of DevOps canary deployment have become a popular technique for releasing new application versions gradually, minimizing risk of full-scale rollouts. Kubernetes has native support for flexible deployments, scaling and traffic management. In this article I will show you the easiest way to build canary deployment with Kubernetes. What is Canary Deployment Why Use Canary Deployments? Setting Up Canary Deployment in Kubernetes - Easiest way Create Deployment - stable version of application Create Service for stable version of application Create Deployment - canary version Edit Service to split traffic Extend this scenario Conclusion What is Canary Deployment? Canary deployment is a strategy where a new version of an application is released to a small subset of users before a full-scale rollout. By deploying to a small group (like 10-20% of users), you can monitor performance, get feedback, and catch potential issues before they affect all users. If everything works well, the rollout continues; if not, the deployment can be rolled back quickly. About rolling updates and rollbacks you can read in my previous article ...

2024-24-12 · 6 min · 1068 words · Mateoops

Kubernetes Application deployments and how to perform rolling update and rollbacks

Kubernetes deployment is the most powerfull way to to create and maitain containerized applications. It helps you manage the entire lifecycle of an application - from initial deployment to subsequent updates and disliked but occasionally necessary rollbacks. In this post I will show you how to use deployments rolling updates and rollbacks to keep maximum availibilty of your application. Setting up a Deployment Understanding Rolling Updates Performing Rolling Update Executing Rollbacks Conclusion Setting up a Deployment At first let’s create simple application deployment on Kubernetes. In this example, we’ll use the popular nginx image. ...

2024-24-07 · 3 min · 621 words · Mateoops