operator-framework / operator-framework/ansible-operator-plugins

Inconsistent sample file naming in Ansible operator scaffolding (v1.36+)

Open
#211 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

language/ansible
Dominant language
Go
Stars
12
Forks
33
PR merge metrics
No merged PRs in 30d

Description

Bug Report

What did you do?

Created a new Ansible-based operator using Operator SDK:

$ operator-sdk init --domain myorg.io --plugins ansible

Created a new API for kind "MyKind":

$ operator-sdk create api --version v1alpha1 --kind MyKind --generate-role

Examined the generated files in config/samples/:

$ ls -1 config/samples/
_v1alpha1_akit.yaml
kustomization.yaml

$ cat config/samples/kustomization.yaml
## Append samples of your project ##
resources:
- v1alpha1_mykind.yaml
- _v1alpha1_mykind.yaml
#+kubebuilder:scaffold:manifestskustomizesamples

The Ansible plugin scaffolding incorrectly adds both the underscored and non-underscored references

What did you expect to see?

I expected a single sample Custom Resource file to be created with consistent naming, and kustomization.yaml to reference only that one file.

Expected output:

Either v1alpha1_mykind.yaml or _v1alpha1_mykind.yaml (not both) and kustomization.yaml containing a single reference to the existing file:

## Append samples of your project ##
resources:
- v1alpha1_akit.yaml   # or _v1alpha1_akit.yaml depending on convention
# +kubebuilder:scaffold:manifestskustomizesamples
What did you see instead? Under which circumstances?

I observed inconsistent scaffolding: the actual file created was v1alpha1_mykind.yaml (without underscore) and kustomization.yaml contained both entries:

## Append samples of your project ##
resources:
- v1alpha1_mykind.yaml
- _v1alpha1_mykind.yaml
# +kubebuilder:scaffold:manifestskustomizesamples

The file _v1alpha1_mykind.yaml does not exist, causing make bundle to fail with:

Error: accumulating resources: accumulation err='accumulating resources from '../samples': '/home/myuser/myoperator/config/samples' must resolve to a file': recursed accumulation of path '/home/myuser/myoperator/config/samples': accumulating resources: accumulation err='accumulating resources from '_v1alpha1_mykind.yaml': evalsymlink failure on '/home/myuser/myoperator/config/samples/_v1alpha1_mykind.yaml' : lstat /home/myuser/myoperator/config/samples/_v1alpha1_mykind.yaml: no such file or directory': must build at directory: not a valid directory: evalsymlink failure on '/home/myuser/myoperator/config/samples/_v1alpha1_mykind.yaml' : lstat /home/myuser/myoperator/config/samples/_v1alpha1_mykind.yaml: no such file or directory

Additional testing: I tested various versions and found that this issue started with operator-sdk v1.36. Versions prior to 1.36 (e.g., 1.35) correctly generated a single consistent entry.

Environment

Operator type:

/language ansible

Kubernetes cluster type:

$ operator-sdk version

operator-sdk version: "v1.42.0", commit: "ab5563df5499cafa4ea9d40d4b36b51899a4718e", kubernetes version: "1.33.1", go version: "go1.24.6", GOOS: "linux", GOARCH: "amd64"

$ kubectl version

Client Version: v1.30.4
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.30.14
Possible Solution

The create api command should generate consistent file naming and kustomization references. Two possible fixes:

  • Option A: Generate the sample file with underscore (_v1alpha1_mykind.yaml) to match the existing kustomization template.
  • Option B: Generate the sample file without underscore and update kustomization.yaml to reference only that file.

Currently, the behavior is mixed: the file is created without underscore but kustomization references both, causing build failures.

Additional context

The issue appears to be specific to the Ansible plugin. The bug likely originated from a change in the scaffolding templates between v1.35 and v1.36 that caused both naming conventions to be written simultaneously.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Ansible create api scaffolding that produces config/samples/kustomization.yaml and the sample manifest, comparing the v1.35 and v1.36 behavior described in the issue. Reproduce the command sequence, inspect the generated references, and run make bundle. Done means one existing sample file is referenced and the bundle build succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
kubernetes
Domain
build-system, cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.