Skip to content

Commit

Permalink
fix: k8s version detection for agent service (#472) (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
clamoriniere committed Apr 28, 2022
1 parent 1937df3 commit 76452f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions controllers/datadogagent/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/pkg/version"

"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
Expand Down Expand Up @@ -152,7 +151,10 @@ var testGitVersion string

func (r *Reconciler) manageAgentService(logger logr.Logger, dda *datadoghqv1alpha1.DatadogAgent) (reconcile.Result, error) {
// Service Internal Traffic Policy exists in Kube 1.21 but it is enabled by default since 1.22
gitVersion := version.Get().GitVersion
gitVersion := ""
if r.versionInfo != nil {
gitVersion = r.versionInfo.GitVersion
}
if testGitVersion != "" {
gitVersion = testGitVersion
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/utils/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ func TestCompareVersion(t *testing.T) {
minVersion: "7.28.0",
expected: false,
},
{
version: "1.23.4",
minVersion: "1.22-0",
expected: true,
},
}
for _, test := range testCases {
t.Run(test.version, func(t *testing.T) {
Expand Down

0 comments on commit 76452f6

Please sign in to comment.