sonic-net / sonic-buildimage

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

[ZTP] firmware plugin: predefined task of removing of existing image fails. #5379

Open MaxYaremchuk opened 4 years ago

MaxYaremchuk commented 4 years ago

Description Attempt of removing inactive sonic image by firmware's remove plugin fails. In syslog it claims that image is not specified but it has been specified in ztp config file.

Steps to reproduce the issue

  1. Install two images on the switch.
  2. Boot sonic with ZTP enabled feature
  3. Specify in the remove section the name of currently inactive image to be removed.
    sonic_installer list
    Current: SONiC-OS-HEAD.0-f6a8678d
    Next: SONiC-OS-HEAD.0-f6a8678d
    Available: 
    SONiC-OS-HEAD.0-f6a8678d
    SONiC-OS-HEAD.0-fffee7e3   <==this image is supposed to be removed
    cat /var/run/ztp/ztp_data_opt67.json
    {
        "ztp": {
                "01-firmware": {
                        "remove": {
                                "image": "SONiC-OS-HEAD.0-fffee7e3" 
                        }
                 }
        }
    }
  4. Announce DHCP option 67 pointing to ztp_config.json (see at the bottom)
  5. Initiate ZTP one more time
    ztp erase
    ztp run

Describe the results you received Remove subtask fails with error:

Sep  4 08:07:26.460584 DUT-1 INFO sonic-ztp[20620]: Processing configuration section 01-firmware at 2020-09-04 08:07:26 UTC.
Sep  4 08:07:27.384968 DUT-1 ERR sonic-ztp[626]: firmware: Error [Version of image to be removed is not provided] encountered while processing.
Sep  4 08:07:27.402007 DUT-1 INFO sonic-ztp[20620]: Processed Configuration section 01-firmware with result FAILED, exit code (1) at 2020-09-04 08:07:26 UTC.
Sep  4 08:07:27.403739 DUT-1 INFO sonic-ztp[20620]: Checking configuration section 01-firmware result: FAILED, ignore-result: False.
Sep  4 08:07:27.404560 DUT-1 INFO sonic-ztp[20620]: ZTP failed at 2020-09-04 08:07:27 UTC as configuration section 01-firmware FAILED.

Although SONiC's image is specified in ztp config file:

Describe the results you expected Specified in ztp config file image has to be removed.

Output of show version

SONiC Software Version: SONiC.HEAD.0-f6a8678d
Distribution: Debian 9.13
Kernel: 4.9.0-11-2-amd64
Build commit: f6a8678d
Build date: Mon Aug 17 14:01:06 UTC 2020
Built by: ezrada@l-csi-0241l

Platform: x86_64-mlnx_msn2700-r0
HwSKU: Mellanox-SN2700
ASIC: mellanox
Serial Number: MT1646X05282            
Uptime: 08:08:51 up 26 min,  2 users,  load average: 0.07, 0.55, 0.85

sonic_dump_DUT-1_20200904_080850.tar.gz

ZTP config file:

{
        "ztp": {
                "01-firmware": {
                        "remove": {
                                "image": "SONiC-OS-HEAD.0-fffee7e3" 
                        }
                 }
        }
}
rajendra-dendukuri commented 4 years ago

Please use "version" : "SONiC-OS-HEAD.0-fffee7e3" instead of "image" : "SONiC-OS-HEAD.0-fffee7e3". Please refer to the ZTP HLD https://github.com/Azure/SONiC/blob/master/doc/ztp/ztp.md#firmware

MaxYaremchuk commented 4 years ago

Hi @rajendra-dendukuri Thank you for having answered me. There is a mistake in manual.

  "firmware": {
    "remove": {
      "image": "SONiC-OS-brcm_xlr_gts.0-dirty-20190304.154831"
    }
  }

Please change it on "version": "SONiC-OS-brcm_xlr_gts.0-dirty-20190304.154831" in the manual. Thanks.

anshuv-mfst commented 4 years ago

@rajendra-dendukuri working in the issue.