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

libnetwork: add NetworkInfo() for get network information #1460

Merged
merged 1 commit into from
May 16, 2023

Conversation

sstosh
Copy link
Contributor

@sstosh sstosh commented May 10, 2023

NetworkInfo() return the network binary path,
package version and program version.

Related to containers/podman#18383

@sstosh sstosh force-pushed the networkinfo branch 2 times, most recently from 1c77e5f to f241567 Compare May 10, 2023 05:05
Copy link
Collaborator

@flouthoc flouthoc left a comment

Choose a reason for hiding this comment

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

LGTM

libnetwork/types/network.go Outdated Show resolved Hide resolved
libnetwork/cni/network.go Outdated Show resolved Hide resolved
pkg/util/util.go Outdated Show resolved Hide resolved
@sstosh
Copy link
Contributor Author

sstosh commented May 15, 2023

podman info prints the network information as shown below:

  networkBackendInfo:
    backend: cni
    dns:
      package: podman-plugins-4.5.0-1.fc37.x86_64
      path: /usr/libexec/cni/dnsname
    package: |-
      containernetworking-plugins-1.1.1-8.fc37.x86_64
      podman-plugins-4.5.0-1.fc37.x86_64
    path: /usr/libexec/cni
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.6.0-1.fc37.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.6.0
    package: netavark-1.6.0-2.fc37.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 1.6.0

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.

mostly looks good just some minor comments

libnetwork/cni/network.go Outdated Show resolved Hide resolved

dnsPath := filepath.Join(path, "dnsname")
dnsPackage := cutil.PackageVersion(dnsPath)
if _, err := os.Stat(dnsPath); err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

At least for dnsname you can get the version from the binary as well:

$ /usr/libexec/cni/dnsname --version
CNI dnsname plugin
version: 1.3.1
commit: unknown

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add a wrapper function ProgramVersionDnsname() to get the dnsname information.
AFAICS, dnsname --version returns the information to stdErr.

# /usr/libexec/cni/dnsname --version > /dev/null
CNI dnsname plugin
version: 1.3.1
commit: unknown

# /usr/libexec/cni/dnsname > /dev/null
CNI dnsname plugin
version: 1.3.1
commit: unknown


# /usr/libexec/cni/dnsname --version 2> /dev/null

# /usr/libexec/cni/dnsname 2> /dev/null

libnetwork/cni/network.go Outdated Show resolved Hide resolved
libnetwork/netavark/network.go Outdated Show resolved Hide resolved
libnetwork/netavark/network.go Outdated Show resolved Hide resolved
libnetwork/netavark/network.go Outdated Show resolved Hide resolved
pkg/util/util.go Show resolved Hide resolved
@sstosh
Copy link
Contributor Author

sstosh commented May 16, 2023

podman info prints the network information as shown below:

  networkBackendInfo:
    backend: cni
    dns:
      package: podman-plugins-4.5.0-1.fc37.x86_64
      path: /usr/libexec/cni/dnsname
      version: |-
        CNI dnsname plugin
        version: 1.3.1
        commit: unknown
    package: |-
      containernetworking-plugins-1.1.1-8.fc37.x86_64
      podman-plugins-4.5.0-1.fc37.x86_64
    path: /usr/libexec/cni
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.6.0-1.fc37.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.6.0
    package: netavark-1.6.0-2.fc37.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 1.6.0

@sstosh sstosh force-pushed the networkinfo branch 3 times, most recently from dd7d770 to 6595ffb Compare May 16, 2023 05:19
NetworkInfo() return the network binary path, package version,
program version and DNS information.

Signed-off-by: Toshiki Sonoda <[email protected]>
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

@rhatdan
Copy link
Member

rhatdan commented May 16, 2023

/approve
/lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 16, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, Luap99, rhatdan, sstosh

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-robot openshift-merge-robot merged commit 51d4c4b into containers:main May 16, 2023
@sstosh sstosh deleted the networkinfo branch May 16, 2023 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants