Skip to content

Commit

Permalink
Merge pull request #454 from pliurh/sync
Browse files Browse the repository at this point in the history
Bug 1908570: Sync upstream 2021-01-05
  • Loading branch information
openshift-merge-robot authored Jan 5, 2021
2 parents d6033c0 + aac3a69 commit 211d8ee
Show file tree
Hide file tree
Showing 19 changed files with 155 additions and 250 deletions.
8 changes: 8 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# labels to be used with /area command
area:
- 'bug'
- 'important'

# File globs for PR labeler
tests:
- '**/*.test.ts'
22 changes: 16 additions & 6 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
name: Go

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
on: [push, pull_request]

jobs:

build:
name: Build
name: build
runs-on: ubuntu-latest
steps:

Expand All @@ -27,8 +23,22 @@ jobs:
- name: Build
run: make all

test:
name: test
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15

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

- name: test pkg
run: make test-pkg

- name: test controllers on opensfhit
run: CLUSTER_TYPE=openshift make test-controllers

11 changes: 11 additions & 0 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "Pull Request Labeler"
on:
- pull_request_target

jobs:
triage:
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v3
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
12 changes: 12 additions & 0 deletions .github/workflows/pr-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "Run Jobs on PR"
on: pull_request

jobs:
execute:
name: "remove the lgtm label"
runs-on: ubuntu-latest
steps:
- uses: jpmcb/[email protected]
with:
jobs: 'lgtm'
github-token: "${{ secrets.GITHUB_TOKEN }}"
28 changes: 28 additions & 0 deletions .github/workflows/prow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Prow github actions"
on:
issue_comment:
types: [created]

jobs:
execute:
runs-on: ubuntu-latest
steps:
- uses: jpmcb/[email protected]
with:
prow-commands: '/assign
/unassign
/approve
/retitle
/area
/kind
/priority
/remove
/lgtm
/close
/reopen
/lock
/milestone
/hold
/cc
/uncc'
github-token: "${{ secrets.GITHUB_TOKEN }}"
50 changes: 0 additions & 50 deletions bindata/manifests/daemon/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,57 +50,7 @@ spec:
volumeMounts:
- name: host
mountPath: /host
# - name: hostetc
# mountPath: /host/etc
# - name: hostdev
# mountPath: /host/dev
# - name: hostproc
# mountPath: /host/proc
# - name: hostboot
# mountPath: /host/boot
# - name: hostusrlib
# mountPath: /host/lib
# - name: hostusrlib64
# mountPath: /host/lib64
# - name: hostusr
# mountPath: /host/usr
# - name: hostusrbin
# mountPath: /host/bin
# - name: hostusrsbin
# mountPath: /host/sbin
# - name: hostsysmodule
# mountPath: /host/sys/module
volumes:
- name: host
hostPath:
path: /
# - name: hostetc
# hostPath:
# path: /etc
# - name: hostdev
# hostPath:
# path: /dev
# - name: hostproc
# hostPath:
# path: /proc
# - name: hostboot
# hostPath:
# path: /boot
# - name: hostusr
# hostPath:
# path: /usr
# - name: hostusrbin
# hostPath:
# path: /usr/bin
# - name: hostusrlib
# hostPath:
# path: /usr/lib
# - name: hostusrlib64
# hostPath:
# path: /usr/lib64
# - name: hostusrsbin
# hostPath:
# path: /usr/sbin
# - name: hostsysmodule
# hostPath:
# path: /sys/module
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ contents:
ip link set ${new_name} down
ip link set ${new_name} name ${names[i]}
ip link set ${names[i]} up
# ip link set $new_name up
# turn hw-tc-offload on
/usr/sbin/ethtool -K ${names[i]} hw-tc-offload on
i=$(( i+1 ))
# load VF driver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ dropins:
contents: |
[Service]
ExecStartPre=/bin/ovs-vsctl set Open_vSwitch . other_config:hw-offload=true
ExecStartPre=/bin/ovs-vsctl set Open_vSwitch . other_config:tc-policy=skip_sw
4 changes: 4 additions & 0 deletions bindata/manifests/operator-webhook/003-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: MutatingWebhookConfiguration
metadata:
name: {{.SRIOVMutatingWebhookName}}
namespace: {{.Namespace}}
annotations:
service.beta.openshift.io/inject-cabundle: "true"
webhooks:
- name: operator-webhook.sriovnetwork.openshift.io
failurePolicy: Fail
Expand All @@ -24,6 +26,8 @@ kind: ValidatingWebhookConfiguration
metadata:
name: {{.SRIOVMutatingWebhookName}}
namespace: {{.Namespace}}
annotations:
service.beta.openshift.io/inject-cabundle: "true"
webhooks:
- name: operator-webhook.sriovnetwork.openshift.io
failurePolicy: Fail
Expand Down
8 changes: 0 additions & 8 deletions bindata/manifests/operator-webhook/004-configmap.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions bindata/manifests/webhook/003-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: MutatingWebhookConfiguration
metadata:
name: {{.SRIOVMutatingWebhookName}}
namespace: {{.Namespace}}
annotations:
service.beta.openshift.io/inject-cabundle: "true"
webhooks:
- name: network-resources-injector-config.k8s.io
clientConfig:
Expand Down
8 changes: 0 additions & 8 deletions bindata/manifests/webhook/004-configmap.yaml

This file was deleted.

22 changes: 22 additions & 0 deletions cmd/sriov-network-config-daemon/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"flag"
"fmt"
"net"
"net/url"
"os"
"strings"
"time"
Expand Down Expand Up @@ -84,6 +85,27 @@ func runStartCmd(cmd *cobra.Command, args []string) {

var config *rest.Config
var err error

if os.Getenv("CLUSTER_TYPE") == utils.ClusterTypeOpenshift {
kubeconfig, err := clientcmd.LoadFromFile("/host/etc/kubernetes/kubeconfig")
if err != nil {
glog.Errorf("failed to load kubelet kubeconfig: %v", err)
}
clusterName := kubeconfig.Contexts[kubeconfig.CurrentContext].Cluster
apiURL := kubeconfig.Clusters[clusterName].Server

url, err := url.Parse(apiURL)
if err != nil {
glog.Errorf("failed to parse api url from kubelet kubeconfig: %v", err)
}

// The kubernetes in-cluster functions don't let you override the apiserver
// directly; gotta "pass" it via environment vars.
glog.V(0).Infof("overriding kubernetes api to %s", apiURL)
os.Setenv("KUBERNETES_SERVICE_HOST", url.Hostname())
os.Setenv("KUBERNETES_SERVICE_PORT", url.Port())
}

kubeconfig := os.Getenv("KUBECONFIG")
if kubeconfig != "" {
config, err = clientcmd.BuildConfigFromFlags("", kubeconfig)
Expand Down
2 changes: 0 additions & 2 deletions controllers/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ const (
CONFIG_DAEMON_PATH = "./bindata/manifests/daemon"
INJECTOR_WEBHOOK_PATH = "./bindata/manifests/webhook"
OPERATOR_WEBHOOK_PATH = "./bindata/manifests/operator-webhook"
INJECTOR_SERVICE_CA_CONFIGMAP = "injector-service-ca"
WEBHOOK_SERVICE_CA_CONFIGMAP = "webhook-service-ca"
SERVICE_CA_CONFIGMAP_ANNOTATION = "service.beta.openshift.io/inject-cabundle"
INJECTOR_WEBHOOK_NAME = "network-resources-injector-config"
OPERATOR_WEBHOOK_NAME = "sriov-operator-webhook-config"
Expand Down
43 changes: 14 additions & 29 deletions controllers/sriovnetworknodepolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,6 @@ func (r *SriovNetworkNodePolicyReconciler) syncPluginDaemonObjs(dp *sriovnetwork
logger := r.Log.WithName("syncPluginDaemonObjs")
logger.Info("Start to sync sriov daemons objects")

if len(pl.Items) < 2 {
err := r.tryDeleteDsPods(namespace, "sriov-device-plugin")
if err != nil {
return err
}
err = r.tryDeleteDsPods(namespace, "sriov-cni")
if err != nil {
return err
}
}
// render RawCNIConfig manifests
data := render.MakeRenderData()
data.Data["Namespace"] = namespace
Expand Down Expand Up @@ -352,6 +342,17 @@ func (r *SriovNetworkNodePolicyReconciler) syncPluginDaemonObjs(dp *sriovnetwork
if err != nil {
return err
}

if len(pl.Items) < 2 {
for _, obj := range objs {
err := r.deleteK8sResource(obj)
if err != nil {
return err
}
}
return nil
}

// Sync DaemonSets
for _, obj := range objs {
if obj.GetKind() == "DaemonSet" && len(defaultConfig.Spec.ConfigDaemonNodeSelector) > 0 {
Expand All @@ -378,25 +379,9 @@ func (r *SriovNetworkNodePolicyReconciler) syncPluginDaemonObjs(dp *sriovnetwork
return nil
}

func (r *SriovNetworkNodePolicyReconciler) tryDeleteDsPods(namespace, name string) error {
logger := r.Log.WithName("tryDeleteDsPods")
ds := &appsv1.DaemonSet{}
err := r.Get(context.TODO(), types.NamespacedName{Namespace: namespace, Name: name}, ds)
if err != nil {
if errors.IsNotFound(err) {
return nil
} else {
logger.Error(err, "Fail to get DaemonSet", "Namespace", namespace, "Name", name)
return err
}
} else {
ds.Spec.Template.Spec.NodeSelector = map[string]string{"beta.kubernetes.io/os": "none"}
ds.Spec.Template.Spec.Affinity = &corev1.Affinity{}
err = r.Update(context.TODO(), ds)
if err != nil {
logger.Error(err, "Fail to update DaemonSet", "Namespace", namespace, "Name", name)
return err
}
func (r *SriovNetworkNodePolicyReconciler) deleteK8sResource(in *uns.Unstructured) error {
if err := apply.DeleteObject(context.TODO(), r, in); err != nil {
return fmt.Errorf("failed to delete object %v with err: %v", in, err)
}
return nil
}
Expand Down
Loading

0 comments on commit 211d8ee

Please sign in to comment.