operator-framework / operator-sdk

SDK for building Kubernetes applications. Provides high level APIs, useful abstractions, and project scaffolding.
https://sdk.operatorframework.io
Apache License 2.0
7.22k stars 1.75k forks source link

operator-sdk bundle regression - no longer honours --input-dir and/or --output-dir #5143

Closed phantomjinx closed 3 years ago

phantomjinx commented 3 years ago

Bug Report

What did you do?

Syndesis project has been using operator-sdk 1.5.0 for bundle generation. Due to historical circumstances, the Makefile & PROJECT files were located in the config directory and all paths to config/ were updated to ..

Therefore the command for generating the config/manifests directory looks like this:

operator-sdk generate kustomize manifests \
  --apis-dir ../api \
  --input-dir manifests \
  --output-dir manifests

However, an update of the operator-sdk to 1.9.2 causes problems.

Rather than the existing config/manifests directory being observed and used, a new arbitrary config/config/manifests directory is created instead. This means any customisations to the base CSV are ignored and the resulting bundle produced incorrectly.

Reproduced Using memcached Tutorial

  1. Created a template memcached project (commit) using the tutorial;
  2. Moved the Makefile and PROJECT into the config directory and customized accordingly (see commit);
  3. Downgraded (commit) to kubebuilder v2 to be compatible with operator-sdk 1.5.0 and executed make bundle ---> Bundle created correctly and no new config directory;
  4. Switched to operator-sdk 1.5.1 and repeated make bundle --> Bundle created correctly and no new config directory;
  5. Switched to operator-sdk 1.6.1 and repeated make bundle --> New config/config/manifests directory created (commit).

What did you expect to see?

What did you see instead? Under which circumstances?

Environment

Operator type:

/language go

Kubernetes cluster type:

$ operator-sdk version

  1. operator-sdk version: "v1.5.0", commit: "98f30d59ade2d911a7a8c76f0169a7de0dec37a0", kubernetes version: "1.19.4", go version: "go1.15.5", GOOS: "linux", GOARCH: "amd64"
  2. operator-sdk version: "v1.5.1", commit: "b1db0a5863923d4d37f562f16541f68bc7ab9ed5", kubernetes version: "1.19.4", go version: "go1.15.5", GOOS: "linux", GOARCH: "amd64"
  3. operator-sdk version: "v1.6.1", commit: "e6981d812a759442a583d8ee2fae269507c408d4", kubernetes version: "1.19.4", go version: "go1.15.5", GOOS: "linux", GOARCH: "amd64"
  4. operator-sdk version: "v1.9.2", commit: "319e77f2fff57c6c862bddd64ecf9c562f2d2161", kubernetes version: "1.20.2", go version: "go1.16.6", GOOS: "linux", GOARCH: "amd64"

$ go version (if language is Go) go version go1.15.8 linux/amd64

$ kubectl version Client Version: 4.7.1 Server Version: 4.8.2 Kubernetes Version: v1.21.1+051ac4f

Possible Solution

Code change between 1.5.1 and 1.6.1 meant --input-dir and/or --output-dir no longer respected?

phantomjinx commented 3 years ago

Tested 1.11.0 and 1.10.1 - both fail like 1.6.1.

phantomjinx commented 3 years ago

bisect

git bisect showing regression

operator-sdk version: "scorecard-kuttl/v2.0.0-21-g163c6575", commit: "163c657565ad136fc1f6c453803e1af8306f0b63", kubernetes version: "v1.19.4", go version: "go1.15.8", GOOS: "linux", GOARCH: "amd64"
phantomjinx commented 3 years ago

The result of the bug in Syndesis is that the manager directory is not included, leading to no deployment in the final bundle. The reason for this is that the manifest/kustomization.yaml file does not include a ../default path whereas the generated erroneous config/manifest/kustomization.yaml version does.

This is a difference to my memcached-operator example because the deployment is included in its bundle since it does use the standard ./default directory.

Anyway, have created a PR which solves the issue and works when outputDir is both set and unset.

varshaprasad96 commented 3 years ago

Closing this as we have the PR (https://github.com/operator-framework/operator-sdk/pull/5144) merged.