You have to be careful about the commands you use every day in the production environment.

Introduction

It is the 13th day of Ateam cyma Advent Calendar 2019. Today, Ateam Co., Ltd. EC Business Headquarters cyma engineer @ihsiek will be in charge.

"People who have done it in a production environment Advent Calendar 2019" is very popular. Recently, the CI / CD environment has been enhanced and the chances of shell access to the production environment are decreasing, and the failure stories of others (other companies) will be a cane that will not fall down so as not to follow the same rut. I would like the engineers of the company to read such failure stories.

So, I would like to write a story of failure in a production environment due to an operation that I was completely unaware of the risks I took in my previous job.

TL; DR

What happened

Background

The day before

On the day

Commentary

The following is the result of man cp in the environment of occurrence.

If you try to copy the file to itself(Except for issuing an error message)do nothing.
When copying to an existing file, the destination file is ‘open(path,O_WRONLY|O_TRUNC)’Opened at.
When copying to a new file, the new file is ‘open(path,O_WRONLY|O_CREAT,mode)’Created with.
The copy destination file exists and-If opening a file in this format fails when the f option is given,
cp deletes existing files(Or unlink)Try.
Then, if the deletion is successful, the instruction is continued as a copy to a new file.

Although it is on the second line from the bottom, the destination of the symbolic link is looking at the same file in the backup and release destination, so

  1. Failed to open the file
  2. Delete existing files
  3. Continue the instruction as a copy to a new file
  4. Failed in 3 because the copy source file disappeared in 2.

That seems to have been the end of the matter. By the way, the behavior of the cp command seems to be different for each distribution, but I have confirmed that such a problem did not occur even at that time if the version was upgraded properly.

Summary

I think that the trouble was caused by the fact that I was careful that the cp command was just a copy command and that it would be okay, that I had prepared a way to verify only in production, and that I was not able to thoroughly update the OS. .. Here are my lessons learned:

in conclusion

How was the 13th day of Ateam cyma Advent Calendar 2019? Since it was a story of my previous job, I looked back while thinking that it would not be possible in my current workplace, but I pray that everyone will not follow the same rut. We apologize for the inconvenience caused to all the people involved at that time: bow_tone1:

Also, in the sense that I want you to feed on the mistakes of others, "Advent Calendar 2019" is really Since it is recommended, I would like various people to read it, including those who have never experienced production operation. Tomorrow is @namedpython, a new graduate engineer who is a little messy returnee. I'm looking forward to posting newcomers who are expected to build a solid data analysis platform.

Ateam Co., Ltd. is looking for colleagues with a strong spirit of challenge to work with.

If you are interested in working as an engineer, please see cyma's Qiita Jobs.

For other occupations, see Ateam Group Recruitment Site.

Recommended Posts

You have to be careful about the commands you use every day in the production environment.
How to write files that you should be careful about in all languages
The programming language you want to be able to use
You will be an engineer in 100 days --Day 86 --Database --About Hadoop
You will be an engineer in 100 days ――Day 71 ――Programming ――About scraping 2
You will be an engineer in 100 days ――Day 74 ――Programming ――About scraping 5
We have summarized the tech conferences scheduled to be held in 2020
You will be an engineer in 100 days ――Day 73 ――Programming ――About scraping 4
What to do if you can't use the trash in Lubuntu 18.04.
You will be an engineer in 100 days ――Day 70 ――Programming ――About scraping
You will be an engineer in 100 days ――Day 81 ――Programming ――About machine learning 6
You will be an engineer in 100 days ――Day 82 ――Programming ――About machine learning 7
You will be an engineer in 100 days ――Day 79 ――Programming ――About machine learning 4
I wanted to be careful about the behavior of Python's default arguments
You will be an engineer in 100 days ――Day 76 ――Programming ――About machine learning
You will be an engineer in 100 days ――Day 80 ――Programming ――About machine learning 5
You will be an engineer in 100 days ――Day 84 ――Programming ――About machine learning 9
You will be an engineer in 100 days ――Day 83 ――Programming ――About machine learning 8
You will be an engineer in 100 days ――Day 77 ――Programming ――About machine learning 2
Switch the module to be loaded for each execution environment in Python
You will be an engineer in 100 days ――Day 85 ――Programming ――About machine learning 10
About the development environment you are using
You will be an engineer in 100 days --Day 29 --Python --Basics of the Python language 5
I want to use Python in the environment of pyenv + pipenv on Windows 10
You will be an engineer in 100 days --Day 33 --Python --Basics of the Python language 8
You will be an engineer in 100 days --Day 26 --Python --Basics of the Python language 3
Use PIL in Python to extract only the data you want from Exif
You will be an engineer in 100 days --Day 32 --Python --Basics of the Python language 7
I didn't have to write a decorator in the class Thank you contextmanager
You will be an engineer in 100 days --Day 28 --Python --Basics of the Python language 4
Use the latest pip in a virtualenv environment
Use pygogo to get the log in json.
Use os.getenv to get environment variables in Python
The day you killed the process (flask gave an error saying Address already in use)
Use the CASA Toolkit in your own Python environment
How to use jupyter lab in Windows 10 local environment
Kaggle Tutorial Titanic know-how to be in the top 2%
I want to use the R dataset in python
Use hash to lighten collision detection of about 1000 balls in Python (related to the new coronavirus)
A story about PHP that was okay in the development environment but buggy in the production environment LEVEL 1-3 + 1
[Python] When you want to import and use your own package in the upper directory
You will be an engineer in 100 days ――Day 60 ――Programming ――About data structure and sorting algorithm