Skip to content

Commit da9786d

Browse files
committed
Revert "Add --syslog to vic-machine configure (#8512)"
This reverts commit 1d749af.
1 parent d168824 commit da9786d

File tree

9 files changed

+43
-128
lines changed

9 files changed

+43
-128
lines changed

cmd/vic-machine/common/syslog.go

Lines changed: 0 additions & 51 deletions
This file was deleted.

cmd/vic-machine/common/syslog_test.go

Lines changed: 0 additions & 27 deletions
This file was deleted.

cmd/vic-machine/configure/configure.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ type Configure struct {
5252

5353
executor *management.Dispatcher
5454

55-
Force bool
56-
help common.Help
57-
Syslog common.Syslog
55+
Force bool
56+
help common.Help
5857
}
5958

6059
func NewConfigure() *Configure {
@@ -109,11 +108,10 @@ func (c *Configure) Flags() []cli.Flag {
109108
help := c.help.HelpFlags()
110109
squota := c.VCHStorageQuotaFlag()
111110
cvms := c.VCHContainerCountFlag()
112-
syslog := c.Syslog.SyslogFlags()
113111

114112
// flag arrays are declared, now combined
115113
var flags []cli.Flag
116-
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} {
114+
for _, f := range [][]cli.Flag{target, ops, id, compute, affinity, container, volume, dns, cNetwork, memory, cpu, squota, cvms, certificates, registries, proxies, util, debug, help} {
117115
flags = append(flags, f...)
118116
}
119117

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

166-
if u, err := c.Syslog.ProcessSyslog(); err == nil {
167-
c.SyslogConfig.Addr = u
168-
} else {
169-
return err
170-
}
171-
172164
return nil
173165
}
174166

@@ -269,10 +261,6 @@ func (c *Configure) copyChangedConf(o *config.VirtualContainerHostConfigSpec, n
269261
o.RegistryCertificateAuthorities = n.RegistryCertificateAuthorities
270262
}
271263

272-
if c.SyslogConfig.Addr != nil {
273-
o.Diagnostics.SysLogConfig = n.Diagnostics.SysLogConfig
274-
}
275-
276264
o.UseVMGroup = n.UseVMGroup
277265

278266
if n.VMGroupName != "" {

cmd/vic-machine/create/create.go

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ type Create struct {
6767

6868
Proxies common.Proxies
6969

70-
Syslog common.Syslog
70+
SyslogAddr string
7171

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

255+
syslog := []cli.Flag{
256+
cli.StringFlag{
257+
Name: "syslog-address",
258+
Value: "",
259+
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",
260+
Destination: &c.SyslogAddr,
261+
Hidden: true,
262+
},
263+
}
264+
255265
util := []cli.Flag{
256266
// miscellaneous
257267
cli.BoolFlag{
@@ -287,7 +297,6 @@ func (c *Create) Flags() []cli.Flag {
287297
help := c.help.HelpFlags()
288298
squota := c.VCHStorageQuotaFlag()
289299
cvms := c.VCHContainerCountFlag()
290-
syslog := c.Syslog.SyslogFlags()
291300

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

385-
if u, err := c.Syslog.ProcessSyslog(); err == nil {
386-
c.SyslogConfig.Addr = u
387-
} else {
394+
if err = c.ProcessSyslog(); err != nil {
388395
return err
389396
}
390397

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

531+
func (c *Create) ProcessSyslog() error {
532+
if len(c.SyslogAddr) == 0 {
533+
return nil
534+
}
535+
536+
u, err := url.Parse(c.SyslogAddr)
537+
if err != nil {
538+
return err
539+
}
540+
541+
c.SyslogConfig.Addr = u
542+
return nil
543+
}
544+
524545
func (c *Create) logArguments(op trace.Operation, cliContext *cli.Context) []string {
525546
args := []string{}
526547
sf := c.SetFields() // StringSlice options set by the user

cmd/vic-machine/create/create_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,10 @@ func TestSetFields(t *testing.T) {
9999
option := c.SetFields()
100100
assert.NotNil(t, option)
101101
}
102+
103+
func TestProcessSysLog(t *testing.T) {
104+
c := NewCreate()
105+
c.SyslogAddr = ""
106+
r := c.ProcessSyslog()
107+
assert.Nil(t, r, "Should be nil, SyslogAddr is empty")
108+
}

lib/apiservers/service/restapi/handlers/vch_create.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,8 @@ func (h *vchCreate) buildCreate(op trace.Operation, d *data.Data, finder client.
424424
}
425425

426426
if vch.SyslogAddr != "" {
427-
c.Syslog.SyslogAddr = vch.SyslogAddr.String()
428-
if u, err := c.Syslog.ProcessSyslog(); err == nil {
429-
c.SyslogConfig.Addr = u
430-
} else {
427+
c.SyslogAddr = vch.SyslogAddr.String()
428+
if err := c.ProcessSyslog(); err != nil {
431429
return nil, errors.NewError(http.StatusBadRequest, "error processing syslog server address: %s", err)
432430
}
433431
}

lib/apiservers/service/restapi/handlers/vch_create_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func newCreate() *create.Create {
204204
InsecureRegistriesArg: cli.StringSlice{"https://insecure.example.com"},
205205
WhitelistRegistriesArg: cli.StringSlice{"10.0.0.0/8"},
206206
}
207-
ca.Syslog = common.Syslog{"tcp://syslog.example.com:4444"}
207+
ca.SyslogAddr = "tcp://syslog.example.com:4444"
208208
ca.ContainerNameConvention = "container-{id}"
209209
ca.Certs.CertPath = "test-vch"
210210
ca.Certs.NoSaveToDisk = true
@@ -226,9 +226,6 @@ func compare(a, b reflect.Value, index int) (err error) {
226226
case reflect.Interface:
227227
return compare(a.Elem(), b.Elem(), index)
228228
case reflect.Struct:
229-
if a.Type().Field(0).Name == "SyslogAddr" {
230-
return nil
231-
}
232229
for i := 0; i < a.NumField(); i++ {
233230
if err = compare(a.Field(i), b.Field(i), i); err != nil {
234231
fmt.Printf("Field name a: %s, b: %s, index: %d\n", a.Type().Field(i).Name, b.Type().Field(i).Name, i)

lib/install/data/data.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,6 @@ func (d *Data) CopyNonEmpty(src *Data) error {
373373

374374
d.RegistryCAs = src.RegistryCAs
375375

376-
d.SyslogConfig = src.SyslogConfig
377-
378376
d.ContainerConfig.ContainerNameConvention = src.ContainerConfig.ContainerNameConvention
379377

380378
return nil

tests/test-cases/Group6-VIC-Machine/6-15-Syslog.robot

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
*** Settings ***
1616
Documentation Test 6-15 - Verify remote syslog
1717
Resource ../../resources/Util.robot
18-
Test Teardown Cleanup VIC Appliance On Test Server
18+
Suite Setup Install VIC Appliance To Test Server additional-args=--syslog-address tcp://%{SYSLOG_SERVER}:514 --debug 1
19+
Suite Teardown Cleanup VIC Appliance On Test Server
1920
Test Timeout 20 minutes
2021

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

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

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

102104
Should Match Regexp ${out} ${shortID} ${shortID}\\[1\\]: bin
103105
Should Match Regexp ${out} ${shortID} ${shortID}\\[1\\]: home
104106
Should Match Regexp ${out} ${shortID} ${shortID}\\[1\\]: var
105-
106-
107-
*** Test Cases ***
108-
Verify VCH Create remote syslog
109-
110-
Install VIC Appliance To Test Server certs=${false} additional-args=--syslog-address tcp://%{SYSLOG_SERVER}:514 --debug 1
111-
112-
Verify VCH remote syslog
113-
114-
Verify VCH Configure remote syslog
115-
116-
Install VIC Appliance To Test Server certs=${false} additional-args=--debug 1
117-
118-
${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
119-
Should Be Equal As Integers ${rc} 0
120-
Should Contain ${output} Completed successfully
121-
122-
Verify VCH remote syslog

0 commit comments

Comments
 (0)