Where is the output of debug!() calls in rust - rust

Trying to understand an open source project and I have seen the following code in many places
debug!("called with params: {:?}", body); // or some parameter instead of bo
when I run cargo run I do not see any of these outputs in the console. only the INFO logs are displayed
[2022-12-19T13:53:23Z INFO actix_server::builder] Starting 8 workers
[2022-12-19T13:53:23Z INFO actix_server::server] Actix runtime found; starting in Actix runtime
[2022-12-19T14:00:58Z INFO actix_web::middleware::logger] ::1 "GET /stats HTTP/1.1" 200 49 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36" 0.009129
[2022-12-
I tried running RUST_LOG=debug cargo run. but still unable to see the debug output. as I can see the logging is configured via rust-log crate. but with my limited experience with rust I couldn't figure out more. I assume these debug logs are in some file but not sure exactly where they are.

meilisearch provides a command line option --log-level=... for users to specify the log level, which can contain any filter string that's accepted by the env_logger crate. To enable all the log::debug! outputs, supply --log-level=debug when running the binary.
# If building from source
cargo run -- --log-level=debug
# If installed
meilisearch --log-level=debug
See the documentation of env_logger for the syntax of filter strings.

Related

Packer failed when executed on Gitlab-runner

I have a packer file to deploy Centos 7 using vSphere-Iso builder that works Ok when executed directly on a linux server but when I try to run the same packer file using a gitlab-runner it fails as it does not wait until the OS is installed. It fails after waiting for 1 minute but if I run the packer command with -on-error=run-cleanup-provisioner the OS install finish succesuflly so clear the issue is that packer is just not waiting.
2021/07/20 12:02:40 packer.io plugin: [INFO] Waiting for IP, up to total timeout: 30m0s, settle timeout: 5m0s
==> vsphere-iso.autogenerated_1: Waiting for IP...
==> vsphere-iso.autogenerated_1: Clear boot order...
==> vsphere-iso.autogenerated_1: Power off VM...
==> vsphere-iso.autogenerated_1: Destroying VM...
2021/07/20 12:03:12 [INFO] (telemetry) ending
==> Wait completed after 1 minute 2 seconds
2021/07/20 12:03:12 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
My boot command is the following as I do not use DHCP.
boot_command = ["<up><tab> text inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/vmware-ks.cfg ip=10.118.12.117::10.118.12.1:255.255.255.0:{{ .Name }}.localhost:ens192:none<enter><wait>"]
I have tested using options like ssh_host, ip_wait_address, ip_settle_timeout, ssh_wait_timeout, pause_before_connecting but nothing seems to work.
As I said, the same packer pkr.hcl file works OK if run it manually on a regular linux but not on my gitlab-runner that is a runner installed directly on my Gitlab server (Yes, I know is not the best practice but I only use the runner for this task)
Packer versions 1.7.2 and 1.7.3 tested, gitlab-runner 14.0.0 and 14.0.1 tested.
Managed to make it work by changing the las wait on my boot command for wait5m. This will give the OS enough time to get installed and the VM rebooted.
New boot command boot_command = ["<up><tab> text inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/vmware-ks.cfg ip=10.118.12.117::10.118.12.1:255.255.255.0:{{ .Name }}.localhost:ens192:none<enter><wait5m>"]
All the other wait options from packer are no longer needed with this boot command.
Doing some test I managed to make it work as well by creating a Firewall drop rule for the VM just after the kickstar file was loaded and removing the FW rules once the OS was installed. Definitelly, packer is just ignoring all the wait machanism native to packer when running on the gitlab-runner
EDIT: After having the same issue with my Windows Templates y tested using a different gitlab-runner installed on a different server instead of the one in the same gitlab server and it worked perfectly with my initial contifiguration for both, windows and centos.

How to determine the OS version using pvymomi?

Using pvymomi, I can determine the OS. How does one determine the OS version?
#!/usr/bin/python3
import sys
import atexit
from pyVmomi import vim
from pyVim.connect import SmartConnectNoSSL, Disconnect
si = SmartConnectNoSSL(host = 'xxx', user = 'xxx', pwd = 'xxx', port = 443)
atexit.register(Disconnect, si)
content = si.RetrieveContent()
vm = si.content.searchIndex.FindByIp(None, sys.argv[1], True)
print(vm.summary.config.guestFullName)
print(vm.summary.config.guestId)
The above code produces the following:
$ ./example.py 10.120.73.45
CentOS 7 (64-bit)
centos7_64Guest
I can see the VM is running CentOS 7, but is it 7.6 or 7.9? I'm not seeing what property or even what data object gives that information.
After doing some research into this question, I have found that the vSphere Web Services API, which the Python package pyvmomi uses does not have an easy way to collect the exact version operating system version with a basic API call.
If you look at the vSphere Web Services API information for
guestFamily, which is in GuestInfo you will not see any API call for precise versioning information.
Additionally, to obtain the exact operating system version information for CentOS you would normally have to query the kernel, which contains this information.
You can obtain the version of CentOS using this command:
cat /etc/centos-release
# output
CentOS Linux release 7.9.2009 (Core)
You can query this information GuestProgramSpec
Here is some pseudocode for doing this.
ps = vim.vm.guest.ProcessManager.ProgramSpec(programPath="/usr/bin/cat", arguments=" /etc/centos-release > /tmp/os_version_info.txt")
res = pm.StartProgramInGuest(vm, creds, ps)
You can also obtain this information using the uname tool, which is commonly used to obtain information about the processor architecture, which as the system hostname and the version of the kernel running on the system.
Here is the command - uname -s -r
-s, (--kernel-name) - Prints the kernel name
-r, (--kernel-release) - Prints the kernel release.
Here is a website that provides some information on mapping the kernel releases information to a specific operating system. Here is another website. Using the latter website I can see that kernel-3.10.0-1160.el7.x86_64 maps to CentOS 7.9.2009 for x86_64.
Here is some pseudocode for doing this.
ps = vim.vm.guest.ProcessManager.ProgramSpec(programPath="/usr/bin/uname", arguments=" -s -r > /tmp/os_kernel_info.txt")
res = pm.StartProgramInGuest(vm, creds, ps)
Based on my research getting this information back to the console is more complex. Here is a Stack Overflow question in how to do this.
UPDATE
I discovered this sample pyvmomi script, which can execute a command and retrieve the content back to the console.
Execute program in a virtual machine

Selenium, VBA - ERR_PROXY_CONNECTION_FAILED with chromedriver update 86.0.4240.111

It's been working fine until the latest chrome update. As usual I downloaded the latest Chromedriver update to complement the newest release of chrome but now I'm getting the following error once it tries to open a page.
I'm using a proxy so initially I launch chrome without the proxy to ensure there is no connection without proxy, then I launch Putty and connect the proxy server. This has all worked seamlessly until this latest update.
I've included a section of my code below:
Public Driver As New WebDriver
Set Driver = New ChromeDriver
Driver.SetProfile Sheets("Settings").Range("B52").Value
Driver.AddArgument ("--proxy-server=socks5://localhost:1194")
'Set download directory
Driver.SetPreference "download.default_directory", Sheets("Settings").Range("B44").Value
Driver.Get "https://www.google.co.uk/", timeout:=none ', False
If Driver.FindElementsByXPath("//*[contains(text(),'The proxy server is refusing connections')]").Count Or Driver.FindElementsByXPath("//*[contains(text(),'There is something wrong with the proxy server')]").Count Then
Open_Putty_and_Connect_to_Host_Network
end if
Error occurs at driver.get
Full Error Message:
Run_time error '13':
UnknownError
unknown error: net::ERR_PROXY_CONNECTION_FAILED
(Session info: chrome=86.0.4240.111)
(Driver info: chromedriver=86.0.4240.22)
(398b0743353ff36fb1b82468f63a3a93b4e2e89e-refs/branch-heads/424
NT 10.0.18362 x86_64)
I've been looking online and what I can see I need to pass an argument to the chrome driver but I'm not sure how to or what I need to pass to it.
The code will run beyond this point normally and connect to the proxy and perform it's standard function but I can't understand why this error is occurring or how to fix it. Any help would be greatly appreciated!

get chrome app console logs in chrome os debug log

I've got a chrome app with several isolated layers (webviews, iframes), all those layers are logging some debugging stuff to console with console.log().
I managed to get all console logs inside a chrome debug log when launching chrome on mac os with --enable-logging --v=1 flags.
The problem is I can't get all the console.logs when running the app in chrome os. For chrome os debugging I wrote the following into /etc/chrome_dev.conf file:
CHROME_LOG_FILE=/tmp/chrome_debug.log
--enable-logging --v=1
So I expect pretty much the same logs as I get when running chrome app on mac os, but I do not see any console.logs in /tmp/chrome_debug.log.
Would appreciate any advice how to get my app console.logs in chrome debug log on chrome os
Please read the comments in the /etc/chrome_dev.conf file, particularly this one at the top:
# This file may be modified to make local changes to the environment and command
# line that session_manager uses to run Chrome. It contains one directive per
# line, with the following forms available:
That means your --enable-logging --v=1 is incorrect because you put two options on one line instead of one option per line.

Running protractor tests on IE 11

OK, so I have been searching a lot to get proper solution to the blocker I am facing right now. Let me give you a background of what I have done so far :
I want to run protractor tests (located on Linux machine) on IE 11 of Windows Server 2012 R2 (IP : 10.81.73.248). My protractorTest.conf.js has below :
exports.config = {
seleniumAddress: 'http://10.81.73.248:4444/wd/hub',
baseURL: 'http://10.81.78.137:80000/',
capabilities: {
browserName: 'internet explorer',
platform: 'ANY',
version: '11'
},
On my Windows Server 2012 R2 machine, I've downloaded IEDriverServer_Win32_2.47.0 and placed it under C:\Windows\System32, environment variable PATH has been updated with above location. Protected mode settings are same for all zones. Windows machine also has selenium-server-standalone-2.48.2.jar placed under C:\Users\Selenium.
On Windows machine, I am starting selenium server using below command :
java -jar selenium-server-standalone-2.48.2.jar -port 4444 -Dwebdriver.ie.driver="C:\Windows\System32\IEDriverServer_Win32_2.47.0\IEDriverServer.exe" , which starts selenium server fine.
With above settings, I run protractor tests from my Linux machine using grunt protractor_test, which launches IE browser on Windows machine, shows localhost:dynamic port and a message as : This is the initial page of webdriver server and within 2 seconds, closes the browser.
The exception I get on selenium server terminal is as below :
Session ID is null. Using WebDriver after calling quit() ?
This is where I am stuck at. I looked at various posts which describes similar issue (?) as mine along with the potential solution, but I am unable to resolve my issue here.
Is there anything I might be doing wrong to setup the connections ? or am I missing some steps to get me through ?
I would really appreciate if you guide me in resolving this long time pending blocker.
I think you are trying to run using old selenium version.It should be 2.53.x something.
Few basics things to check first regarding IE execution:
1).IE Setting for protractor(Selenium)
http://elgalu.github.io/2014/run-protractor-against-internet-explorer-vm/
2).Take IE driver of 32 bit(don't take 64 it has known slowness issues) and manually copy on the following path:
Root Folder\node_modules\protractor\node_modules\webdriver-manager\selenium\IEDriverServer_Win32_2.53.1
3). IE Driver can be downloaded from following path:
http://selenium-release.storage.googleapis.com/index.html?path=2.53/
**OR**
Please upgrade your protractor version to latest like 4.0.11 by changing the version in package.json file and do from command prompt(inside project root directory):
npm update
and then give update your selenium driver with following command from command prompt
webdriver-manager update --ie
it will update the selenium version of IE driver to latest and then try running your tests again.

Resources