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

manifest_test: safer registry setup and teardown #14845

Merged
merged 1 commit into from
Jul 8, 2022

Conversation

edsantiago
Copy link
Member

manifest_test:authenticated_push() is the final test left to
fix before merging #14397. The reason it's failing seems to be
that podman is running with a mix of netavark and CNI, and
that seems to be because this test invokes hack/podman-registry
which invokes plain podman without whatever options used in e2e.

Starting a registry directly from the test is insane: there is
no reusable code for doing that (see login_logout_test.go and
push_test.go. Yeesh.)

Solution: set $PODMAN, by inspecting the podmanTest object
which includes both a path and a list of options. podman-registry
will invoke that. (It will also override --root and --runroot.
This is the desired behavior).

Also: add cleanup. If auth-push test fails, stop the registry.

Also: add a sanity check to podman-registry script, have it
wait for the registry port to activate. Die if it doesn't.
That could've saved us a nice bit of debugging time.

Signed-off-by: Ed Santiago [email protected]

None

@edsantiago edsantiago added the kind/cleanup Categorizes issue or PR as related to cleanup. label Jul 6, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 6, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: edsantiago

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 6, 2022
@edsantiago edsantiago force-pushed the registry_sanitize branch 4 times, most recently from a2d829c to 81234ad Compare July 7, 2022 01:47
@edsantiago edsantiago force-pushed the registry_sanitize branch from 81234ad to 14899e8 Compare July 7, 2022 11:29

// registry script invokes $PODMAN; make sure we define that
// so it can use our same networking options.
opts := strings.Join(podmanTest.MakeOptions(nil, false, false), " ")
Copy link
Member

Choose a reason for hiding this comment

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

Do we have to worry about options containing a white space, should we escape the options?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I don't know, because I've never spent much time in the e2e tests and don't have a sense for what the test options are. Let's see what CI has to say.

@edsantiago edsantiago force-pushed the registry_sanitize branch from 14899e8 to 175f29f Compare July 7, 2022 12:16
@edsantiago edsantiago marked this pull request as draft July 7, 2022 12:16
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 7, 2022
@edsantiago
Copy link
Member Author

Marking as draft because this is getting way beyond the original scope -- I'm playing with new images due to the missing-runc bug, and that is proving to be a mess.

@edsantiago
Copy link
Member Author

Update: criu seems to be broken in f35 and ubuntu. 1minutetip is down, so I can't investigate.

manifest_test:authenticated_push() is the final test left to
fix before merging containers#14397. The reason it's failing _seems_ to be
that podman is running with a mix of netavark and CNI, and
that _seems_ to be because this test invokes hack/podman-registry
which invokes plain podman without whatever options used in e2e.

Starting a registry directly from the test is insane: there is
no reusable code for doing that (see login_logout_test.go and
push_test.go. Yeesh.)

Solution: set $PODMAN, by inspecting the podmanTest object
which includes both a path and a list of options. podman-registry
will invoke that. (It will also override --root and --runroot.
This is the desired behavior).

Also: add cleanup. If auth-push test fails, stop the registry.

Also: add a sanity check to podman-registry script, have it
wait for the registry port to activate. Die if it doesn't.
That could've saved us a nice bit of debugging time.

Signed-off-by: Ed Santiago <[email protected]>
@edsantiago edsantiago force-pushed the registry_sanitize branch from 175f29f to 1161e8b Compare July 7, 2022 20:03
@edsantiago edsantiago marked this pull request as ready for review July 7, 2022 21:40
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 7, 2022
@edsantiago
Copy link
Member Author

It is currently (temporarily) impossible to upgrade VMs, so I've rolled back that part of my changeset. It's back to just addressing the registry problem.

All int tests have passed, so this is ready for review. (The rest are running, but the only way they'll fail is if flakes).

@lsm5 once this merges, please rebase your #14397. I think this will address your remaining test failures.

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM
@Luap99 PTAL

@Luap99
Copy link
Member

Luap99 commented Jul 8, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 8, 2022
@openshift-ci openshift-ci bot merged commit a2bcf83 into containers:main Jul 8, 2022
Comment on lines +43 to +46
// if auth test fails, it will leave a registry running
if registry != nil {
_ = registry.Stop()
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the registry is state related to a single test, I’d naively expect only that test to be dealing with that, without the callers having to care:

		os.Setenv("PODMAN", podmanTest.PodmanBinary+" "+opts)
		registry, err = podmanRegistry.StartWithOptions(registryOptions)
		Expect(err).To(BeNil())
		defer func() {
			err := registry.Stop()
			Expect(err).To(BeNil())
		}()

Same for the environment variable. Is there some non-obvious reason why that won’t work, e.g. is there a risk of the test process crashing and not having a chance to run the defer? If so, it would be nice to add a comment. (Or is this a general practice of the e2e tests not to rely on defer, which everyone understands and I’m just unaware of the convention?)

Copy link
Member Author

Choose a reason for hiding this comment

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

I see plenty of defer()s under test/e2e. The reason I didn't use it is that I'm not a seasoned Go programmer, and completely forgot about it. Thank you, I will submit a new PR (Monday) to address this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In that case, it’s just a small low-priority cleanup — the code as is works just fine.

@edsantiago edsantiago deleted the registry_sanitize branch July 8, 2022 12:12
edsantiago added a commit to edsantiago/libpod that referenced this pull request Jul 8, 2022
Followup to containers#14845: use defer(), not fragile global context,
to stop registry and clean up temporary envariable. Thanks
to mitr for the suggestion.

Signed-off-by: Ed Santiago <[email protected]>
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/cleanup Categorizes issue or PR as related to cleanup. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants