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

Submitting from a WorkflowTemplate shows incorrect serviceAccount and securityContext nag #7726

Closed
tyrken opened this issue Feb 1, 2022 · 7 comments · Fixed by #7805
Closed

Comments

@tyrken
Copy link

tyrken commented Feb 1, 2022

Summary

Starting a Workflow from a WorkflowTemplate brings up the security nag "This workflow does not have security context set. ..." - even if the WorkflowTemplate defines a securityContext. I've also (just) noticed that the serviceAccount is also shown as "default" even though I'm running with one (currently having to as using PNS).

What version of Argo Workflows are you running?

Running with v3.2.7 client & v3.2.6 server

Diagnostics

Example WorkflowTemplate

apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
  name: my-workflow-template
  namespace: my-namespace
spec:
  entrypoint: main
  securityContext:
    runAsNonRoot: false
  serviceAccountName: my-service-account
  templates:
    - name: main
      metadata:
      container:
        command:
          - bash
          - -c
          - echo 'Hello from WT'; env; sleep 15
        image: ubuntu
        name: main

Example command & output:

$ argo submit --from workflowtemplate/my-workflow-template
Name:                my-workflow-template-76qt4
Namespace:           my-namespace
ServiceAccount:      default
Status:              Pending
Created:             Tue Feb 01 21:38:02 +0000 (now)
Progress:            

This workflow does not have security context set. You can run your workflow pods more securely by setting it.
Learn more at https://argoproj.github.io/argo-workflows/workflow-pod-security-context/

What Kubernetes provider are you using? EKS

What executor are you running? PNS


Message from the maintainers:

Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.

@tyrken
Copy link
Author

tyrken commented Feb 1, 2022

I can only assume the test at

if wf.Spec.SecurityContext == nil {
and access at
serviceAccount := wf.Spec.ServiceAccountName
are operating on the "raw" spec. I was expecting some accessor function which merged the WorkflowTemplate into the Workflow before letting code query object attributes...

@alexec alexec added good first issue Good for newcomers area/ui and removed area/ui labels Feb 2, 2022
@alexec
Copy link
Contributor

alexec commented Feb 3, 2022

@tyrken this is a CLI problem?

@sarabala1979 can I check my logic here? If you have wf.Status.StoreWorkflowSpec, you should use that, otherwise use wf.Spec? I wonder if we should add a wf.GetExecSpec()?

@alexec alexec removed the triage label Feb 3, 2022
@alexec
Copy link
Contributor

alexec commented Feb 3, 2022

@tyrken I think you've found the bug, do you want to fix it? I think we'd benefit from a func named:

func (w *Workflow) GetExecSpec() *WorkflowSpec

That would return w.Status.StoredWorkflowSpec or w.Spec and then you could just call that.

@sarabala1979
Copy link
Member

yes cli should use wf.GetExecSpec()

@alexec alexec added the area/cli The `argo` CLI label Feb 4, 2022
@sarabala1979
Copy link
Member

Dillen is going submit the PR for this

@tyrken
Copy link
Author

tyrken commented Feb 5, 2022

I think it is a CLI only issue, and thanks-in-advance to Dillen!

@sarabala1979
Copy link
Member

sarabala1979 commented Feb 5, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants