Skip to content

Change the type of CRI runtime option #5300

Merged
mikebrow merged 1 commit intocontainerd:masterfrom
adisky:fix-toml
Apr 8, 2021
Merged

Change the type of CRI runtime option #5300
mikebrow merged 1 commit intocontainerd:masterfrom
adisky:fix-toml

Conversation

@adisky
Copy link
Copy Markdown
Contributor

@adisky adisky commented Apr 1, 2021

Trying to fix the issue in which runtime options does not get printed in crictl info.
Added separate field for runtime options in status response.

Update the type of Options *toml.Tree to Options *toml.Tree map[string]interface{}. This is correctly marshalling the options in CRI status response.

Ref Issue: kubernetes-sigs/cri-tools#728

@k8s-ci-robot
Copy link
Copy Markdown

Hi @adisky. Thanks for your PR.

I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@adisky
Copy link
Copy Markdown
Contributor Author

adisky commented Apr 1, 2021

cc @dims @mikebrow

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Apr 1, 2021

Build succeeded.

@kzys
Copy link
Copy Markdown
Member

kzys commented Apr 1, 2021

@adisky Please rebase your branch against master, instead of merging commits from there.

@adisky adisky changed the title Add runtime options in CRI Status response [WIP] Add runtime options in CRI Status response Apr 1, 2021
@adisky
Copy link
Copy Markdown
Contributor Author

adisky commented Apr 1, 2021

@kzys It is based on the PR #5278 once it gets merged, I'll rebase my PR

@dmcgowan
Copy link
Copy Markdown
Member

dmcgowan commented Apr 2, 2021

Its merged now

@adisky
Copy link
Copy Markdown
Contributor Author

adisky commented Apr 2, 2021

@dmcgowan @kzys Updated!!!

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Apr 2, 2021

Build succeeded.

Copy link
Copy Markdown
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

LGTM hit the wrong button..

Copy link
Copy Markdown
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

let's move this loop down to sometime after the rest.Info make on line 72 below.. otherwise it will panic..

and possibly consider substituting the options in response.Info["config"]

      "runtimes": {
        "runc": {
          "runtimeType": "io.containerd.runc.v2",
          "runtimeEngine": "",
          "PodAnnotations": null,
          "ContainerAnnotations": null,
          "runtimeRoot": "",
          "options": {},
          "privileged_without_host_devices": false,
          "baseRuntimeSpec": ""
        }
      },

after moving the loop down here was my full output:

sudo crictl info
{
  "status": {
    "conditions": [
      {
        "type": "RuntimeReady",
        "status": true,
        "reason": "",
        "message": ""
      },
      {
        "type": "NetworkReady",
        "status": true,
        "reason": "",
        "message": ""
      }
    ]
  },
  "cniconfig": {
    "PluginDirs": [
      "/opt/cni/bin"
    ],
    "PluginConfDir": "/etc/cni/net.d",
    "PluginMaxConfNum": 1,
    "Prefix": "eth",
    "Networks": [
      {
        "Config": {
          "Name": "cni-loopback",
          "CNIVersion": "0.3.1",
          "Plugins": [
            {
              "Network": {
                "type": "loopback",
                "ipam": {},
                "dns": {}
              },
              "Source": "{\"type\":\"loopback\"}"
            }
          ],
          "Source": "{\n\"cniVersion\": \"0.3.1\",\n\"name\": \"cni-loopback\",\n\"plugins\": [{\n  \"type\": \"loopback\"\n}]\n}"
        },
        "IFName": "lo"
      },
      {
        "Config": {
          "Name": "containerd-net",
          "CNIVersion": "0.4.0",
          "Plugins": [
            {
              "Network": {
                "type": "bridge",
                "ipam": {
                  "type": "host-local"
                },
                "dns": {}
              },
              "Source": "{\"bridge\":\"cni0\",\"ipMasq\":true,\"ipam\":{\"ranges\":[[{\"subnet\":\"10.88.0.0/16\"}],[{\"subnet\":\"2001:4860:4860::/64\"}]],\"routes\":[{\"dst\":\"0.0.0.0/0\"},{\"dst\":\"::/0\"}],\"type\":\"host-local\"},\"isGateway\":true,\"promiscMode\":true,\"type\":\"bridge\"}"
            },
            {
              "Network": {
                "type": "portmap",
                "capabilities": {
                  "portMappings": true
                },
                "ipam": {},
                "dns": {}
              },
              "Source": "{\"capabilities\":{\"portMappings\":true},\"type\":\"portmap\"}"
            }
          ],
          "Source": "{\n  \"cniVersion\": \"0.4.0\",\n  \"name\": \"containerd-net\",\n  \"plugins\": [\n    {\n      \"type\": \"bridge\",\n      \"bridge\": \"cni0\",\n      \"isGateway\": true,\n      \"ipMasq\": true,\n      \"promiscMode\": true,\n      \"ipam\": {\n        \"type\": \"host-local\",\n        \"ranges\": [\n          [{\n            \"subnet\": \"10.88.0.0/16\"\n          }],\n          [{\n            \"subnet\": \"2001:4860:4860::/64\"\n          }]\n        ],\n        \"routes\": [\n          { \"dst\": \"0.0.0.0/0\" },\n          { \"dst\": \"::/0\" }\n        ]\n      }\n    },\n    {\n      \"type\": \"portmap\",\n      \"capabilities\": {\"portMappings\": true}\n    }\n  ]\n}\n"
        },
        "IFName": "eth0"
      }
    ]
  },
  "config": {
    "containerd": {
      "snapshotter": "overlayfs",
      "defaultRuntimeName": "runc",
      "defaultRuntime": {
        "runtimeType": "",
        "runtimeEngine": "",
        "PodAnnotations": null,
        "ContainerAnnotations": null,
        "runtimeRoot": "",
        "options": null,
        "privileged_without_host_devices": false,
        "baseRuntimeSpec": ""
      },
      "untrustedWorkloadRuntime": {
        "runtimeType": "",
        "runtimeEngine": "",
        "PodAnnotations": null,
        "ContainerAnnotations": null,
        "runtimeRoot": "",
        "options": null,
        "privileged_without_host_devices": false,
        "baseRuntimeSpec": ""
      },
      "runtimes": {
        "runc": {
          "runtimeType": "io.containerd.runc.v2",
          "runtimeEngine": "",
          "PodAnnotations": null,
          "ContainerAnnotations": null,
          "runtimeRoot": "",
          "options": {},
          "privileged_without_host_devices": false,
          "baseRuntimeSpec": ""
        }
      },
      "noPivot": false,
      "disableSnapshotAnnotations": false,
      "discardUnpackedLayers": false
    },
    "cni": {
      "binDir": "/opt/cni/bin",
      "confDir": "/etc/cni/net.d",
      "maxConfNum": 1,
      "confTemplate": ""
    },
    "registry": {
      "configPath": "",
      "mirrors": {
        "docker.io": {
          "endpoint": [
            "https://registry-1.docker.io"
          ]
        }
      },
      "configs": null,
      "auths": null,
      "headers": null
    },
    "imageDecryption": {
      "keyModel": ""
    },
    "disableTCPService": true,
    "streamServerAddress": "127.0.0.1",
    "streamServerPort": "0",
    "streamIdleTimeout": "4h0m0s",
    "enableSelinux": false,
    "selinuxCategoryRange": 1024,
    "sandboxImage": "k8s.gcr.io/pause:3.2",
    "statsCollectPeriod": 10,
    "systemdCgroup": false,
    "enableTLSStreaming": false,
    "x509KeyPairStreaming": {
      "tlsCertFile": "",
      "tlsKeyFile": ""
    },
    "maxContainerLogSize": 16384,
    "disableCgroup": false,
    "disableApparmor": false,
    "restrictOOMScoreAdj": false,
    "maxConcurrentDownloads": 3,
    "disableProcMount": false,
    "unsetSeccompProfile": "",
    "tolerateMissingHugetlbController": true,
    "disableHugetlbController": true,
    "ignoreImageDefinedVolumes": false,
    "netnsMountsUnderStateDir": false,
    "containerdRootDir": "/var/lib/containerd",
    "containerdEndpoint": "/run/containerd/containerd.sock",
    "rootDir": "/var/lib/containerd/io.containerd.grpc.v1.cri",
    "stateDir": "/run/containerd/io.containerd.grpc.v1.cri"
  },
  "golang": "go1.15.5",
  "lastCNILoadStatus": "OK",
  "runcOptions": {
    "SystemdCgroup": false
  }
}

@mikebrow
Copy link
Copy Markdown
Member

mikebrow commented Apr 2, 2021

the other reported ci issues look to be well known ..

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Apr 4, 2021

Build succeeded.

@adisky adisky changed the title [WIP] Add runtime options in CRI Status response Change the type of CRI runtime option Apr 4, 2021
@adisky
Copy link
Copy Markdown
Contributor Author

adisky commented Apr 4, 2021

@mikebrow Thanks for the review, I tried changing the approach here. I updated the runtime options field to map[string]interface{} and where ever we require it as toml.Tree we can convert it using toml.TreeFromMap(). This way it is generating complete output for options while marshalling it from go to json and CRI status response is complete.

crictl info output with this PR (only runtimes output shown here)

  "runtimes": {
        "runc": {
          "runtimeType": "io.containerd.runc.v2",
          "runtimeEngine": "",
          "PodAnnotations": null,
          "ContainerAnnotations": null,
          "runtimeRoot": "",
          "options": {
            "SystemdCgroup": true
          },
          "privileged_without_host_devices": false,
          "baseRuntimeSpec": ""
        }

Copy link
Copy Markdown
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

LGTM
Given:t

// Tree is the result of the parsing of a TOML file.
type Tree struct {
	values    map[string]interface{} // string -> *tomlValue, *Tree, []*Tree
...

This seems to be a workable approach :-)
@mxpv thoughts?

@mxpv
Copy link
Copy Markdown
Member

mxpv commented Apr 5, 2021

I'd add a comment to explain the motivation of this intermediate step.
Other than that LGTM on green.

@adisky adisky force-pushed the fix-toml branch 4 times, most recently from 3446911 to 2dea684 Compare April 6, 2021 08:42
@adisky
Copy link
Copy Markdown
Contributor Author

adisky commented Apr 6, 2021

@mxpv @mikebrow Addressed review comments.

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Apr 6, 2021

Build succeeded.

Copy link
Copy Markdown
Member

@mikebrow mikebrow left a comment

Choose a reason for hiding this comment

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

LGTM
please rebase... to pick up the fixes to cri test

Changing Runtime.Options type to map[string]interface{}
to correctly marshal it from go to JSON.
See issue: kubernetes-sigs/cri-tools#728

Signed-off-by: Aditi Sharma <[email protected]>
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Apr 8, 2021

Build succeeded.

@adisky
Copy link
Copy Markdown
Contributor Author

adisky commented Apr 8, 2021

LGTM
please rebase... to pick up the fixes to cri test

Done!!!

@oldthreefeng
Copy link
Copy Markdown

nice work!!!

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.

7 participants