Skip to content

Do Not Review #8538

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 0 additions & 51 deletions cmd/vic-machine/common/syslog.go

This file was deleted.

27 changes: 0 additions & 27 deletions cmd/vic-machine/common/syslog_test.go

This file was deleted.

18 changes: 3 additions & 15 deletions cmd/vic-machine/configure/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ type Configure struct {

executor *management.Dispatcher

Force bool
help common.Help
Syslog common.Syslog
Force bool
help common.Help
}

func NewConfigure() *Configure {
Expand Down Expand Up @@ -109,11 +108,10 @@ func (c *Configure) Flags() []cli.Flag {
help := c.help.HelpFlags()
squota := c.VCHStorageQuotaFlag()
cvms := c.VCHContainerCountFlag()
syslog := c.Syslog.SyslogFlags()

// flag arrays are declared, now combined
var flags []cli.Flag
for _, f := range [][]cli.Flag{target, ops, id, compute, affinity, container, volume, dns, cNetwork, memory, cpu, squota, cvms, certificates, registries, proxies, syslog, util, debug, help} {
for _, f := range [][]cli.Flag{target, ops, id, compute, affinity, container, volume, dns, cNetwork, memory, cpu, squota, cvms, certificates, registries, proxies, util, debug, help} {
flags = append(flags, f...)
}

Expand Down Expand Up @@ -163,12 +161,6 @@ func (c *Configure) processParams(op trace.Operation) error {
}
c.Data.RegistryCAs = c.registries.RegistryCAs

if u, err := c.Syslog.ProcessSyslog(); err == nil {
c.SyslogConfig.Addr = u
} else {
return err
}

return nil
}

Expand Down Expand Up @@ -269,10 +261,6 @@ func (c *Configure) copyChangedConf(o *config.VirtualContainerHostConfigSpec, n
o.RegistryCertificateAuthorities = n.RegistryCertificateAuthorities
}

if c.SyslogConfig.Addr != nil {
o.Diagnostics.SysLogConfig = n.Diagnostics.SysLogConfig
}

o.UseVMGroup = n.UseVMGroup

if n.VMGroupName != "" {
Expand Down
31 changes: 26 additions & 5 deletions cmd/vic-machine/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type Create struct {

Proxies common.Proxies

Syslog common.Syslog
SyslogAddr string

executor *management.Dispatcher
}
Expand Down Expand Up @@ -252,6 +252,16 @@ func (c *Create) Flags() []cli.Flag {
Usage: "Specify a list of permitted whitelist registry server addresses (insecure addresses still require the --insecure-registry option in addition)",
})

syslog := []cli.Flag{
cli.StringFlag{
Name: "syslog-address",
Value: "",
Usage: "Address of the syslog server to send Virtual Container Host logs to. Must be in the format transport://host[:port], where transport is udp or tcp. port defaults to 514 if not specified",
Destination: &c.SyslogAddr,
Hidden: true,
},
}

util := []cli.Flag{
// miscellaneous
cli.BoolFlag{
Expand Down Expand Up @@ -287,7 +297,6 @@ func (c *Create) Flags() []cli.Flag {
help := c.help.HelpFlags()
squota := c.VCHStorageQuotaFlag()
cvms := c.VCHContainerCountFlag()
syslog := c.Syslog.SyslogFlags()

// flag arrays are declared, now combined
var flags []cli.Flag
Expand Down Expand Up @@ -382,9 +391,7 @@ func (c *Create) ProcessParams(op trace.Operation) error {
c.HTTPSProxy = sproxy
c.NoProxy = nproxy

if u, err := c.Syslog.ProcessSyslog(); err == nil {
c.SyslogConfig.Addr = u
} else {
if err = c.ProcessSyslog(); err != nil {
return err
}

Expand Down Expand Up @@ -521,6 +528,20 @@ func (c *Create) ProcessNetwork(op trace.Operation, network *data.NetworkConfig,
return nil
}

func (c *Create) ProcessSyslog() error {
if len(c.SyslogAddr) == 0 {
return nil
}

u, err := url.Parse(c.SyslogAddr)
if err != nil {
return err
}

c.SyslogConfig.Addr = u
return nil
}

func (c *Create) logArguments(op trace.Operation, cliContext *cli.Context) []string {
args := []string{}
sf := c.SetFields() // StringSlice options set by the user
Expand Down
7 changes: 7 additions & 0 deletions cmd/vic-machine/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,10 @@ func TestSetFields(t *testing.T) {
option := c.SetFields()
assert.NotNil(t, option)
}

func TestProcessSysLog(t *testing.T) {
c := NewCreate()
c.SyslogAddr = ""
r := c.ProcessSyslog()
assert.Nil(t, r, "Should be nil, SyslogAddr is empty")
}
6 changes: 2 additions & 4 deletions lib/apiservers/service/restapi/handlers/vch_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,8 @@ func (h *vchCreate) buildCreate(op trace.Operation, d *data.Data, finder client.
}

if vch.SyslogAddr != "" {
c.Syslog.SyslogAddr = vch.SyslogAddr.String()
if u, err := c.Syslog.ProcessSyslog(); err == nil {
c.SyslogConfig.Addr = u
} else {
c.SyslogAddr = vch.SyslogAddr.String()
if err := c.ProcessSyslog(); err != nil {
return nil, errors.NewError(http.StatusBadRequest, "error processing syslog server address: %s", err)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func newCreate() *create.Create {
InsecureRegistriesArg: cli.StringSlice{"https://insecure.example.com"},
WhitelistRegistriesArg: cli.StringSlice{"10.0.0.0/8"},
}
ca.Syslog = common.Syslog{"tcp://syslog.example.com:4444"}
ca.SyslogAddr = "tcp://syslog.example.com:4444"
ca.ContainerNameConvention = "container-{id}"
ca.Certs.CertPath = "test-vch"
ca.Certs.NoSaveToDisk = true
Expand All @@ -226,9 +226,6 @@ func compare(a, b reflect.Value, index int) (err error) {
case reflect.Interface:
return compare(a.Elem(), b.Elem(), index)
case reflect.Struct:
if a.Type().Field(0).Name == "SyslogAddr" {
return nil
}
for i := 0; i < a.NumField(); i++ {
if err = compare(a.Field(i), b.Field(i), i); err != nil {
fmt.Printf("Field name a: %s, b: %s, index: %d\n", a.Type().Field(i).Name, b.Type().Field(i).Name, i)
Expand Down
2 changes: 0 additions & 2 deletions lib/install/data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,6 @@ func (d *Data) CopyNonEmpty(src *Data) error {

d.RegistryCAs = src.RegistryCAs

d.SyslogConfig = src.SyslogConfig

d.ContainerConfig.ContainerNameConvention = src.ContainerConfig.ContainerNameConvention

return nil
Expand Down
24 changes: 4 additions & 20 deletions tests/test-cases/Group6-VIC-Machine/6-15-Syslog.robot
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*** Settings ***
Documentation Test 6-15 - Verify remote syslog
Resource ../../resources/Util.robot
Test Teardown Cleanup VIC Appliance On Test Server
Suite Setup Install VIC Appliance To Test Server additional-args=--syslog-address tcp://%{SYSLOG_SERVER}:514 --debug 1
Suite Teardown Cleanup VIC Appliance On Test Server
Test Timeout 20 minutes

*** Variables ***
Expand All @@ -31,6 +32,7 @@ Get Remote PID
Should Not Be Empty ${pid}
[Return] ${pid}

*** Test Cases ***
Verify VCH remote syslog
# enable ssh
${output}= Run bin/vic-machine-linux debug --name=%{VCH-NAME} --target=%{TEST_URL} --thumbprint=%{TEST_THUMBPRINT} --user=%{TEST_USERNAME} --password=%{TEST_PASSWORD}
Expand Down Expand Up @@ -96,27 +98,9 @@ Verify VCH remote syslog

# Check trace logger for docker-engine and port-layer
Should Match Regexp ${out} ${vch-ip} docker-engine-server\\[${pid}\\]: op=${pid}.\\d+: Commit container \\w{64}
#Should Match Regexp ${out} ${vch-ip} port-layer-server\\[${port-layer-pid}\\]: op=${port-layer-pid}.\\d+: Creating base file structure on disk
Should Match Regexp ${out} ${vch-ip} port-layer-server\\[${port-layer-pid}\\]: op=${port-layer-pid}.\\d+: Creating base file structure on disk
Should Match Regexp ${out} ${vch-ip} vicadmin\\[${vic-admin-pid}\\]: op=${vic-admin-pid}.\\d+: vSphere resource cache populating...

Should Match Regexp ${out} ${shortID} ${shortID}\\[1\\]: bin
Should Match Regexp ${out} ${shortID} ${shortID}\\[1\\]: home
Should Match Regexp ${out} ${shortID} ${shortID}\\[1\\]: var


*** Test Cases ***
Verify VCH Create remote syslog

Install VIC Appliance To Test Server certs=${false} additional-args=--syslog-address tcp://%{SYSLOG_SERVER}:514 --debug 1

Verify VCH remote syslog

Verify VCH Configure remote syslog

Install VIC Appliance To Test Server certs=${false} additional-args=--debug 1

${rc} ${output}= Run And Return Rc And Output bin/vic-machine-linux configure --target %{TEST_URL} --user %{TEST_USERNAME} --password=%{TEST_PASSWORD} --compute-resource=%{TEST_RESOURCE} --name %{VCH-NAME} --syslog-address tcp://%{SYSLOG_SERVER}:514 --thumbprint=%{TEST_THUMBPRINT} --debug 1
Should Be Equal As Integers ${rc} 0
Should Contain ${output} Completed successfully

Verify VCH remote syslog