-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix scheduler driver name; create node structs file
- Loading branch information
1 parent
f18731a
commit 3e698ea
Showing
8 changed files
with
130 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package structs | ||
|
||
import ( | ||
"strings" | ||
"time" | ||
) | ||
|
||
// DriverInfo is the current state of a single driver. This is updated | ||
// regularly as driver health changes on the node. | ||
type DriverInfo struct { | ||
Attributes map[string]string | ||
Detected bool | ||
Healthy bool | ||
HealthDescription string | ||
UpdateTime time.Time | ||
} | ||
|
||
func (di *DriverInfo) MergeHealthCheck(other *DriverInfo) { | ||
di.Healthy = other.Healthy | ||
di.HealthDescription = other.HealthDescription | ||
di.UpdateTime = other.UpdateTime | ||
} | ||
|
||
func (di *DriverInfo) MergeFingerprintInfo(other *DriverInfo) { | ||
di.Detected = other.Detected | ||
di.Attributes = other.Attributes | ||
} | ||
|
||
// DriverInfo determines if two driver info objects are equal..As this is used | ||
// in the process of health checking, we only check the fields that are | ||
// computed by the health checker. In the future, this will be merged. | ||
func (di *DriverInfo) HealthCheckEquals(other *DriverInfo) bool { | ||
if di == nil && other != nil || di != nil && other == nil { | ||
return false | ||
} | ||
|
||
if di.Healthy != other.Healthy { | ||
return false | ||
} | ||
|
||
if strings.Compare(di.HealthDescription, other.HealthDescription) != 0 { | ||
return false | ||
} | ||
|
||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package structs | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestDriverInfoEquals(t *testing.T) { | ||
require := require.New(t) | ||
var driverInfoTest = []struct { | ||
input []*DriverInfo | ||
expected bool | ||
errorMsg string | ||
}{ | ||
{ | ||
[]*DriverInfo{ | ||
&DriverInfo{ | ||
Healthy: true, | ||
}, | ||
&DriverInfo{ | ||
Healthy: false, | ||
}, | ||
}, | ||
false, | ||
"Different healthy values should not be equal.", | ||
}, | ||
{ | ||
[]*DriverInfo{ | ||
&DriverInfo{ | ||
HealthDescription: "not running", | ||
}, | ||
&DriverInfo{ | ||
HealthDescription: "running", | ||
}, | ||
}, | ||
false, | ||
"Different health description values should not be equal.", | ||
}, | ||
{ | ||
[]*DriverInfo{ | ||
&DriverInfo{ | ||
Healthy: true, | ||
HealthDescription: "running", | ||
}, | ||
&DriverInfo{ | ||
Healthy: true, | ||
HealthDescription: "running", | ||
}, | ||
}, | ||
true, | ||
"Different health description values should not be equal.", | ||
}, | ||
} | ||
for _, testCase := range driverInfoTest { | ||
first := testCase.input[0] | ||
second := testCase.input[1] | ||
require.Equal(testCase.expected, first.HealthCheckEquals(second), testCase.errorMsg) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters