Skip to content

Custom image build reports success on a failed plugin installation #239

@arm4b

Description

@arm4b

When trying to build a custom BitOps image with the plugin referring to the wrong git repo, the image build succeeds while in fact there was a failure.

Build the custom "plugins" image with the following bitops.config.yaml:

bitops:
  fail_fast: true     # When set, will exit if any warning+ is raised, otherwise only exit on critical error
  logging:      
    level: DEBUG
    color:
      enabled: true
    filename: bitops-run
    err: bitops.logs
    path: /var/logs/bitops
  opsrepo_root_default_dir: _default
  plugins:
    helm:
      source: https://google.com/ # <--- wrong git repo
  deployments:
    helm:
      plugin: helm

Let's take a look at what's inside the image:

docker run -it custom/my-bitops:helm --entrypoint /bin/sh

Re-running the original plugins.py install command:

/opt/bitops # python3 scripts/plugins.py install
2022-08-01 16:52:47,564 git.cmd      DEBUG Popen(['git', 'version'], cwd=/opt/bitops, universal_newlines=False, shell=None, istream=None)
2022-08-01 16:52:47,569 git.cmd      DEBUG Popen(['git', 'version'], cwd=/opt/bitops, universal_newlines=False, shell=None, istream=None)
2022-08-01 16:52:47,641 root         INFO 

 ____  _ _    ___            
| __ )(_) |_ / _ \ _ __  ___ 
|  _ \| | __| | | | '_ \/ __|
| |_) | | |_| |_| | |_) \__ \
|____/|_|\__|\___/| .__/|___/
                  |_|        

    BitOps is a way to describe the infrastructure and things deployed onto that infrastructure for multiple environments in a single place called an Operations Repo.
    
2022-08-01 16:52:47,641 root         INFO 


#~#~#~#~ BITOPS CONFIGURATION ~#~#~#~        
        FAIL FAST:              [True]                       
        RUN MODE:               [default]                        
        DEFAULT RUN MODE:       [install]                            
        LOGGING LEVEL:          [DEBUG]                       
        LOGGING COLOR:          [True]                           
        BITOPS CONFIG FILE:     [bitops.config.yaml]                     
#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#
                       
2022-08-01 16:52:47,654 root         INFO 


~#~#~#~PROCESSING STAGE [HELM]~#~#~#~

2022-08-01 16:52:47,655 root         INFO 


~#~#~#~PLUGIN SOURCE [https://google.com/]~#~#~#~

2022-08-01 16:52:47,657 root         INFO 


~#~#~#~CLONING PLUGIN [HELM]~#~#~#~              
         PLUGIN_SOURCE:         [https://google.com/]                           
         PLUGIN_TAG:            [latest]                              
         PLUGIN_BRANCH:         [main]                            
#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~# 
                            
2022-08-01 16:52:47,660 git.cmd      DEBUG Popen(['git', 'clone', '-v', '--branch=main', 'https://google.com/', '/opt/bitops/scripts/plugins/helm'], cwd=/opt/bitops, universal_newlines=True, shell=None, istream=None)
2022-08-01 16:52:48,040 git.repo.base DEBUG Cmd(['git', 'clone', '-v', '--branch=main', 'https://google.com/', '/opt/bitops/scripts/plugins/helm'])'s unused stdout: 
2022-08-01 16:52:48,041 git.cmd      DEBUG AutoInterrupt wait stderr: b"Cloning into '/opt/bitops/scripts/plugins/helm'...\nfatal: repository 'https://google.com/' not found\n"
2022-08-01 16:52:48,043 root         INFO 
~#~#~#~CLONING PLUGIN [helm] FAILED~#~#~#~
        Cmd('git') failed due to: exit code(128)
  cmdline: git clone -v --branch=main https://google.com/ /opt/bitops/scripts/plugins/helm
  stderr: 'Cloning into '/opt/bitops/scripts/plugins/helm'...
fatal: repository 'https://google.com/' not found
'

It failed, bit looks like the script didn't report the correct return code to be considered a failure:

/opt/bitops # echo $?
0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🪲Something isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions