SUSE/cap

`config.logs.enabled=true` when `config.jobs.deploy-k8s-false` is broken

Opened this issue · 2 comments

Using the following config file:

(note logs.enabled=true and jobs.deploy-k8s=false)

workertags:
  caasp4: suse-internal

jobs:
  deploy-k8s: false
  deploy-kubecf: true
  smoke-tests: true
  cf-acceptance-tests-brain: false
  sync-integration-tests: false
  minibroker-integration-tests: false
  cf-acceptance-tests: false
  upgrade-kubecf: false
  deploy-stratos: false
  destroy-kubecf: true
jobs_ordered:
- deploy-k8s
- deploy-kubecf
- smoke-tests
- cf-acceptance-tests-brain
- sync-integration-tests
- minibroker-integration-tests
- cf-acceptance-tests
- upgrade-kubecf
- deploy-stratos
- destroy-kubecf
backends:
  caasp4: true
  aks: false
  gke: false
  eks: false
availabilities:
  sa: true
  ha: false
  all: false
schedulers:
  diego: true
  eirini: false
catapult:
  uri: https://github.com/SUSE/catapult
  branch: master
brain:
  verbose: false
  inorder: false
  include: ""
  exclude: ""
cats:
  nodes: 3
  flake-attempts: 5
  timeout-scale: "3.0"
s3minibroker:
  bucket: minibroker-helm-charts
  region: us-east-1
  regexp: minibroker-charts/minibroker-(.*).tgz
s3:
  bucket: kubecf
  region: us-west-2
  regexp: kubecf-bundle-v(.*).tgz
# Scheduling is required for nightly builds, enabling it removes regular trigger on kubecf bundle.
schedule:
  enabled: false
  start: 12:00 AM
  stop: 12:10 AM
  location: America/Vancouver
logs:
  enabled: true

Gives me:

apply configuration? [yN]: y
error: invalid pipeline config:
invalid resources:
        resource 's3.klog-destination' is not used

This is happening because the klog script is only called inside the destroy-k8s task:

{{- if eq .logs.enabled true }}
{{ tmpl.Exec "scripts_klog" | indent 14 | trimSpace }}
{{ end }}
{{ tmpl.Exec "scripts_destroy_k8s" | indent 14 | trimSpace }}
- put: {{ .backend }}-pool.kube-hosts
params:
remove: {{ .backend }}-pool.kube-hosts
depth: 1
{{- if eq .logs.enabled true }}
- put: s3.klog-destination
params:
file: catapult/klog-*.tar.gz
{{ end }}

Yet (rightly) the definition of the resource has nothing to do with destroy_k8s:

{{- if $config.logs.enabled }}
- name: s3.klog-destination
type: s3
source:
bucket: kubecf-klog
access_key_id: ((aws-access-key))
secret_access_key: ((aws-secret-key))
regexp: klog-(.*)\.tar\.gz$
region_name: us-west-2
endpoint: null
{{ end }}

Possible solutions:

There is a fundamental issue of design here. klog should not be part of destroy k8s job (aka destroy-kubecf flag) https://jira.suse.com/browse/CAP-1564