sonic-net / sonic-buildimage

Scripts which perform an installable binary image build for SONiC
Other
743 stars 1.43k forks source link

Config DB is not migrated from previous image #3460

Open stepanblyschak opened 5 years ago

stepanblyschak commented 5 years ago

Description

Steps to reproduce the issue:

admin@mtbc-sonic-03-2700:/etc/sonic$ ls                                                                                                                                                                                                                                                                                                                                        [21/3245]
asic_config_checksum  config_db.json  deployment_id_asn_map.yml  frr  generated_services.conf  init_cfg.json  snmp.yml  sonic_version.yml  updategraph.conf
admin@mtbc-sonic-03-2700:/etc/sonic$ head -n 25 config_db.json 
{
    "BGP_NEIGHBOR": {
        "10.0.0.1": {
            "asn": "65200", 
            "holdtime": "180", 
            "keepalive": "60", 
            "local_addr": "10.0.0.0", 
            "name": "ARISTA01T2", 
            "nhopself": 0, 
            "rrclient": 0
        }, 
        "10.0.0.3": {
            "asn": "65200", 
            "holdtime": "180", 
            "keepalive": "60", 
            "local_addr": "10.0.0.2", 
            "name": "ARISTA02T2", 
            "nhopself": 0, 
            "rrclient": 0
        }, 
        "10.0.0.5": {
            "asn": "65200", 
            "holdtime": "180", 
            "keepalive": "60", 
            "local_addr": "10.0.0.4", 
admin@mtbc-sonic-03-2700:/etc/sonic$ sudo sonic_installer install -y /home/admin/sonic-mellanox.bin 
Installing image SONiC-OS-HEAD.79-75104bb3 and setting it as default...
Command: bash /home/admin/sonic-mellanox.bin
Verifying image checksum ... OK.
Preparing image archive ... OK.
Installing SONiC in SONiC
ONIE Installer: platform: x86_64-mellanox-r0
onie_platform: x86_64-mlnx_msn2700-r0
Installing SONiC to /host/image-HEAD.79-75104bb3
Archive:  fs.zip
   creating: /host/image-HEAD.79-75104bb3/boot/
  inflating: /host/image-HEAD.79-75104bb3/boot/vmlinuz-4.9.0-9-2-amd64  
  inflating: /host/image-HEAD.79-75104bb3/boot/config-4.9.0-9-2-amd64  
  inflating: /host/image-HEAD.79-75104bb3/boot/System.map-4.9.0-9-2-amd64  
  inflating: /host/image-HEAD.79-75104bb3/boot/initrd.img-4.9.0-9-2-amd64  
   creating: /host/image-HEAD.79-75104bb3/platform/
 extracting: /host/image-HEAD.79-75104bb3/platform/firsttime  
   creating: /host/image-HEAD.79-75104bb3/platform/x86_64-grub/
  inflating: /host/image-HEAD.79-75104bb3/platform/x86_64-grub/grub-pc-bin_2.02~beta3-5+deb9u2_amd64.deb  
  inflating: /host/image-HEAD.79-75104bb3/fs.squashfs  
Installed SONiC base image SONiC-OS successfully

Command: grub-set-default --boot-directory=/host 0

Command: rm -rf /host/old_config

Command: cp -ar /etc/sonic /host/old_config

Command: sync;sync;sync

Command: sleep 3

Done
admin@mtbc-sonic-03-2700:/etc/sonic$ 
admin@mtbc-sonic-03-2700:/etc/sonic$ sudo reboot
/var/log: 0 B (0 bytes) trimmed
/boot: 385 MiB (403714048 bytes) trimmed
Mon Sep 16 16:09:37 UTC 2019 Rebooting with platform x86_64-mlnx_msn2700-r0 specific tool ...

INFO: firmware is up to date

Write failed: Broken pipe
stepanb@arc-build-server:~ 
> ssh-mtbc2700
Linux mtbc-sonic-03-2700 4.9.0-9-2-amd64 #1 SMP Debian 4.9.168-1+deb9u5 (2015-12-19) x86_64
You are on
  ____   ___  _   _ _  ____
 / ___| / _ \| \ | (_)/ ___|
 \___ \| | | |  \| | | |
  ___) | |_| | |\  | | |___
 |____/ \___/|_| \_|_|\____|

-- Software for Open Networking in the Cloud --

Unauthorized access and/or use are prohibited.
All access and/or use are subject to monitoring.

Help:    http://azure.github.io/SONiC/

admin@mtbc-sonic-03-2700:~$ cat /etc/sonic/config_db.json 
{
    "VERSIONS": {
        "DATABASE": {
            "VERSION": "version_1_0_1"
        }
    }
}

Describe the results you received: Config DB has only version information.

Describe the results you expected: Config DB is migrated from previous image

Additional information you deem important (e.g. issue happens only occasionally):

**Output of `show version`:**

```

Version: HEAD.79-75104bb3


    **Attach debug file `sudo generate_dump`:**
(paste your output here)
```
prsunny commented 5 years ago

can you do a config save and check? I think it requires the config to be explicitly saved by user.

jleveque commented 5 years ago

@prsunny: config save dumps ConfigDB to /etc/sonic/config_db.json. From the description above, it appears as though the file is present before the upgrade. It looks like it's getting trashed during DB migration. Assigning to @yxieca to take a look.

yxieca commented 5 years ago

@prsunny I think this is the flaw we discussed the other day. From the log, I think the old config_db.json was used without calling db_migrator.py. I thought you were adding these calls in updategraph.sh for a change you are making recently?