Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow setting ARGOCD_EXEC_TIMEOUT in repo server #415

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/v1alpha1/argocd_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ type ArgoCDRepoSpec struct {

// Version is the ArgoCD Repo Server container image tag.
Version string `json:"version,omitempty"`

// ExecTimeout specifies the timeout in seconds for tool execution
ExecTimeout *int `json:"execTimeout,omitempty"`
}

// ArgoCDRouteSpec defines the desired state for an OpenShift Route.
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions config/crd/bases/argoproj.io_argocds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,10 @@ spec:
can currently be: - openshift - Use the OpenShift service CA
to request TLS config'
type: string
execTimeout:
description: ExecTimeout specifies the timeout in seconds for
tool execution
type: integer
image:
description: Image is the ArgoCD Repo Server container image.
type: string
Expand Down
7 changes: 6 additions & 1 deletion controllers/argocd/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,11 @@ func (r *ReconcileArgoCD) reconcileRepoDeployment(cr *argoprojv1a1.ArgoCD) error
deploy.Spec.Template.Spec.ServiceAccountName = cr.Spec.Repo.ServiceAccount
}

repoEnv := proxyEnvVars()
if cr.Spec.Repo.ExecTimeout != nil {
repoEnv = append(repoEnv, corev1.EnvVar{Name: "ARGOCD_EXEC_TIMEOUT", Value: fmt.Sprintf("%d", *cr.Spec.Repo.ExecTimeout)})
}

deploy.Spec.Template.Spec.Containers = []corev1.Container{{
Command: getArgoRepoCommand(cr),
Image: getRepoServerContainerImage(cr),
Expand All @@ -798,7 +803,7 @@ func (r *ReconcileArgoCD) reconcileRepoDeployment(cr *argoprojv1a1.ArgoCD) error
InitialDelaySeconds: 5,
PeriodSeconds: 10,
},
Env: proxyEnvVars(),
Env: repoEnv,
Name: "argocd-repo-server",
Ports: []corev1.ContainerPort{
{
Expand Down
53 changes: 53 additions & 0 deletions controllers/argocd/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,59 @@ func TestReconcileArgoCD_reconcileRepoDeployment_volumes(t *testing.T) {
}
}

func TestReconcileArgoCD_reconcileRepoDeployment_env(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

t.Run("ExecTimeout set", func(t *testing.T) {
logf.SetLogger(ZapLogger(true))
a := makeTestArgoCD()
timeout := 600
a.Spec.Repo.ExecTimeout = &timeout
r := makeTestReconciler(t, a)

err := r.reconcileRepoDeployment(a)
assert.NilError(t, err)
deployment := &appsv1.Deployment{}
err = r.Client.Get(context.TODO(), types.NamespacedName{
Name: "argocd-repo-server",
Namespace: testNamespace,
}, deployment)
assert.NilError(t, err)

found := false
for _, e := range deployment.Spec.Template.Spec.Containers[0].Env {
if e.Name == "ARGOCD_EXEC_TIMEOUT" && e.Value == "600" {
found = true
break
}
}

assert.Equal(t, found, true)
})
t.Run("ExecTimeout not set", func(t *testing.T) {
logf.SetLogger(ZapLogger(true))
a := makeTestArgoCD()
r := makeTestReconciler(t, a)

err := r.reconcileRepoDeployment(a)
assert.NilError(t, err)
deployment := &appsv1.Deployment{}
err = r.Client.Get(context.TODO(), types.NamespacedName{
Name: "argocd-repo-server",
Namespace: testNamespace,
}, deployment)
assert.NilError(t, err)

found := false
for _, e := range deployment.Spec.Template.Spec.Containers[0].Env {
if e.Name == "ARGOCD_EXEC_TIMEOUT" && e.Value == "600" {
found = true
break
}
}

assert.Equal(t, found, false)
})
}

// reconcileRepoDeployment creates a Deployment with the correct mounts for the
// repo-server.
func TestReconcileArgoCD_reconcileRepoDeployment_mounts(t *testing.T) {
Expand Down