Skip to content

Commit 70c7b84

Browse files
committed
consistent log messages
1 parent 0c1ac2e commit 70c7b84

File tree

7 files changed

+29
-27
lines changed

7 files changed

+29
-27
lines changed

cmd/libvirt-actuator/main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ func bootstrapCommand() *cobra.Command {
282282
},
283283
}
284284

285-
glog.Infof("Collecting master kubeconfig")
285+
glog.Info("Collecting master kubeconfig")
286286
config, err := f.GetMasterMachineRestConfig(masterMachine, lcw)
287287
if err != nil {
288288
return err
@@ -399,7 +399,6 @@ func checkFlags(cmd *cobra.Command) error {
399399
func main() {
400400
err := rootCmd.Execute()
401401
if err != nil {
402-
fmt.Fprintf(os.Stderr, "Error occurred: %v\n", err)
403-
os.Exit(1)
402+
glog.Fatalf("Error occurred: %v", err)
404403
}
405404
}

cmd/manager/main.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func main() {
4444
glog.Fatal(err)
4545
}
4646

47-
glog.Infof("Registering Components.")
47+
glog.Info("Registering Components")
4848

4949
// Setup Scheme for all resources
5050
if err := apis.AddToScheme(mgr.GetScheme()); err != nil {
@@ -61,10 +61,13 @@ func main() {
6161
glog.Fatal(err)
6262
}
6363

64-
glog.Infof("Starting the Cmd.")
64+
glog.Info("Starting the Cmd")
6565

6666
// Start the Cmd
67-
glog.Fatal(mgr.Start(signals.SetupSignalHandler()))
67+
err = mgr.Start(signals.SetupSignalHandler())
68+
if err != nil {
69+
glog.Fatal(err)
70+
}
6871
}
6972

7073
func initActuator(m manager.Manager) {

pkg/cloud/libvirt/actuators/machine/actuator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func (a *Actuator) createVolumeAndDomain(machine *machinev1.Machine, machineProv
263263
// Clean up the created volume if domain creation fails,
264264
// otherwise subsequent runs will fail.
265265
if err := client.DeleteVolume(domainName); err != nil {
266-
glog.Errorf("error cleaning up volume: %v", err)
266+
glog.Errorf("Error cleaning up volume: %v", err)
267267
}
268268

269269
return nil, a.handleMachineError(machine, apierrors.CreateMachine("error creating domain %v", err), createEventAction)
@@ -373,7 +373,7 @@ func (a *Actuator) applyMachineStatus(
373373
return nil
374374
}
375375

376-
glog.Infof("Machine %s status has changed: %s", machine.Name, diff.ObjectReflectDiff(machine.Status, machineCopy.Status))
376+
glog.Infof("Machine %s status has changed: %q", machine.Name, diff.ObjectReflectDiff(machine.Status, machineCopy.Status))
377377

378378
now := metav1.Now()
379379
machineCopy.Status.LastUpdated = &now

pkg/cloud/libvirt/client/client.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func (client *libvirtClient) CreateDomain(input CreateDomainInput) error {
152152
if input.DomainName == "" {
153153
return fmt.Errorf("Failed to create domain, name is empty")
154154
}
155-
glog.Infof("Create resource libvirt_domain")
155+
glog.Info("Create resource libvirt_domain")
156156

157157
// Get default values from Host
158158
domainDef, err := newDomainDefForConnection(client.connection)
@@ -165,7 +165,7 @@ func (client *libvirtClient) CreateDomain(input CreateDomainInput) error {
165165
return fmt.Errorf("Failed to init domain definition from machineProviderConfig: %v", err)
166166
}
167167

168-
glog.Infof("setCoreOSIgnition")
168+
glog.Info("Create ignition configuration")
169169
if input.Ignition != nil {
170170
if err := setIgnition(&domainDef, client, input.Ignition, input.KubeClient, input.MachineNamespace, input.IgnitionVolumeName, input.VolumePoolName); err != nil {
171171
return err
@@ -182,13 +182,13 @@ func (client *libvirtClient) CreateDomain(input CreateDomainInput) error {
182182
return fmt.Errorf("machine does not has a IgnKey nor CloudInit value")
183183
}
184184

185-
glog.Infof("setDisks")
185+
glog.Info("Create volume")
186186
VolumeKey := baseVolumePath + input.VolumeName
187187
if err := setDisks(&domainDef, client.connection, VolumeKey); err != nil {
188188
return fmt.Errorf("Failed to setDisks: %s", err)
189189
}
190190

191-
glog.Infof("setNetworkInterfaces")
191+
glog.Info("Set up network interface")
192192
var waitForLeases []*libvirtxml.DomainInterface
193193
hostName := input.HostName
194194
if hostName == "" {
@@ -313,12 +313,12 @@ func (client *libvirtClient) DeleteDomain(name string) error {
313313

314314
if err := domain.UndefineFlags(libvirt.DOMAIN_UNDEFINE_NVRAM); err != nil {
315315
if e := err.(libvirt.Error); e.Code == libvirt.ERR_NO_SUPPORT || e.Code == libvirt.ERR_INVALID_ARG {
316-
glog.Infof("libvirt does not support undefine flags: will try again without flags")
316+
glog.Info("libvirt does not support undefine flags: will try again without flags")
317317
if err := domain.Undefine(); err != nil {
318-
return fmt.Errorf("Couldn't undefine libvirt domain: %s", err)
318+
return fmt.Errorf("couldn't undefine libvirt domain: %v", err)
319319
}
320320
} else {
321-
return fmt.Errorf("Couldn't undefine libvirt domain with flags: %s", err)
321+
return fmt.Errorf("couldn't undefine libvirt domain with flags: %v", err)
322322
}
323323
}
324324

pkg/cloud/libvirt/client/cloudinit.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func newCloudInitDef() defCloudInit {
111111
// Create the ISO holding all the cloud-init data
112112
// Returns a string with the full path to the ISO file
113113
func (ci *defCloudInit) createISO() (string, error) {
114-
glog.Infof("Creating new ISO")
114+
glog.Info("Creating new ISO")
115115
tmpDir, err := ci.createFiles()
116116
if err != nil {
117117
return "", err
@@ -132,7 +132,7 @@ func (ci *defCloudInit) createISO() (string, error) {
132132

133133
glog.Infof("About to execute cmd: %+v", cmd)
134134
if err = cmd.Run(); err != nil {
135-
return "", fmt.Errorf("Error while starting the creation of CloudInit's ISO image: %s", err)
135+
return "", fmt.Errorf("error while starting the creation of CloudInit's ISO image: %s", err)
136136
}
137137
glog.Infof("ISO created at %s", isoDestination)
138138

@@ -143,7 +143,7 @@ func (ci *defCloudInit) createISO() (string, error) {
143143
// Returns a string containing the name of the temporary directory and an error
144144
// object
145145
func (ci *defCloudInit) createFiles() (string, error) {
146-
glog.Infof("Creating ISO contents")
146+
glog.Info("Creating ISO contents")
147147
tmpDir, err := ioutil.TempDir("", "cloudinit")
148148
if err != nil {
149149
return "", fmt.Errorf("Cannot create tmp directory for cloudinit ISO generation: %s",
@@ -162,7 +162,7 @@ func (ci *defCloudInit) createFiles() (string, error) {
162162
return "", fmt.Errorf("Error while writing network-config to file: %s", err)
163163
}
164164

165-
glog.Infof("ISO contents created")
165+
glog.Info("ISO contents created")
166166

167167
return tmpDir, nil
168168
}

pkg/cloud/libvirt/client/domain.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func getHostCapabilities(virConn *libvirt.Connect) (libvirtxml.Caps, error) {
147147

148148
func getGuestForArchType(caps libvirtxml.Caps, arch string, virttype string) (libvirtxml.CapsGuest, error) {
149149
for _, guest := range caps.Guests {
150-
glog.Infof("Checking for %s/%s against %s/%s\n", arch, virttype, guest.Arch.Name, guest.OSType)
150+
glog.Infof("Checking for %s/%s against %s/%s", arch, virttype, guest.Arch.Name, guest.OSType)
151151
if guest.Arch.Name == arch && guest.OSType == virttype {
152152
glog.Infof("Found %d machines in guest for %s/%s", len(guest.Arch.Machines), arch, virttype)
153153
return guest, nil
@@ -157,7 +157,7 @@ func getGuestForArchType(caps libvirtxml.Caps, arch string, virttype string) (li
157157
}
158158

159159
func getCanonicalMachineName(caps libvirtxml.Caps, arch string, virttype string, targetmachine string) (string, error) {
160-
glog.Infof("getCanonicalMachineName")
160+
glog.Info("Get machine name")
161161
guest, err := getGuestForArchType(caps, arch, virttype)
162162
if err != nil {
163163
return "", err
@@ -267,18 +267,18 @@ func randomWWN(strlen int) string {
267267

268268
func setDisks(domainDef *libvirtxml.Domain, virConn *libvirt.Connect, volumeKey string) error {
269269
disk := newDefDisk(0)
270-
glog.Infof("LookupStorageVolByKey")
270+
glog.Info("Looking up storage volume by key")
271271
diskVolume, err := virConn.LookupStorageVolByKey(volumeKey)
272272
if err != nil {
273273
return fmt.Errorf("Can't retrieve volume %s", volumeKey)
274274
}
275-
glog.Infof("diskVolume")
275+
glog.Info("Getting disk volume")
276276
diskVolumeFile, err := diskVolume.GetPath()
277277
if err != nil {
278278
return fmt.Errorf("Error retrieving volume file: %s", err)
279279
}
280280

281-
glog.Infof("DomainDiskSource")
281+
glog.Info("Constructing domain disk source")
282282
disk.Source = &libvirtxml.DomainDiskSource{
283283
File: &libvirtxml.DomainDiskSourceFile{
284284
File: diskVolumeFile,
@@ -347,7 +347,7 @@ func setNetworkInterfaces(domainDef *libvirtxml.Domain,
347347
if networkInterfaceHostname != "" {
348348
hostname = networkInterfaceHostname
349349
}
350-
glog.Infof("Networkaddress %v", networkInterfaceAddress)
350+
glog.Infof("Networkaddress: %v", networkInterfaceAddress)
351351
if networkInterfaceAddress != "" {
352352
_, networkCIDR, err := net.ParseCIDR(networkInterfaceAddress)
353353
if err != nil {

pkg/cloud/libvirt/client/ignition.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
)
1919

2020
func setIgnition(domainDef *libvirtxml.Domain, client *libvirtClient, ignition *providerconfigv1.Ignition, kubeClient kubernetes.Interface, machineNamespace, volumeName, poolName string) error {
21-
glog.Infof("creating ignition file")
21+
glog.Info("Creating ignition file")
2222
ignitionDef := newIgnitionDef()
2323

2424
if ignition.UserDataSecret == "" {
@@ -38,7 +38,7 @@ func setIgnition(domainDef *libvirtxml.Domain, client *libvirtClient, ignition *
3838
ignitionDef.PoolName = poolName
3939
ignitionDef.Content = string(userDataSecret)
4040

41-
glog.Infof("ignition: %+v", ignitionDef)
41+
glog.Infof("Ignition: %+v", ignitionDef)
4242

4343
ignitionVolumeName, err := ignitionDef.createAndUpload(client)
4444
if err != nil {

0 commit comments

Comments
 (0)