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

quadlet: fix inter-dependency of containers in Network= #24794

Merged

Conversation

ruihe774
Copy link
Contributor

@ruihe774 ruihe774 commented Dec 7, 2024

This PR fixes a bug introduced by #23814.

Unlike network quadlet units, which are sorted before container quadlet units so that the ResourceName of which are guaranteed to be present when used in addNetworks(), there is no guaranteed resolving order between containers. As a result, ResourceName of a container when used in addNetworks() may be empty because the container is not resolved (i.e. ConventContainer() is not called for it) yet.

This PR fixes this by adding special handling to resolve the resource name in addNetworks() for containers.

@ygalblum PTAL

Fix a bug that when reusing another container's network in Quadlet, an error of "cannot get the resource name" may appear.

@openshift-ci openshift-ci bot added the do-not-merge/release-note-label-needed Enforce release-note requirement, even if just None label Dec 7, 2024
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@rhatdan
Copy link
Member

rhatdan commented Dec 9, 2024

@Luap99 PTAL

@rhatdan
Copy link
Member

rhatdan commented Dec 9, 2024

You have lint errors.

@mheon
Copy link
Member

mheon commented Dec 9, 2024

LGTM

@ruihe774 ruihe774 force-pushed the fix-quadlet-container-network branch from 5b511ec to a419adc Compare December 10, 2024 05:55
@ruihe774
Copy link
Contributor Author

You have lint errors.

Sorry. Fixed.

@openshift-ci openshift-ci bot added release-note and removed do-not-merge/release-note-label-needed Enforce release-note requirement, even if just None labels Dec 10, 2024
@ruihe774 ruihe774 force-pushed the fix-quadlet-container-network branch from a419adc to ecf9b0a Compare December 10, 2024 06:31
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

Tests are failing

pkg/systemd/quadlet/quadlet.go Outdated Show resolved Hide resolved
@ygalblum
Copy link
Contributor

ygalblum commented Dec 10, 2024

Instead of addressing this only when needed, the way to address this issue is the same as we did for .build units. That is get the resource name before actually processing the units. This is handled as part of the generateUnitsInfoMap method in cmd/quadlet/main.go (

func generateUnitsInfoMap(units []*parser.UnitFile) map[string]*quadlet.UnitInfo {
).

Copy link
Contributor

@ygalblum ygalblum left a comment

Choose a reason for hiding this comment

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

As mentioned, this is not the way to address this issue. I mark is as "Request Changes" to make sure it is not merged

@ruihe774
Copy link
Contributor Author

Instead of addressing this only when needed, the way to address this issue is the same as we did for .build units. That is get the resource name before actually processing the units. This is handled as part of the generateUnitsInfoMap method in cmd/quadlet/main.go (

func generateUnitsInfoMap(units []*parser.UnitFile) map[string]*quadlet.UnitInfo {

).

Thanks for pointing this out. I'll rework this PR.

@ruihe774 ruihe774 force-pushed the fix-quadlet-container-network branch from ecf9b0a to cf505fe Compare December 11, 2024 00:37
@ruihe774 ruihe774 requested review from Luap99 and ygalblum December 11, 2024 01:26
@ruihe774
Copy link
Contributor Author

ruihe774 commented Dec 11, 2024

I have no idea why two tasks have failed.

Copy link
Contributor

@ygalblum ygalblum left a comment

Choose a reason for hiding this comment

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

LGTM

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 11, 2024
@ygalblum
Copy link
Contributor

I have no idea why two tasks have failed.

Not sure either, I've rerun the failed ones

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Dec 11, 2024
Copy link
Contributor

openshift-ci bot commented Dec 11, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Luap99, ruihe774, ygalblum

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-merge-bot openshift-merge-bot bot merged commit b60df61 into containers:main Dec 11, 2024
80 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants