Skip to content

Commit

Permalink
fix version check to work with release candidates (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
celenechang committed Jul 20, 2021
1 parent 37ef64e commit 17299c9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
4 changes: 3 additions & 1 deletion api/v1alpha1/datadogagent_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ func DefaultDatadogAgentSpecAgentConfig(agent *DatadogAgentSpecAgentSpec) *NodeA
// Let Env AD do the work for us
// Image is defaulted prior to this function.
agentTag := strings.TrimSuffix(utils.GetTagFromImageName(agent.Image.Name), "-jmx")
if !(agentTag == "latest" || utils.IsAboveMinVersion(agentTag, "7.27.0") || utils.IsAboveMinVersion(agentTag, "6.27.0")) {
// Check against image tag + "-0"; otherwise prelease versions are not compared.
// (See https://github.com/Masterminds/semver#working-with-prerelease-versions)
if !(agentTag == "latest" || utils.IsAboveMinVersion(agentTag, "7.27.0-0") || utils.IsAboveMinVersion(agentTag, "6.27.0-0")) {
if socketOverride := DefaultContainerSocket(agent.Config); !IsEqualStruct(socketOverride, CRISocketConfig{}) {
configOverride.CriSocket = socketOverride
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/datadogagent/finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (r *Reconciler) handleFinalizer(reqLogger logr.Logger, dda *datadoghqv1alph
func (r *Reconciler) finalizeDad(reqLogger logr.Logger, dda *datadoghqv1alpha1.DatadogAgent) {
_, err := r.cleanupMetricsServerAPIService(reqLogger, dda)
if err != nil {
reqLogger.Error(err,"Could not delete Metrics Server API Service")
reqLogger.Error(err, "Could not delete Metrics Server API Service")
}
r.forwarders.Unregister(dda)
reqLogger.Info("Successfully finalized DatadogAgent")
Expand Down
25 changes: 25 additions & 0 deletions pkg/utils/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,31 @@ func TestCompareVersion(t *testing.T) {
minVersion: "7.26.0-rc.5",
expected: true,
},
{
version: "7.29.0-rc.5",
minVersion: "7.27.0-0",
expected: true,
},
{
version: "7.30.0",
minVersion: "7.27.1-0",
expected: true,
},
{
version: "7.25.0",
minVersion: "7.27.1-0",
expected: false,
},
{
version: "6.27.0",
minVersion: "6.28.0-0",
expected: false,
},
{
version: "6.28.1",
minVersion: "6.28.0-0",
expected: true,
},
{
version: "6.27.0",
minVersion: "6.28.0",
Expand Down

0 comments on commit 17299c9

Please sign in to comment.