From 5d93aa1cebd0597ac55e50c9773ebd4f05826406 Mon Sep 17 00:00:00 2001 From: 10240987 Date: Thu, 9 Aug 2018 19:35:51 +0800 Subject: [PATCH] adapt: support configurable stream-port to virtlet server instead of default 10010 view: modify corresponding doc file. UTest: modify UTest output file. view: modify the location of pakcage, system package should be in front of other packages. view: modify location of package that "st" shoud be above "sy" view: rollback glide.lock file which glide tool lead to. --- docs/config.md | 1 + docs/virtletctl/virtletctl_diag_sonobuoy.md | 3 ++- images/image_skel/start.sh | 2 +- pkg/api/virtlet.k8s/v1/virtletconfig.go | 2 ++ pkg/api/virtlet.k8s/v1/zz_generated.deepcopy.go | 9 +++++++++ pkg/config/TestConfigForNode__global_mapping.out.yaml | 1 + .../TestConfigForNode__mapping_by_node_labels.out.yaml | 1 + ...igForNode__mapping_by_node_labels__no_match_.out.yaml | 1 + .../TestConfigForNode__mapping_by_node_name.out.yaml | 1 + ...nfigForNode__mapping_by_node_name__no_match_.out.yaml | 1 + ...de__mapping_by_node_name_and_multiple_labels.out.yaml | 1 + ..._name_and_multiple_labels_and_a_local_config.out.yaml | 1 + pkg/config/TestConfigForNode__no_mappings.out.yaml | 1 + pkg/config/TestDefaultVirtletConfig.out.yaml | 1 + pkg/config/TestGenerateDoc.out.txt | 1 + pkg/config/TestGetCRDDefinitions.out.yaml | 4 ++++ pkg/config/TestLoadMappings.out.yaml | 1 + ...gs__all_cli_opts_and_explicit_default_config.out.yaml | 1 + ...all_cli_opts_and_explicit_default_config__env.out.txt | 1 + ...nfigs__defaults__explicitly_set_as_a_config_.out.yaml | 1 + ...s__defaults__explicitly_set_as_a_config___env.out.txt | 1 + pkg/config/config.go | 4 ++++ pkg/manager/manager.go | 2 +- pkg/stream/server.go | 5 +++-- pkg/tools/TestGenCommand__compat.out.yaml | 4 ++++ pkg/tools/TestGenCommand__compat_dev.out.yaml | 4 ++++ pkg/tools/TestGenCommand__crd.out.yaml | 4 ++++ pkg/tools/TestGenCommand__dev.out.yaml | 4 ++++ pkg/tools/TestGenCommand__plain.out.yaml | 4 ++++ pkg/tools/TestGenCommand__tag.out.yaml | 4 ++++ pkg/tools/TestGenDocForConfig.out.txt | 1 + 31 files changed, 67 insertions(+), 5 deletions(-) diff --git a/docs/config.md b/docs/config.md index 7215fdc80..2c6277540 100644 --- a/docs/config.md +++ b/docs/config.md @@ -93,6 +93,7 @@ standard Virtlet deployment YAML as generated by `virtletctl gen`. | Calico subnet size to use | `calicoSubnetSize` | `24` | integer | `--calico-subnet-size` / `VIRTLET_CALICO_SUBNET` | | Enable regexp image name translation | `enableRegexpImageTranslation` | `true` | boolean | `--enable-regexp-image-translation` / `IMAGE_REGEXP_TRANSLATION` | | CPU model to use in libvirt domain definition (libvirt's default value will be used if not set) | `cpuModel` | | string | `--cpu-model` / `VIRTLET_CPU_MODEL` | +| configurable port to the virtlet server | `streamPort` | `10010` | integer | `--stream-port` / `VIRTLET_STREAM_PORT` | | Log level to use | `logLevel` | `1` | integer | `--v` / `VIRTLET_LOGLEVEL` | diff --git a/docs/virtletctl/virtletctl_diag_sonobuoy.md b/docs/virtletctl/virtletctl_diag_sonobuoy.md index 917a8a19f..1adbc9ef6 100644 --- a/docs/virtletctl/virtletctl_diag_sonobuoy.md +++ b/docs/virtletctl/virtletctl_diag_sonobuoy.md @@ -13,7 +13,8 @@ virtletctl diag sonobuoy [flags] ### Options ``` - -h, --help help for sonobuoy + -h, --help help for sonobuoy + --tag string Set virtlet image tag for the plugin ``` ### Options inherited from parent commands diff --git a/images/image_skel/start.sh b/images/image_skel/start.sh index 859bd0ff2..46cf39c8e 100755 --- a/images/image_skel/start.sh +++ b/images/image_skel/start.sh @@ -21,4 +21,4 @@ verbose= if [[ ${VIRTLET_LOGLEVEL:-} ]]; then verbose="--v ${VIRTLET_LOGLEVEL}" fi -/usr/local/bin/virtlet ${verbose} +/usr/local/bin/virtlet ${verbose} $* diff --git a/pkg/api/virtlet.k8s/v1/virtletconfig.go b/pkg/api/virtlet.k8s/v1/virtletconfig.go index b8696d15b..eb8e6bf59 100644 --- a/pkg/api/virtlet.k8s/v1/virtletconfig.go +++ b/pkg/api/virtlet.k8s/v1/virtletconfig.go @@ -62,6 +62,8 @@ type VirtletConfig struct { // CPUModel specifies the default CPU model to use in the libvirt domain definition. // It can be overridden using VirtletCPUModel pod annotation. CPUModel *string `json:"cpuModel,omitempty"` + // StreamPort specifies the configurable stream port of virtlet server. + StreamPort *int `json:"streamPort,omitempty"` // LogLevel specifies the log level to use LogLevel *int `json:"logLevel,omitempty"` } diff --git a/pkg/api/virtlet.k8s/v1/zz_generated.deepcopy.go b/pkg/api/virtlet.k8s/v1/zz_generated.deepcopy.go index 6bbf71c57..8a2ff1db2 100644 --- a/pkg/api/virtlet.k8s/v1/zz_generated.deepcopy.go +++ b/pkg/api/virtlet.k8s/v1/zz_generated.deepcopy.go @@ -297,6 +297,15 @@ func (in *VirtletConfig) DeepCopyInto(out *VirtletConfig) { **out = **in } } + if in.StreamPort != nil { + in, out := &in.StreamPort, &out.StreamPort + if *in == nil { + *out = nil + } else { + *out = new(int) + **out = **in + } + } if in.LogLevel != nil { in, out := &in.LogLevel, &out.LogLevel if *in == nil { diff --git a/pkg/config/TestConfigForNode__global_mapping.out.yaml b/pkg/config/TestConfigForNode__global_mapping.out.yaml index c80049573..1c5bd121a 100755 --- a/pkg/config/TestConfigForNode__global_mapping.out.yaml +++ b/pkg/config/TestConfigForNode__global_mapping.out.yaml @@ -16,3 +16,4 @@ libvirtURI: qemu:///foobar logLevel: 3 rawDevices: sd* skipImageTranslation: false +streamPort: 10010 diff --git a/pkg/config/TestConfigForNode__mapping_by_node_labels.out.yaml b/pkg/config/TestConfigForNode__mapping_by_node_labels.out.yaml index c80049573..1c5bd121a 100755 --- a/pkg/config/TestConfigForNode__mapping_by_node_labels.out.yaml +++ b/pkg/config/TestConfigForNode__mapping_by_node_labels.out.yaml @@ -16,3 +16,4 @@ libvirtURI: qemu:///foobar logLevel: 3 rawDevices: sd* skipImageTranslation: false +streamPort: 10010 diff --git a/pkg/config/TestConfigForNode__mapping_by_node_labels__no_match_.out.yaml b/pkg/config/TestConfigForNode__mapping_by_node_labels__no_match_.out.yaml index 2c7a78169..6c55b8e83 100755 --- a/pkg/config/TestConfigForNode__mapping_by_node_labels__no_match_.out.yaml +++ b/pkg/config/TestConfigForNode__mapping_by_node_labels__no_match_.out.yaml @@ -16,3 +16,4 @@ libvirtURI: qemu:///system logLevel: 1 rawDevices: loop* skipImageTranslation: false +streamPort: 10010 diff --git a/pkg/config/TestConfigForNode__mapping_by_node_name.out.yaml b/pkg/config/TestConfigForNode__mapping_by_node_name.out.yaml index c80049573..1c5bd121a 100755 --- a/pkg/config/TestConfigForNode__mapping_by_node_name.out.yaml +++ b/pkg/config/TestConfigForNode__mapping_by_node_name.out.yaml @@ -16,3 +16,4 @@ libvirtURI: qemu:///foobar logLevel: 3 rawDevices: sd* skipImageTranslation: false +streamPort: 10010 diff --git a/pkg/config/TestConfigForNode__mapping_by_node_name__no_match_.out.yaml b/pkg/config/TestConfigForNode__mapping_by_node_name__no_match_.out.yaml index 2c7a78169..6c55b8e83 100755 --- a/pkg/config/TestConfigForNode__mapping_by_node_name__no_match_.out.yaml +++ b/pkg/config/TestConfigForNode__mapping_by_node_name__no_match_.out.yaml @@ -16,3 +16,4 @@ libvirtURI: qemu:///system logLevel: 1 rawDevices: loop* skipImageTranslation: false +streamPort: 10010 diff --git a/pkg/config/TestConfigForNode__mapping_by_node_name_and_multiple_labels.out.yaml b/pkg/config/TestConfigForNode__mapping_by_node_name_and_multiple_labels.out.yaml index 9ce0dd09d..a2aeec018 100755 --- a/pkg/config/TestConfigForNode__mapping_by_node_name_and_multiple_labels.out.yaml +++ b/pkg/config/TestConfigForNode__mapping_by_node_name_and_multiple_labels.out.yaml @@ -16,3 +16,4 @@ libvirtURI: qemu:///system logLevel: 1 rawDevices: vd* skipImageTranslation: false +streamPort: 10010 diff --git a/pkg/config/TestConfigForNode__mapping_by_node_name_and_multiple_labels_and_a_local_config.out.yaml b/pkg/config/TestConfigForNode__mapping_by_node_name_and_multiple_labels_and_a_local_config.out.yaml index 67579e2c1..aa46302e4 100755 --- a/pkg/config/TestConfigForNode__mapping_by_node_name_and_multiple_labels_and_a_local_config.out.yaml +++ b/pkg/config/TestConfigForNode__mapping_by_node_name_and_multiple_labels_and_a_local_config.out.yaml @@ -16,3 +16,4 @@ libvirtURI: qemu:///system logLevel: 1 rawDevices: vd* skipImageTranslation: false +streamPort: 10010 diff --git a/pkg/config/TestConfigForNode__no_mappings.out.yaml b/pkg/config/TestConfigForNode__no_mappings.out.yaml index 2c7a78169..6c55b8e83 100755 --- a/pkg/config/TestConfigForNode__no_mappings.out.yaml +++ b/pkg/config/TestConfigForNode__no_mappings.out.yaml @@ -16,3 +16,4 @@ libvirtURI: qemu:///system logLevel: 1 rawDevices: loop* skipImageTranslation: false +streamPort: 10010 diff --git a/pkg/config/TestDefaultVirtletConfig.out.yaml b/pkg/config/TestDefaultVirtletConfig.out.yaml index 2c7a78169..6c55b8e83 100755 --- a/pkg/config/TestDefaultVirtletConfig.out.yaml +++ b/pkg/config/TestDefaultVirtletConfig.out.yaml @@ -16,3 +16,4 @@ libvirtURI: qemu:///system logLevel: 1 rawDevices: loop* skipImageTranslation: false +streamPort: 10010 diff --git a/pkg/config/TestGenerateDoc.out.txt b/pkg/config/TestGenerateDoc.out.txt index af9f20a98..902ab9795 100755 --- a/pkg/config/TestGenerateDoc.out.txt +++ b/pkg/config/TestGenerateDoc.out.txt @@ -16,4 +16,5 @@ | Calico subnet size to use | `calicoSubnetSize` | `24` | integer | `--calico-subnet-size` / `VIRTLET_CALICO_SUBNET` | | Enable regexp image name translation | `enableRegexpImageTranslation` | `true` | boolean | `--enable-regexp-image-translation` / `IMAGE_REGEXP_TRANSLATION` | | CPU model to use in libvirt domain definition (libvirt's default value will be used if not set) | `cpuModel` | | string | `--cpu-model` / `VIRTLET_CPU_MODEL` | +| configurable port to the virtlet server | `streamPort` | `10010` | integer | `--stream-port` / `VIRTLET_STREAM_PORT` | | Log level to use | `logLevel` | `1` | integer | `--v` / `VIRTLET_LOGLEVEL` | diff --git a/pkg/config/TestGetCRDDefinitions.out.yaml b/pkg/config/TestGetCRDDefinitions.out.yaml index 2286a32f0..cd76c6ab7 100755 --- a/pkg/config/TestGetCRDDefinitions.out.yaml +++ b/pkg/config/TestGetCRDDefinitions.out.yaml @@ -84,6 +84,10 @@ type: string skipImageTranslation: type: boolean + streamPort: + maximum: 65535 + minimum: 1 + type: integer nodeName: type: string nodeSelector: diff --git a/pkg/config/TestLoadMappings.out.yaml b/pkg/config/TestLoadMappings.out.yaml index d36c893f3..7e71f4b28 100755 --- a/pkg/config/TestLoadMappings.out.yaml +++ b/pkg/config/TestLoadMappings.out.yaml @@ -16,3 +16,4 @@ libvirtURI: qemu:///system logLevel: 1 rawDevices: sd* skipImageTranslation: false +streamPort: 10010 diff --git a/pkg/config/TestMergeConfigs__all_cli_opts_and_explicit_default_config.out.yaml b/pkg/config/TestMergeConfigs__all_cli_opts_and_explicit_default_config.out.yaml index b96387260..c64735296 100755 --- a/pkg/config/TestMergeConfigs__all_cli_opts_and_explicit_default_config.out.yaml +++ b/pkg/config/TestMergeConfigs__all_cli_opts_and_explicit_default_config.out.yaml @@ -16,3 +16,4 @@ libvirtURI: qemu:///foobar logLevel: 1 rawDevices: sd* skipImageTranslation: false +streamPort: 10010 diff --git a/pkg/config/TestMergeConfigs__all_cli_opts_and_explicit_default_config__env.out.txt b/pkg/config/TestMergeConfigs__all_cli_opts_and_explicit_default_config__env.out.txt index 1c8f8f811..1503fa551 100755 --- a/pkg/config/TestMergeConfigs__all_cli_opts_and_explicit_default_config__env.out.txt +++ b/pkg/config/TestMergeConfigs__all_cli_opts_and_explicit_default_config__env.out.txt @@ -14,4 +14,5 @@ export VIRTLET_CNI_CONFIG_DIR=/some/cni/conf/dir export VIRTLET_CALICO_SUBNET=22 export IMAGE_REGEXP_TRANSLATION='' export VIRTLET_CPU_MODEL=host-model +export VIRTLET_STREAM_PORT=10010 export VIRTLET_LOGLEVEL=1 diff --git a/pkg/config/TestMergeConfigs__defaults__explicitly_set_as_a_config_.out.yaml b/pkg/config/TestMergeConfigs__defaults__explicitly_set_as_a_config_.out.yaml index 2c7a78169..6c55b8e83 100755 --- a/pkg/config/TestMergeConfigs__defaults__explicitly_set_as_a_config_.out.yaml +++ b/pkg/config/TestMergeConfigs__defaults__explicitly_set_as_a_config_.out.yaml @@ -16,3 +16,4 @@ libvirtURI: qemu:///system logLevel: 1 rawDevices: loop* skipImageTranslation: false +streamPort: 10010 diff --git a/pkg/config/TestMergeConfigs__defaults__explicitly_set_as_a_config___env.out.txt b/pkg/config/TestMergeConfigs__defaults__explicitly_set_as_a_config___env.out.txt index ad88ec123..7e31f42d0 100755 --- a/pkg/config/TestMergeConfigs__defaults__explicitly_set_as_a_config___env.out.txt +++ b/pkg/config/TestMergeConfigs__defaults__explicitly_set_as_a_config___env.out.txt @@ -14,4 +14,5 @@ export VIRTLET_CNI_CONFIG_DIR=/etc/cni/net.d export VIRTLET_CALICO_SUBNET=24 export IMAGE_REGEXP_TRANSLATION=1 export VIRTLET_CPU_MODEL='' +export VIRTLET_STREAM_PORT=10010 export VIRTLET_LOGLEVEL=1 diff --git a/pkg/config/config.go b/pkg/config/config.go index 3eb295cda..d940afae2 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -73,6 +73,9 @@ const ( defaultCPUModel = "" cpuModelEnv = "VIRTLET_CPU_MODEL" + + defaultStreamPort = 10010 + streamPortEnv = "VIRTLET_STREAM_PORT" ) func configFieldSet(c *virtlet_v1.VirtletConfig) *fieldSet { @@ -95,6 +98,7 @@ func configFieldSet(c *virtlet_v1.VirtletConfig) *fieldSet { fs.addIntField("calicoSubnetSize", "calico-subnet-size", "", "Calico subnet size to use", calicoSubnetEnv, defaultCalicoSubnet, 0, 32, &c.CalicoSubnetSize) fs.addBoolField("enableRegexpImageTranslation", "enable-regexp-image-translation", "", "Enable regexp image name translation", enableRegexpImageTranslationEnv, true, &c.EnableRegexpImageTranslation) fs.addStringField("cpuModel", "cpu-model", "", "CPU model to use in libvirt domain definition (libvirt's default value will be used if not set)", cpuModelEnv, defaultCPUModel, &c.CPUModel) + fs.addIntField("streamPort", "stream-port", "", "configurable port to the virtlet server", streamPortEnv, defaultStreamPort, 1, 65535, &c.StreamPort) // this field duplicates glog's --v, so no option for it, which is signified // by "+" here (it's only for doc) fs.addIntField("logLevel", "+v", "", "Log level to use", logLevelEnv, 1, 0, math.MaxInt32, &c.LogLevel) diff --git a/pkg/manager/manager.go b/pkg/manager/manager.go index 486408663..14730ba55 100644 --- a/pkg/manager/manager.go +++ b/pkg/manager/manager.go @@ -116,7 +116,7 @@ func (v *VirtletManager) Run() error { var streamServer StreamServer if !*v.config.DisableLogging { - s, err := stream.NewServer(streamerSocketPath, v.metadataStore) + s, err := stream.NewServer(streamerSocketPath, v.metadataStore, *v.config.StreamPort) if err != nil { return fmt.Errorf("couldn't create stream server: %v", err) } diff --git a/pkg/stream/server.go b/pkg/stream/server.go index b593331d9..0771b39da 100644 --- a/pkg/stream/server.go +++ b/pkg/stream/server.go @@ -20,6 +20,7 @@ import ( "fmt" "net" "os" + "strconv" "syscall" "github.com/Mirantis/virtlet/pkg/metadata" @@ -46,7 +47,7 @@ type Server struct { var _ streaming.Runtime = (*Server)(nil) // NewServer creates a new Server -func NewServer(socketPath string, metadataStore metadata.Store) (*Server, error) { +func NewServer(socketPath string, metadataStore metadata.Store, iStreamPort int) (*Server, error) { s := &Server{DeadlineSeconds: 10} // Prepare unix server @@ -56,7 +57,7 @@ func NewServer(socketPath string, metadataStore metadata.Store) (*Server, error) if err != nil { return nil, err } - streamPort := "10010" + streamPort := strconv.Itoa(iStreamPort) streamServerConfig := streaming.DefaultConfig streamServerConfig.Addr = net.JoinHostPort(bindAddress.String(), streamPort) diff --git a/pkg/tools/TestGenCommand__compat.out.yaml b/pkg/tools/TestGenCommand__compat.out.yaml index e606436ab..8f50c9b91 100755 --- a/pkg/tools/TestGenCommand__compat.out.yaml +++ b/pkg/tools/TestGenCommand__compat.out.yaml @@ -487,6 +487,10 @@ spec: type: string skipImageTranslation: type: boolean + streamPort: + maximum: 65535 + minimum: 1 + type: integer nodeName: type: string nodeSelector: diff --git a/pkg/tools/TestGenCommand__compat_dev.out.yaml b/pkg/tools/TestGenCommand__compat_dev.out.yaml index 0381afe1c..d5318e2ae 100755 --- a/pkg/tools/TestGenCommand__compat_dev.out.yaml +++ b/pkg/tools/TestGenCommand__compat_dev.out.yaml @@ -498,6 +498,10 @@ spec: type: string skipImageTranslation: type: boolean + streamPort: + maximum: 65535 + minimum: 1 + type: integer nodeName: type: string nodeSelector: diff --git a/pkg/tools/TestGenCommand__crd.out.yaml b/pkg/tools/TestGenCommand__crd.out.yaml index 0d2798710..a990bb197 100755 --- a/pkg/tools/TestGenCommand__crd.out.yaml +++ b/pkg/tools/TestGenCommand__crd.out.yaml @@ -82,6 +82,10 @@ spec: type: string skipImageTranslation: type: boolean + streamPort: + maximum: 65535 + minimum: 1 + type: integer nodeName: type: string nodeSelector: diff --git a/pkg/tools/TestGenCommand__dev.out.yaml b/pkg/tools/TestGenCommand__dev.out.yaml index 613ca0708..12fab120d 100755 --- a/pkg/tools/TestGenCommand__dev.out.yaml +++ b/pkg/tools/TestGenCommand__dev.out.yaml @@ -502,6 +502,10 @@ spec: type: string skipImageTranslation: type: boolean + streamPort: + maximum: 65535 + minimum: 1 + type: integer nodeName: type: string nodeSelector: diff --git a/pkg/tools/TestGenCommand__plain.out.yaml b/pkg/tools/TestGenCommand__plain.out.yaml index f20c78776..1850a6385 100755 --- a/pkg/tools/TestGenCommand__plain.out.yaml +++ b/pkg/tools/TestGenCommand__plain.out.yaml @@ -491,6 +491,10 @@ spec: type: string skipImageTranslation: type: boolean + streamPort: + maximum: 65535 + minimum: 1 + type: integer nodeName: type: string nodeSelector: diff --git a/pkg/tools/TestGenCommand__tag.out.yaml b/pkg/tools/TestGenCommand__tag.out.yaml index 581992883..0c27f85ad 100755 --- a/pkg/tools/TestGenCommand__tag.out.yaml +++ b/pkg/tools/TestGenCommand__tag.out.yaml @@ -491,6 +491,10 @@ spec: type: string skipImageTranslation: type: boolean + streamPort: + maximum: 65535 + minimum: 1 + type: integer nodeName: type: string nodeSelector: diff --git a/pkg/tools/TestGenDocForConfig.out.txt b/pkg/tools/TestGenDocForConfig.out.txt index af9f20a98..902ab9795 100755 --- a/pkg/tools/TestGenDocForConfig.out.txt +++ b/pkg/tools/TestGenDocForConfig.out.txt @@ -16,4 +16,5 @@ | Calico subnet size to use | `calicoSubnetSize` | `24` | integer | `--calico-subnet-size` / `VIRTLET_CALICO_SUBNET` | | Enable regexp image name translation | `enableRegexpImageTranslation` | `true` | boolean | `--enable-regexp-image-translation` / `IMAGE_REGEXP_TRANSLATION` | | CPU model to use in libvirt domain definition (libvirt's default value will be used if not set) | `cpuModel` | | string | `--cpu-model` / `VIRTLET_CPU_MODEL` | +| configurable port to the virtlet server | `streamPort` | `10010` | integer | `--stream-port` / `VIRTLET_STREAM_PORT` | | Log level to use | `logLevel` | `1` | integer | `--v` / `VIRTLET_LOGLEVEL` |