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

*: use CI-built scorecard images during e2e tests #3909

Merged

Conversation

joelanford
Copy link
Member

Description of the change:
Use CI-built scorecard images during e2e tests

Motivation for the change:
Right now, we use either master or the latest release image during CI. However, this has 2 problems:

  1. It doesn't test any changes to these images that may have happened in PRs
  2. It fails during releases PRs because the release image is not yet built and pushed.

This is related to #3845.

@joelanford
Copy link
Member Author

This is required to be backported to v1.0.x so that the v1.0.1 release PR will pass in #3901.

"quay.io/operator-framework/scorecard-test:.*",
"quay.io/operator-framework/scorecard-test:dev",
)

By("creating an API definition")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joelanford these are not the only places. The images are scaffold in many files in the sub dir of config and bundle. If you check the Memcached Go Sample you will see that it needs to be changed in:

  • /scorecard/config.yaml
  • /patches/olm.config.yaml
  • /patches/basic.config.yaml

However, it shows changed from 1.0.0 to now. So, if you run the test and ad a breaking point you will find the places in the bundle which are not in the Memcached sample.

IMO we could to do:

By("replacing scorecard-test image to use the dev tag")
const scorecardImage :="quay.io/operator-framework/scorecard-test:master"
const scorecardImageReplace :="quay.io/operator-framework/scorecard-test:dev"
err = testutils.ReplaceInAllFilesFromTree(filepath.Join(tc.Dir, "bundle"), scorecardImage,scorecardImageReplace)
Expect(err).NotTo(HaveOccurred())
err = testutils.ReplaceInAllFilesFromTree(filepath.Join(tc.Dir, "config", "scorecard"), scorecardImage, scorecardImageReplace)
Expect(err).NotTo(HaveOccurred())
// ReplaceInAllFiles replaces all instances of old with new in the files of a directory and its subdirectories.
func ReplaceInAllFilesFromTree(projectPath, old, new string) error {
	err := filepath.Walk(projectPath,
		func(path string, info os.FileInfo, err error) error {
			if err != nil {
				return err
			}
			if !info.IsDir() {
				ReplaceInFile(path, old, new)
			}
			return nil
		})
	if err != nil {
		return err
	}
	return nil
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it, we don't need to replace in ./bundle, because that directory is populated from the contents of the config directory when make bundle is run. So the changes we make in the kustomize patch files propagate to the bundle.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI @joelanford,

Regards the bundle it makes sense only if the bundle is generated after this replace. Note that in the future we will build the bundle before in the samples and then, we will do this replace just for the e2e tests.

See that it shows still missing the /scorecard/config.yaml.

Also, note that it is very easy we add new scaffolds and just forget that we need to replace the images. So, I think it is better we add the func that will replace ALL in a tree as suggested above for we do not end up by mistake in this situation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that in the future we will build the bundle before in the samples and then, we will do this replace just for the e2e tests.

This PR is a minimal change to get this working. I plan to backport this to v1.0.1, so I don't think it is a good idea to make the bigger change that you're suggesting for a backported patch. Let's capture this subject as something to solve in your enhancement for generating the samples.

See that it shows still missing the /scorecard/config.yaml.

As far as I can tell, this file doesn't exist in the e2e project (or in the operator-sdk-samples project) and all references correctly use the dev image tag. Am I missing something somewhere?

$ cd e2e-kbaf
$ grep -r 'image:.*scorecard-test' * | sort | uniq
bundle/tests/scorecard/config.yaml:    image: quay.io/operator-framework/custom-scorecard-tests:dev
bundle/tests/scorecard/config.yaml:    image: quay.io/operator-framework/scorecard-test:dev
config/scorecard/patches/basic.config.yaml:    image: quay.io/operator-framework/scorecard-test:dev
config/scorecard/patches/custom.config.yaml:    image: quay.io/operator-framework/custom-scorecard-tests:dev
config/scorecard/patches/olm.config.yaml:    image: quay.io/operator-framework/scorecard-test:dev

Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few nits @joelanford.

@joelanford
Copy link
Member Author

Updated to add the same replacements for the helm and ansible e2e runs.

@camilamacedo86, I think the issue both of us hit is that the dev images were not actually being loaded into the kind cluster because the kubectl command was failing during load_image_if_kind. See https://travis-ci.org/github/operator-framework/operator-sdk/jobs/728156932#L1227

Copy link
Member

@jmrodri jmrodri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks okay to me. I'll wait for @camilamacedo86 to be able to respond before lgtm'ing

Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment in: https://github.com/operator-framework/operator-sdk/pull/3909/files#r490877131

  • It shows still missing a file to be updated /scorecard/config.yaml
  • in order to improve the maintainability and avoid the scenario where we add more manifests and forget to replace the images I'd advocate in favour of we replace ALL files in the tree instead of each one. IMO it will ensure that behaviour after we change it to use the gen samples instead.
  • Nit: WDYT about we have a helper func in test/internal/ such as : ReplaceAllScorecardImagesForDev() to centralize the code

Otherwise, it shows /lgtm for me.
Btw really tks for discovery the root cause of the issue faced by us :-)

@joelanford
Copy link
Member Author

joelanford commented Sep 18, 2020

Nit: WDYT about we have a helper func in test/internal/ such as : ReplaceAllScorecardImagesForDev() to centralize the code

Probably a good idea. I'll capture in a separate issue for follow-up.

EDIT: #3912

@joelanford joelanford merged commit 40e00a3 into operator-framework:master Sep 18, 2020
@joelanford joelanford deleted the use-ci-scorecard-images branch September 18, 2020 14:00
joelanford added a commit to joelanford/operator-sdk that referenced this pull request Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants