err="rpc error: code = Unavailable desc = error reading from server: EOF" - shell

I am trying to create ubuntu in an Oracle VM VirtualBox using terraform this is main.tf:
erraform {
required_providers {
virtualbox = {
source = "shekeriev/virtualbox"
version = "0.0.4"
}
}
}
resource "virtualbox_vm" "vm1" {
count = 2
name = format("node-%02d", count.index + 1)
image = "https://app.vagrantup.com/ubuntu/boxes/bionic64/versions/20180903.0.0/providers/virtualbox.box"
cpus = 2
memory = "512 mib"
# user_data = file("${path.module}/user_data")
network_adapter {
type = "bridge"
# device = "IntelPro1000MTDesktop"
# host_interface = "vboxnet1"
# On Windows use this instead
host_interface = "VirtualBox Host-Only Ethernet Adapter"
}
output "IPAddress" {
value = element(virtualbox_vm.vm1.*.network_adapter.0.ipv4_address, 1)
}
but it keep giving me the following error:
│ Error: can't set up VM properties: exit status 1
│
│ with virtualbox_vm.vm1[0],
│ on main.tf line 15, in resource "virtualbox_vm" "vm1":
│ 15: resource "virtualbox_vm" "vm1" {
│
╵
╷
│ Error: can't set up VM properties: exit status 1
│
│ with virtualbox_vm.vm1[1],
│ on main.tf line 15, in resource "virtualbox_vm" "vm1":
│ 15: resource "virtualbox_vm" "vm1" {
│
╵
2023-02-07T17:06:10.579+0100 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info
2023-02-07T17:06:10.580+0100 [TRACE] statemgr.Filesystem: unlocked by closing terraform.tfstate
2023-02-07T17:06:10.581+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2023-02-07T17:06:10.591+0100 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/shekeriev/virtualbox/0.0.4/windows_amd64/terraform-provider-virtualbox.exe pid=28956
2023-02-07T17:06:10.591+0100 [DEBUG] provider: plugin exited
the virtualboxes appears in the VirtualBox Manager with the operating system: Other/Unknown

Related

Vagrant on Windows 10: Cannot find variable with the name 'AmsiContext'

As currently cannot answer this -> Powershell: Cannot find a variable with the name 'AmsiContext'
The issue can be fixed temporarily by changing (assuming you have PowerShell 5 or higher):
C:\HashiCorp\Vagrant\embedded\gems\2.2.19\gems\vagrant-2.2.19\lib\vagrant\util\powershell.rb
# Returns the version of PowerShell that is installed.
#
# #return [String]
def self.version
if !defined?(#_powershell_version)
command = [
executable,
"-NoLogo",
"-NoProfile",
"-NonInteractive",
"-ExecutionPolicy", "Bypass",
"-Command",
"Write-Output $PSVersionTable.PSVersion.Major"
].flatten
version = nil
timeout = ENV["VAGRANT_POWERSHELL_VERSION_DETECTION_TIMEOUT"].to_i
if timeout < 1
timeout = DEFAULT_VERSION_DETECTION_TIMEOUT
end
begin
r = Subprocess.execute(*command,
notify: [:stdout, :stderr],
timeout: timeout,
) {|io_name,data| version = data}
rescue Vagrant::Util::Subprocess::TimeoutExceeded
LOGGER.debug("Timeout exceeded while attempting to determine version of Powershell.")
end
#_powershell_version = 5
#version
end
#_powershell_version
end

make proto in micro project throws error Expected "{" in windows 10

Starting with micro and everything works fine. I dont have VisualStudio, but instead I have make through chocolatey(dont know if could be the issue)
I bootstrap the service with micro new like this.
λ micro new my.test
Creating service my.test
.
├── micro.mu
├── main.go
├── generate.go
├── handler
│   └── my.test.go
├── proto
│   └── my.test.proto
├── Dockerfile
├── Makefile
├── README.md
├── .gitignore
└── go.mod
download protoc zip packages (protoc-$VERSION-$PLATFORM.zip) and install:
visit https://github.com/protocolbuffers/protobuf/releases
download protobuf for micro:
go get -u github.com/golang/protobuf/proto
go get -u github.com/golang/protobuf/protoc-gen-go
go get github.com/micro/micro/v3/cmd/protoc-gen-micro
compile the proto file my.test.proto:
cd my.test
make proto
Installed dependencies and everything was fine. Then I moved to my.test and after make proto this error shows up
protoc --proto_path=. --micro_out=. --go_out=:. proto/proto.test.proto
proto/proto.test.proto:7:14: Expected "{".
make: *** [Makefile:16: proto] Error 1
I have all dependencies and my PATH is fine, but I dnt know what the problem is.
Edit: This is my proto, conveniently generated by micro
syntax = "proto3";
package proto.test;
option go_package = "./proto;proto.test";
service Proto.Test {
rpc Call(Request) returns (Response) {}
rpc Stream(StreamingRequest) returns (stream StreamingResponse) {}
rpc PingPong(stream Ping) returns (stream Pong) {}
}
message Message {
string say = 1;
}
message Request {
string name = 1;
}
message Response {
string msg = 1;
}
message StreamingRequest {
int64 count = 1;
}
message StreamingResponse {
int64 count = 1;
}
message Ping {
int64 stroke = 1;
}
message Pong {
int64 stroke = 1;
}
Go package names cannot contain dots - it will just not compile:
$ cat pkg.go
package dot.test
$ go build
./pkg.go:1:12: syntax error: unexpected .
so one has to ensure generated code produces a valid Go package name.
From the Go spec, the package clause is defined as:
A package clause begins each source file and defines the package to
which the file belongs.
PackageClause = "package" PackageName .
PackageName = identifier .
and an identifier as:
... a sequence of one or more letters and digits. The first
character in an identifier must be a letter.
identifier = letter { letter | unicode_digit } .
After some reading of the basics I found the problem. Even if the proto file is generated by micro this code service Proto.Test at line seven is the problem, because of the dot. I mean, replacing that for service Test solved the issue. Now I dont know why. Any explanation would be preciated. I am in windows by the way

Julia - How to cat UnitRanges and prevent bad type performance

For a variable i I have two UnitRanges 1:i-1 and i+1:n and I want only one UnitRange that would be their concatenation. My current workaround is doing vcat(1:i-1, i+1:n) but it will result an Array{Int} instead of a UnitRange{Int}.
This will finally gives red performance type with #code_warntype in the next minimal example:
using Gurobi, JuMP
function minimal_example()
milp = Model(() -> Gurobi.Optimizer())
#variable(milp, x[i=1:n, j=vcat(1:i-1, i+1:n)], Bin)
end
#code_warntype minimal_example()
Type performance result:
Variables
#self#::Core.Compiler.Const(minimal_example, false)
#9::var"#9#13"
#10::var"#10#14"{Model}
#11::var"#11#15"
#12::var"#12#16"
milp::Model
##1226::JuMP.Containers.SparseAxisArray
x::JuMP.Containers.SparseAxisArray
Body::JuMP.Containers.SparseAxisArray
1 ─ (#9 = %new(Main.:(var"#9#13")))
│ %2 = #9::Core.Compiler.Const(var"#9#13"(), false)
│ (milp = Main.Model(%2))
│ JuMP._valid_model(milp, :milp)
│ JuMP._error_if_cannot_register(milp, :x)
│ %6 = JuMP.Containers.container::Core.Compiler.Const(JuMP.Containers.container, false)
│ %7 = Main.:(var"#10#14")::Core.Compiler.Const(var"#10#14", false)
│ %8 = Core.typeof(milp)::Core.Compiler.Const(Model, false)
│ %9 = Core.apply_type(%7, %8)::Core.Compiler.Const(var"#10#14"{Model}, false)
│ (#10 = %new(%9, milp))
│ %11 = #10::var"#10#14"{Model}
│ %12 = JuMP.Containers.nested::Core.Compiler.Const(JuMP.Containers.nested, false)
│ (#11 = %new(Main.:(var"#11#15")))
│ %14 = #11::Core.Compiler.Const(var"#11#15"(), false)
│ (#12 = %new(Main.:(var"#12#16")))
│ %16 = #12::Core.Compiler.Const(var"#12#16"(), false)
│ %17 = (%12)(%14, %16)::Core.Compiler.Const(JuMP.Containers.NestedIterator{Tuple{var"#11#15",var"#12#16"},JuMP.Containers.var"#20#22"}((var"#11#15"(), var"#12#16"()), JuMP.Containers.var"#20#22"()), false)
│ (##1226 = (%6)(%11, %17))
│ %19 = JuMP.object_dictionary(milp)::Dict{Symbol,Any}
│ %20 = ##1226::JuMP.Containers.SparseAxisArray
│ Base.setindex!(%19, %20, :x)
│ (x = ##1226)
│ %23 = ##1226::JuMP.Containers.SparseAxisArray
└── return %23
I have search Julia's document page on UnitRanges but couldn't find where it is told how should I cat them.
I tried other ways such as
#variable(milp, x[i=1:n, j=[j for j in 1:n if i!=j]], Bin)
#variable(milp, x[i=1:n, j=UnitRange(vcat(1:i-1, i+1:n))], Bin)
without success.
I guess this should work (no more red in #code_warntype)
function minimal_example(n)
milp = Model()
x = Array{VariableRef}(undef, n, n)
for i in 1:n
x[i, 1:i-1] = #variable(milp, [1:i-1], Bin)
x[i, i+1:n] = #variable(milp, [i+1:n], Bin)
end
x
end
you should really test different options and see what's best in YOUR case
A UnitRange is defined exclusively by its start and endpoints. You are proposing a range that would skip one of the numbers inside the range. So, clearly, the result cannot be a UnitRange, nor even a StepRange.
I am not aware of any standard library range that does this, so you may have to create your own custom SkipRange (or some other, appropriate, name.)

Orderer connection refused Hyperledger Fabric

I am trying to run the fabric-sample with tls settings removed.
The networks and all containers are running good without any errors but when I , try to run the channel creation command from cli, it is unable to connect to orderer container.
CLI Definition:-
version: '2'
services:
cli:
container_name: cli
image: hyperledger/fabric-tools:latest
tty: true
stdin_open: true
environment:
- GOPATH=/opt/gotpath
- CORE_VM_ENDPOINT=unix:///host/var/run/docker.sock
- FABRIC_LOGGING_SPEC=INFO
- CORE_PEER_ID=cli
- CORE_PEER_ADDRESS=peer0.org1.example.com:7051
- CORE_PEER_LOCALMSPID=Org1MSP
- CORE_PEER_TLS_ENABLED=false
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peerOrganizations/org1.example.com/users/Admin#org1.example.com/msp
working_dir: /opt/gopath/src/github.com/hyperledger/fabric/peer
command: /bin/bash
volumes:
- /var/run/:/host/var/run
- ../../chaincode/:/opt/gopath/src/github.com/hyperledger/fabric/peer/chaincode/
- ../../chaincode-advanced/:/opt/gopath/src/github.com/hyperledger/fabric/peer/chaincode-advanced/
- ../crypto-config:/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/
- ../scripts:/opt/gopath/src/github.com/hyperledger/fabric/peer/scripts/
- ../channel-artifacts:/opt/gopath/src/github.com/hyperledger/fabric/peer/channel-artifacts
Orderer Definition:-
version: '2'
services:
orderer-base:
image: hyperledger/fabric-orderer:latest
environment:
- FABRIC_LOGGING_SPEC=INFO
- ORDERER_GENERAL_LISTENADDRESS:0.0.0.0
- ORDERER_GENERAL_GENESISMETHOD=file
- ORDERE_GENERAL_GENESISFILE=/var/hyperledger/orderer/orderer.genesis.block
- ORDERER_GENERAL_LOCALMSPID=OrdererMSP
- ORDERER_GENERAL_LOCALMSPDIR=/var/hyperledger/orderer/msp
- ORDERER_GENERAL_TLS_ENABLED=false
working_dir: /opt/gopath/src/github.com/hyperledger/fabric
command: orderer
Command failing to execute-
peer channel create -o orderer.example.com:7050 -c byfn-fabric-channel -f ./channel-artifacts/channel.tx
Error:-
root#b7a8ed102a7b:/opt/gopath/src/github.com/hyperledger/fabric/peer# peer channel create -o orderer.example.com:7050 -c byfn-fabric-channel -f ./channel-artifacts/channel.tx
Error: failed to create deliver client: orderer client failed to connect to orderer.example.com:7050: failed to create new connection: connection error: desc = "transport: error while dialing: dial tcp 172.21.0.2:7050: connect: connection refused"
Since TLS if off, certificates configuration should not be problem.Although cli container is able to ping orderer container.
But orderer on port 7050 is refusing connection, eventhough services on that port is running inside orderer.
Orderer Logs:-
2020-02-14 00:10:28.164 UTC [localconfig] completeInitialization -> INFO 001 Kafka.Version unset, setting to 0.10.2.0
2020-02-14 00:10:28.175 UTC [orderer.common.server] prettyPrintStruct -> INFO 002 Orderer config values:
General.LedgerType = "file"
General.ListenAddress = "127.0.0.1"
General.ListenPort = 7050
General.TLS.Enabled = false
General.TLS.PrivateKey = "/etc/hyperledger/fabric/tls/server.key"
General.TLS.Certificate = "/etc/hyperledger/fabric/tls/server.crt"
General.TLS.RootCAs = [/etc/hyperledger/fabric/tls/ca.crt]
General.TLS.ClientAuthRequired = false
General.TLS.ClientRootCAs = []
General.Cluster.ListenAddress = ""
General.Cluster.ListenPort = 0
General.Cluster.ServerCertificate = ""
General.Cluster.ServerPrivateKey = ""
General.Cluster.ClientCertificate = ""
General.Cluster.ClientPrivateKey = ""
General.Cluster.RootCAs = []
General.Cluster.DialTimeout = 5s
General.Cluster.RPCTimeout = 7s
General.Cluster.ReplicationBufferSize = 20971520
General.Cluster.ReplicationPullTimeout = 5s
General.Cluster.ReplicationRetryTimeout = 5s
General.Cluster.ReplicationBackgroundRefreshInterval = 5m0s
General.Cluster.ReplicationMaxRetries = 12
General.Cluster.SendBufferSize = 10
General.Cluster.CertExpirationWarningThreshold = 168h0m0s
General.Cluster.TLSHandshakeTimeShift = 0s
General.Keepalive.ServerMinInterval = 1m0s
General.Keepalive.ServerInterval = 2h0m0s
General.Keepalive.ServerTimeout = 20s
General.ConnectionTimeout = 0s
General.GenesisMethod = "file"
General.GenesisProfile = "SampleInsecureSolo"
General.SystemChannel = "test-system-channel-name"
General.GenesisFile = "/var/hyperledger/orderer/orderer.genesis.block"
General.Profile.Enabled = false
General.Profile.Address = "0.0.0.0:6060"
General.LocalMSPDir = "/var/hyperledger/orderer/msp"
General.LocalMSPID = "OrdererMSP"
General.BCCSP.ProviderName = "SW"
General.BCCSP.SwOpts.SecLevel = 256
General.BCCSP.SwOpts.HashFamily = "SHA2"
General.BCCSP.SwOpts.Ephemeral = false
General.BCCSP.SwOpts.FileKeystore.KeyStorePath = "/var/hyperledger/orderer/msp/keystore"
General.BCCSP.SwOpts.DummyKeystore =
General.BCCSP.SwOpts.InmemKeystore =
General.BCCSP.PluginOpts =
General.Authentication.TimeWindow = 15m0s
General.Authentication.NoExpirationChecks = false
FileLedger.Location = "/var/hyperledger/production/orderer"
FileLedger.Prefix = "hyperledger-fabric-ordererledger"
RAMLedger.HistorySize = 1000
Kafka.Retry.ShortInterval = 5s
Kafka.Retry.ShortTotal = 10m0s
Kafka.Retry.LongInterval = 5m0s
Kafka.Retry.LongTotal = 12h0m0s
Kafka.Retry.NetworkTimeouts.DialTimeout = 10s
Kafka.Retry.NetworkTimeouts.ReadTimeout = 10s
Kafka.Retry.NetworkTimeouts.WriteTimeout = 10s
Kafka.Retry.Metadata.RetryMax = 3
Kafka.Retry.Metadata.RetryBackoff = 250ms
Kafka.Retry.Producer.RetryMax = 3
Kafka.Retry.Producer.RetryBackoff = 100ms
Kafka.Retry.Consumer.RetryBackoff = 2s
Kafka.Verbose = false
Kafka.Version = 0.10.2.0
Kafka.TLS.Enabled = false
Kafka.TLS.PrivateKey = ""
Kafka.TLS.Certificate = ""
Kafka.TLS.RootCAs = []
Kafka.TLS.ClientAuthRequired = false
Kafka.TLS.ClientRootCAs = []
Kafka.SASLPlain.Enabled = false
Kafka.SASLPlain.User = ""
Kafka.SASLPlain.Password = ""
Kafka.Topic.ReplicationFactor = 3
Debug.BroadcastTraceDir = ""
Debug.DeliverTraceDir = ""
Consensus = map[SnapDir:/var/hyperledger/production/orderer/etcdraft/snapshot WALDir:/var/hyperledger/production/orderer/etcdraft/wal]
Operations.ListenAddress = "127.0.0.1:8443"
Operations.TLS.Enabled = false
Operations.TLS.PrivateKey = ""
Operations.TLS.Certificate = ""
Operations.TLS.RootCAs = []
Operations.TLS.ClientAuthRequired = false
Operations.TLS.ClientRootCAs = []
Metrics.Provider = "disabled"
Metrics.Statsd.Network = "udp"
Metrics.Statsd.Address = "127.0.0.1:8125"
Metrics.Statsd.WriteInterval = 30s
Metrics.Statsd.Prefix = ""
2020-02-14 00:10:28.392 UTC [orderer.common.server] extractSysChanLastConfig -> INFO 003 Bootstrapping because no existing channels
2020-02-14 00:10:28.402 UTC [fsblkstorage] newBlockfileMgr -> INFO 004 Getting block information from block storage
2020-02-14 00:10:28.598 UTC [orderer.commmon.multichannel] Initialize -> INFO 005 Starting system channel 'byfn-sys-channel' with genesis block hash 46b45898fb2fadca600c5b423af9806a284c0d3c253917eca860c35b55935428 and orderer type solo
2020-02-14 00:10:28.598 UTC [orderer.common.server] Start -> INFO 006 Starting orderer:
Version: 1.4.4
Commit SHA: 7917a40
Go version: go1.12.12
OS/Arch: linux/amd64
2020-02-14 00:10:28.599 UTC [orderer.common.server] Start -> INFO 007 Beginning to serve requests

Gradle: How to copy a list of absolute paths into a single directory

In Gradle, I'm trying to copy a list of absolute paths into a single directory, but I want to keep the last component of the absolute path as a subfolder of the destination directory.
Currently I have:
def copyTask = tasks.create(name: "copyFolders", type: Copy, overwrite: true) {
from ["/sources/a-1/first", "/sources/a-3/b-1/c-1/second"]
into "/destination"
}
but this results in the files contained in /sources/foo/bar and /sources/one/two/three/path being copied into /destination. Instead, I want /destination to contain both bar and path folders (with their contents inside them).
It should be able to handle this case correctly:
sources
├── a-1
│   └── fist
│   └── lorem.txt
| └── subfolder
│   └── lorem2.txt
├── a-2
│   └── fist-b
│   └── lorem.txt
| └── subfolder
│   └── lorem2.txt
└── a-3
└── b-1
└── c-1
└── second
└── ipsum.log
->
destination
├── first
│   └── lorem.txt
│   └── subfolder
│   └── lorem2.txt
└── path
└── ipsum.log
Based on #szymon answer I got:
def copyTask = tasks.create(name: "copyToDestDir", type: Copy, overwrite: true) {
includeEmptyDirs = false
def fromDir = "/sources"
def sourcePaths = ["/sources/a-1/first", "/sources/a-3/b-1/c-1/second"]
from fileTree(fromDir).dir.listFiles()
eachFile { copySpec ->
def shouldBeCopied = false
sourcePaths.find {
if (copySpec.getFile().getCanonicalPath().startsWith(it)) {
shouldBeCopied = true
return true // break iteration
}
}
if (shouldBeCopied) {
String[] parts = file.path.split('/')
copySpec.path = parts.size() > 1 ? "${parts[parts.size() - 2]}/${parts[parts.size() - 1]}" : parts[0]
} else {
copySpec.exclude()
}
}
into destDir
}
but this wrongly results in:
destination
├── first
│   └── lorem.txt
└── subfolder
│   └── lorem2.txt
└── path
└── ipsum.log
How to achieve this?
Try following Gradle task:
task copyFiles(type: Copy, overwrite: true) {
includeEmptyDirs = false
from fileTree("sources").dir.listFiles()
eachFile { file ->
String[] parts = file.path.split('/')
file.path = parts.size() > 1 ? "${parts[parts.size() - 2]}/${parts[parts.size() - 1]}" : parts[0]
}
into "destDir"
}
The whole part happens in eachFile {} closure where we specify a target file.path - I used this imperative approach, but it can be replaced with fancy regex that keeps last folder and file name and replaces all other parts with empty string (I tried to come up with such regex but I failed).
How it works
My input directory looks like this:
sources
├── foo
│   └── bar
│   └── lorem.txt
└── one
└── two
└── three
└── path
└── ipsum.log
I run a task:
#: ./gradlew copyFiles
:copyFiles UP-TO-DATE
BUILD SUCCESSFUL
And the destDir looks like this:
destDir
├── bar
│   └── lorem.txt
└── path
└── ipsum.log
Tested with Gradle 2.14.1, 3.5-rc-2 and 4.2.1
I've finally solved this doing this. Note that the top level into directive is needed or it won't work, and the nested into directives are relative to the top-level one.
def copyTask = tasks.create(name: "copyToDestDir", type: Copy, overwrite: true) {
includeEmptyDirs = false
def fromDir = "/sources"
def sourcePaths = ["/sources/a-1/first", "/sources/a-3/b-1/c-1/second"]
def destDir = "/destination"
sourcePaths.each { sourcePath ->
from(sourcePath) {
into sourcePath.substring(sourcePath.lastIndexOf('/') + 1)
}
}
into destDir
dependsOn cleanUpDestDir
}
Thanks to #SzymonStepniak for the inspiration.

Resources