Skip to content

Commit

Permalink
Merge pull request #197 from dcbw/upstream-merge-2020-06-25
Browse files Browse the repository at this point in the history
Upstream merge 2020-06-25
  • Loading branch information
openshift-merge-robot committed Jun 26, 2020
2 parents d26d272 + 260b5f6 commit d41bfd4
Show file tree
Hide file tree
Showing 316 changed files with 57,934 additions and 49,090 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: ovn-docker-images

on:
push:
pull_request:
branches: [ master ]
paths: [ "dist/images/Dockerfile*"]

env:
GO_VERSION: 1.13.4

jobs:
build:
name: Build Images
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: ${{ env.GO_VERSION }}
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Set up environment
run: |
export GOPATH=$(go env GOPATH)
echo "::set-env name=GOPATH::$GOPATH"
export PATH=$GOPATH/bin:$PATH
echo "::add-path::$GOPATH/bin"
- name: Build images
make -C dist/images all

8 changes: 1 addition & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Free up disk space
run: sudo eatmydata apt-get remove --auto-remove -y aspnetcore-* dotnet-* libmono-* mono-* msbuild php-* php7* ghc-* zulu-*

- name: Set up Go
uses: actions/setup-go@v1
with:
Expand Down Expand Up @@ -53,9 +50,6 @@ jobs:
make windows
COVERALLS=1 make check
popd
pushd dist/images
if [ -n "$(git diff --stat origin/master.. | grep dist/images/Dockerfile)" ]; then make all; fi
popd
# Combine separate code coverage profiles into one
go get github.com/modocache/gover
Expand Down Expand Up @@ -129,7 +123,7 @@ jobs:
- enabled: "false"
name: "noHA"
gateway-mode: [local, shared]
needs: k8s
needs: [build, k8s]
env:
JOB_NAME: "${{ matrix.target.shard }}-${{ matrix.ha.name }}-${{ matrix.gateway-mode }}"
KIND_HA: "${{ matrix.ha.enabled }}"
Expand Down
1 change: 1 addition & 0 deletions dist/images/daemonset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ ovn_image=${image} \
ovn_hybrid_overlay_enable=${ovn_hybrid_overlay_enable} \
ovn_ssl_en=${ovn_ssl_en} \
ovn_master_count=${ovn_master_count} \
ovn_gateway_mode=${ovn_gateway_mode} \
j2 ../templates/ovnkube-master.yaml.j2 -o ../yaml/ovnkube-master.yaml

ovn_image=${image} \
Expand Down
4 changes: 3 additions & 1 deletion dist/images/ovnkube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ovn_loglevel_northd=${OVN_LOGLEVEL_NORTHD:-"-vconsole:info"}
ovn_loglevel_nb=${OVN_LOGLEVEL_NB:-"-vconsole:info"}
ovn_loglevel_sb=${OVN_LOGLEVEL_SB:-"-vconsole:info"}
ovn_loglevel_controller=${OVN_LOGLEVEL_CONTROLLER:-"-vconsole:info"}
ovn_loglevel_nbctld= ${OVN_LOGLEVEL_NBCTLD:"-vconsole:info"}
ovn_loglevel_nbctld=${OVN_LOGLEVEL_NBCTLD:-"-vconsole:info"}

ovnkubelogdir=/var/log/ovn-kubernetes

Expand Down Expand Up @@ -683,6 +683,7 @@ sb-ovsdb() {

# v3 - Runs northd on master. Does not run nb_ovsdb, and sb_ovsdb
run-ovn-northd() {
trap 'ovs-appctl -t ovn-northd exit >/dev/null 2>&1; exit 0' TERM
check_ovn_daemonset_version "3"
rm -f ${OVN_RUNDIR}/ovn-northd.pid
rm -f ${OVN_RUNDIR}/ovn-northd.*.ctl
Expand Down Expand Up @@ -927,6 +928,7 @@ cleanup-ovn-node() {

# v3 - Runs ovn-nbctl in daemon mode
run-nbctld() {
trap 'ovs-appctl -t ovn-nbctl exit >/dev/null 2>&1; exit 0' TERM
check_ovn_daemonset_version "3"
rm -f ${OVN_RUNDIR}/ovn-nbctl.pid
rm -f ${OVN_RUNDIR}/ovn-nbctl.*.ctl
Expand Down
2 changes: 2 additions & 0 deletions dist/templates/ovnkube-master.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ spec:
value: "{{ ovn_hybrid_overlay_net_cidr }}"
- name: OVN_SSL_ENABLE
value: "{{ ovn_ssl_en }}"
- name: OVN_GATEWAY_MODE
value: "{{ ovn_gateway_mode }}"
# end of container

volumes:
Expand Down
4 changes: 2 additions & 2 deletions go-controller/cmd/ovn-kube-util/app/nics-to-bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var NicsToBridgeCommand = cli.Command{
Action: func(context *cli.Context) error {
args := context.Args()
if args.Len() == 0 {
return fmt.Errorf("Please specify list of nic interfaces")
return fmt.Errorf("please specify list of nic interfaces")
}

if err := util.SetSpecificExec(kexec.New(), "ovs-vsctl"); err != nil {
Expand All @@ -43,7 +43,7 @@ var BridgesToNicCommand = cli.Command{
Action: func(context *cli.Context) error {
args := context.Args()
if args.Len() == 0 {
return fmt.Errorf("Please specify list of bridges")
return fmt.Errorf("please specify list of bridges")
}

if err := util.SetSpecificExec(kexec.New(), "ovs-vsctl"); err != nil {
Expand Down
98 changes: 45 additions & 53 deletions go-controller/cmd/ovn-kube-util/app/ovn-db-exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,6 @@ import (
kexec "k8s.io/utils/exec"
)

var metricOVNDBRaftIndex = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: metrics.MetricOvnNamespace,
Subsystem: metrics.MetricOvnSubsystemDBRaft,
Name: "log_entry_index",
Help: "The index of log entry currently exposed to clients. " +
"This value on all the instances of db should be close to " +
"each other otherwise they are said to lagging with eaxch other."},
[]string{
"db_name",
},
)

var metricOVNDBLeader = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: metrics.MetricOvnNamespace,
Subsystem: metrics.MetricOvnSubsystemDBRaft,
Name: "cluster_leader",
Help: "Identifies whether this pod is a leader for given database"},
[]string{
"db_name",
},
)

var metricOVNDBSessions = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: metrics.MetricOvnNamespace,
Subsystem: metrics.MetricOvnSubsystemDBRaft,
Expand Down Expand Up @@ -266,19 +244,15 @@ var metricDBClusterConnOutErr = prometheus.NewGaugeVec(prometheus.GaugeOpts{
},
)

func ovnDBStatusMetricsUpdater(direction, database string) {
status, err := util.GetOVNDBServerInfo(5, direction, database)
if err != nil {
klog.Errorf(err.Error())
return
}
metricOVNDBRaftIndex.WithLabelValues(database).Set(float64(status.Index))
if status.Leader {
metricOVNDBLeader.WithLabelValues(database).Set(1)
} else {
metricOVNDBLeader.WithLabelValues(database).Set(0)
}
}
var metricDBE2eTimestamp = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: metrics.MetricOvnNamespace,
Subsystem: metrics.MetricOvnSubsystemDBRaft,
Name: "e2e_timestamp",
Help: "The current e2e-timestamp value as observed in this instance of the database"},
[]string{
"db_name",
},
)

func ovnDBSizeMetricsUpdater(direction, database string) {
dbFile := fmt.Sprintf("/etc/openvswitch/ovn%s_db.db", direction)
Expand All @@ -290,6 +264,30 @@ func ovnDBSizeMetricsUpdater(direction, database string) {
metricDBSize.WithLabelValues(database).Set(float64(fileInfo.Size()))
}

func ovnE2eTimeStampUpdater(direction, database string) {
var stdout, stderr string
var err error

if direction == "sb" {
stdout, stderr, err = util.RunOVNSbctl("--if-exists", "--no-leader-only",
"get", "SB_Global", ".", "options:e2e_timestamp")
} else {
stdout, stderr, err = util.RunOVNNbctl("--if-exists", "--no-leader-only",
"get", "NB_Global", ".", "options:e2e_timestamp")
}
if err != nil {
klog.Errorf("Failed to scrape timestamp for database %s: "+
"stderr (%s) (%v)", database, stderr, err)
return
}
if value, err := strconv.ParseFloat(stdout, 64); err == nil {
metricDBE2eTimestamp.WithLabelValues(database).Set(value)
} else {
klog.Errorf("Failed to parse %s e2e-timestamp value to float64 :(%v)",
database, err)
}
}

func ovnDBMemoryMetricsUpdater(direction, database string) {
var stdout, stderr string
var err error
Expand All @@ -300,7 +298,7 @@ func ovnDBMemoryMetricsUpdater(direction, database string) {
stdout, stderr, err = util.RunOVNNBAppCtl("--timeout=5", "memory/show")
}
if err != nil {
klog.Errorf("failed retrieving memory/show output for %q, stderr: %s, err: (%v)",
klog.Errorf("Failed retrieving memory/show output for %q, stderr: %s, err: (%v)",
strings.ToUpper(database), stderr, err)
return
}
Expand All @@ -311,7 +309,7 @@ func ovnDBMemoryMetricsUpdater(direction, database string) {
if value, err := strconv.ParseFloat(fields[1], 64); err == nil {
metricOVNDBMonitor.WithLabelValues(database).Set(value)
} else {
klog.Errorf("failed to parse the monitor's value %s to float64: err(%v)",
klog.Errorf("Failed to parse the monitor's value %s to float64: err(%v)",
fields[1], err)
}
} else if strings.HasPrefix(kvPair, "sessions:") {
Expand All @@ -320,7 +318,7 @@ func ovnDBMemoryMetricsUpdater(direction, database string) {
if value, err := strconv.ParseFloat(fields[1], 64); err == nil {
metricOVNDBSessions.WithLabelValues(database).Set(value)
} else {
klog.Errorf("failed to parse the sessions' value %s to float64: err(%v)",
klog.Errorf("Failed to parse the sessions' value %s to float64: err(%v)",
fields[1], err)
}
}
Expand Down Expand Up @@ -375,8 +373,6 @@ var OvnDBExporterCommand = cli.Command{
// get the ovsdb server version info
getOvnDbVersionInfo()
// register metrics that will be served off of /metrics path
prometheus.MustRegister(metricOVNDBRaftIndex)
prometheus.MustRegister(metricOVNDBLeader)
prometheus.MustRegister(metricOVNDBMonitor)
prometheus.MustRegister(metricOVNDBSessions)
prometheus.MustRegister(metricDBSize)
Expand Down Expand Up @@ -410,32 +406,28 @@ var OvnDBExporterCommand = cli.Command{
prometheus.MustRegister(metricDBClusterConnOut)
prometheus.MustRegister(metricDBClusterConnInErr)
prometheus.MustRegister(metricDBClusterConnOutErr)
prometheus.MustRegister(metricDBE2eTimestamp)

// functions responsible for collecting the values and updating the prometheus metrics
go func() {
dirDbMap := map[string]string{
"nb": "OVN_Northbound",
"sb": "OVN_Southbound",
}
for direction, database := range dirDbMap {
ovnDBStatusMetricsUpdater(direction, database)
ovnDBMemoryMetricsUpdater(direction, database)
ovnDBSizeMetricsUpdater(direction, database)
time.Sleep(30 * time.Second)
}
}()

go func() {
for {
ovnDBClusterStatusMetricsUpdater("nb", "OVN_Northbound")
ovnDBClusterStatusMetricsUpdater("sb", "OVN_Southbound")
for direction, database := range dirDbMap {
ovnDBClusterStatusMetricsUpdater(direction, database)
ovnDBMemoryMetricsUpdater(direction, database)
ovnDBSizeMetricsUpdater(direction, database)
ovnE2eTimeStampUpdater(direction, database)
}
time.Sleep(30 * time.Second)
}
}()

err := http.ListenAndServe(bindAddress, mux)
if err != nil {
klog.Exitf("starting metrics server failed: %v", err)
klog.Exitf("Starting metrics server failed: %v", err)
}
return nil
},
Expand Down Expand Up @@ -478,7 +470,7 @@ func getOVNDBClusterStatusInfo(timeout int, direction, database string) (cluster
"cluster/status", database)
}
if err != nil {
klog.Errorf("failed to retrieve cluster/status info for database %q, stderr: %s, err: (%v)",
klog.Errorf("Failed to retrieve cluster/status info for database %q, stderr: %s, err: (%v)",
database, stderr, err)
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions go-controller/cmd/ovnkube/ovnkube.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func setupPIDFile(pidfile string) error {
// Create if it doesn't exist, else exit with error
if os.IsNotExist(err) {
if err := ioutil.WriteFile(pidfile, []byte(fmt.Sprintf("%d", os.Getpid())), 0644); err != nil {
klog.Errorf("failed to write pidfile %s (%v). Ignoring..", pidfile, err)
klog.Errorf("Failed to write pidfile %s (%v). Ignoring..", pidfile, err)
}
} else {
// get the pid and see if it exists
Expand All @@ -159,7 +159,7 @@ func setupPIDFile(pidfile string) error {
if os.IsNotExist(err1) {
// Left over pid from dead process
if err := ioutil.WriteFile(pidfile, []byte(fmt.Sprintf("%d", os.Getpid())), 0644); err != nil {
klog.Errorf("failed to write pidfile %s (%v). Ignoring..", pidfile, err)
klog.Errorf("Failed to write pidfile %s (%v). Ignoring..", pidfile, err)
}
} else {
return fmt.Errorf("pidfile %s exists and ovnkube is running", pidfile)
Expand Down Expand Up @@ -228,7 +228,7 @@ func runOvnKube(ctx *cli.Context) error {

if master != "" {
if runtime.GOOS == "windows" {
return fmt.Errorf("Windows is not supported as a master")
return fmt.Errorf("master nodes cannot be of OS type: Windows")
}
// register prometheus metrics exported by the master
metrics.RegisterMasterMetrics()
Expand Down Expand Up @@ -300,7 +300,7 @@ func watchForChanges(configPath string) error {
if !ok {
return
}
klog.Errorf("fsnotify error %v", err)
klog.Errorf("Error watching for changes to configmap: %s, err: %v", configPath, err)
}
}
}()
Expand Down
3 changes: 1 addition & 2 deletions go-controller/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ go 1.13

require (
github.com/Mellanox/sriovnet v0.0.0-20190516174650-73402dc8fcaa
github.com/Microsoft/hcsshim v0.8.7-0.20190909204626-e6890e6c30eb
github.com/Microsoft/hcsshim v0.8.10-0.20200606013352-27a858bf1651
github.com/bhendo/go-powershell v0.0.0-20190719160123-219e7fb4e41e
github.com/containernetworking/cni v0.7.1
github.com/containernetworking/plugins v0.8.2
github.com/coreos/go-iptables v0.4.3
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect
github.com/googleapis/gnostic v0.3.1 // indirect
github.com/gorilla/mux v1.7.3
Expand Down

0 comments on commit d41bfd4

Please sign in to comment.