Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COPY command of bundle.Dockerfile is failing #85

Closed
laxmikantbpandhare opened this issue May 19, 2022 · 8 comments
Closed

COPY command of bundle.Dockerfile is failing #85

laxmikantbpandhare opened this issue May 19, 2022 · 8 comments
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@laxmikantbpandhare
Copy link
Member

Bug Report

After generating the bundle, bundle.Dockerfile gets generated with one extra line.

COPY bundle/tests/scorecard /tests/scorecard/

While building a bundle image it is failing as there is no such file in our project structure.

What did you do?

Added Run bundle changes.

What did you expect to see?

There are two ways

  1. Remove this line entirely or ask the user to remove it until we add the scorecard.

What did you see instead? Under which circumstances?

ERROR [3/3] COPY bundle/tests/scorecard /tests/scorecard/

Environment

Operator type:

Kubernetes cluster type:

Kind

$ operator-sdk version

operator-sdk version: "v1.20.0-12-g9a501a76-dirty", commit: "9a501a76cb4100144d325782a3d30b29fb653198", kubernetes version: "v1.23", go version: "go1.17.9", GOOS: "darwin", GOARCH: "amd64"

$ java -version (if language is Java)

openjdk version "16.0.2" 2021-07-20
OpenJDK Runtime Environment (build 16.0.2+7-67)
OpenJDK 64-Bit Server VM (build 16.0.2+7-67, mixed mode, sharing)

$ kubectl version

Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.0", GitCommit:"2c6062082e8dbbf36936b35dcc27c6882d3a2f67", GitTreeState:"clean", BuildDate:"2022-01-11T19:37:02Z", GoVersion:"go1.15.14", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.1", GitCommit:"5e58841cce77d4bc13713ad2b91fa0d961e69192", GitTreeState:"clean", BuildDate:"2021-05-21T23:01:33Z", GoVersion:"go1.16.4", Compiler:"gc", Platform:"linux/amd64"}

@jmrodri
Copy link
Member

jmrodri commented May 22, 2022

Can we just create the directory during init? Or is this because we're not passing in a scorecard yaml to operator-sdk generate bundle? If it is the latter then that might be a bug in generate bundle.

@jmrodri
Copy link
Member

jmrodri commented May 22, 2022

Looks like it should only generate that if the scorecard config is present https://github.com/operator-framework/operator-sdk/blob/master/internal/util/bundleutil/template.go#L53-L55

And here is the problem. We are hardcoding it to true https://github.com/operator-framework/operator-sdk/blob/master/internal/cmd/operator-sdk/generate/bundle/bundle.go#L300

So this causes the COPY command to show up.

@jmrodri
Copy link
Member

jmrodri commented May 22, 2022

I think you need to do something like this in generate/bundle/bundle.go.

diff --git a/internal/cmd/operator-sdk/generate/bundle/bundle.go b/internal/cmd/operator-sdk/generate/bundle/bundle.go
index ad15a75a..080b72dc 100644
--- a/internal/cmd/operator-sdk/generate/bundle/bundle.go
+++ b/internal/cmd/operator-sdk/generate/bundle/bundle.go
@@ -291,13 +291,15 @@ func (c bundleCmd) runMetadata() error {
 		}
 	}
 
+	scorecardConfigPath := filepath.Join(bundleRoot, scorecard.DefaultConfigDir, scorecard.ConfigFileName)
+
 	bundleMetadata := bundleutil.BundleMetaData{
 		BundleDir:            c.outputDir,
 		PackageName:          c.packageName,
 		Channels:             c.channels,
 		DefaultChannel:       c.defaultChannel,
 		OtherLabels:          metricsannotations.MakeBundleMetadataLabels(c.layout),
-		IsScoreConfigPresent: true,
+		IsScoreConfigPresent: genutil.IsExist(scorecardConfigPath),
 	}
 
 	return bundleMetadata.GenerateMetadata()

This needs to be tested with the other plugins to make sure it works. If it doesn't adjust accordingly.

@laxmikantbpandhare
Copy link
Member Author

Cool, I will go through it once.

@laxmikantbpandhare
Copy link
Member Author

I will work on it and raise the PR soon.

@laxmikantbpandhare
Copy link
Member Author

laxmikantbpandhare commented May 24, 2022

I did this change and tested with the Java plugin and it is working. I will test with other plugins too.

PR: operator-framework/operator-sdk#5800

@laxmikantbpandhare
Copy link
Member Author

Also, I tried generating a bundle for go, ansible, and helm chart. Every operator scaffolded scorecard details in the bundle.Dockerfile.

@laxmikantbpandhare
Copy link
Member Author

Fix moved to SDK master branch. Closing this issue as it gets fixed.

@laxmikantbpandhare laxmikantbpandhare added the kind/bug Categorizes issue or PR as related to a bug. label May 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

3 participants