Skip to content

Commit

Permalink
Modifying config-daemon to exit if platform type cannot be determined.
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorettodama committed Jul 5, 2023
1 parent e84d536 commit b8752f8
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions cmd/sriov-network-config-daemon/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import (
configv1 "github.com/openshift/api/config/v1"
mcfgv1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1"
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
Expand Down Expand Up @@ -150,18 +152,32 @@ func runStartCmd(cmd *cobra.Command, args []string) {
destdir = "/host/tmp"
}

platformType := utils.Baremetal

nodeInfo, err := kubeclient.CoreV1().Nodes().Get(context.Background(), startOpts.nodeName, v1.GetOptions{})
if err == nil {
for key, pType := range utils.PlatformMap {
if strings.Contains(strings.ToLower(nodeInfo.Spec.ProviderID), strings.ToLower(key)) {
platformType = pType
}
backoff := wait.Backoff{
Steps: 5,
Duration: 10 * time.Second,
Factor: 2,
}
var lastErr error
var nodeInfo *corev1.Node
if err = wait.ExponentialBackoff(backoff, func() (bool, error) {
var nodeErr error
nodeInfo, nodeErr = kubeclient.CoreV1().Nodes().Get(context.Background(), startOpts.nodeName, v1.GetOptions{})
if nodeErr != nil {
lastErr = nodeErr
glog.Warningf("failed to obtain node %s: %v, retrying", startOpts.nodeName, nodeErr)
return false, nil
}
} else {
return true, nil
}); err != nil {
glog.Fatalf("Failed to fetch node state %s, %v!", startOpts.nodeName, err)
}

platformType := utils.Baremetal
for key, pType := range utils.PlatformMap {
if strings.Contains(strings.ToLower(nodeInfo.Spec.ProviderID), strings.ToLower(key)) {
platformType = pType
}
}
glog.V(0).Infof("Running on platform: %s", platformType.String())

var namespace = os.Getenv("NAMESPACE")
Expand Down

0 comments on commit b8752f8

Please sign in to comment.