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

Prefix Skaffold labels with 'skaffold-' #2062

Merged
merged 3 commits into from
May 6, 2019

Conversation

charlyx
Copy link
Contributor

@charlyx charlyx commented May 3, 2019

Hi 👋

First of all, thanks for your work!

I hope this PR meets #2002 expectations 😄

Thanks to @pyaillet for his help 🤗

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@charlyx
Copy link
Contributor Author

charlyx commented May 3, 2019

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes and removed cla: no labels May 3, 2019
@corneliusweig
Copy link
Contributor

I'm a bit worried that somebody may forget to add the skaffold- prefix when this issue has been forgotten. I would prefer, if the labeler would check each label whether it needs to be prefixed. WDYT?

"two": "second",
"three": "",
"four": "",
"cleanup": "true",
Copy link
Contributor

Choose a reason for hiding this comment

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

why cleanup and skaffold-cleanup both exist here?

Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand correctly, in #2002, it's question of keeping both for sometimes to make sure not to break potential use from skaffold users.
If this is excessive precaution, we might just replace the existing ones.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah understood. this is for backward compatibility. However these are labels that skaffold uses internally to track pods that needed to cleaned-up. Users should not have to care about these labels.
So. removing them should be fine.

@tejal29
Copy link
Contributor

tejal29 commented May 3, 2019

I'm a bit worried that somebody may forget to add the skaffold- prefix when this issue has been forgotten. I would prefer, if the labeler would check each label whether it needs to be prefixed. WDYT?

Thats is a great thought. The labeller could have something is "AddSkaffoldPrefixIfRequired". However there is an exception to this rule when you want to add k8 recommended style labels.
Maybe we could do some more strict validations like if its one of the recommended style label or not?

@corneliusweig
Copy link
Contributor

However there is an exception to this rule when you want to add k8 recommended style labels .

@tejal29 good point. So at the very least, we should check if the label already has a app.kubernetes.io prefix, and if it does skip adding our prefix.

Further, it seems to be common convention to delimit label namespaces with a /. Therefore, if a label already contains a /, we should assume that the label is already namespaced and skip the skaffold prefix. WDYT?

Now that I think about it, should we not use a more expressive prefix than skaffold-? My favorite would be skaffold.dev/, e.g. skaffold.dev/tail. That way, a completely oblivious user would be directed to the skaffold web page.

@pyaillet
Copy link
Contributor

pyaillet commented May 3, 2019

@corneliusweig I like the idea of a skaffold.dev/ prefix.
However, what should be done of user label passed with skaffold ... -l userlabel=uservalue ?

@corneliusweig
Copy link
Contributor

corneliusweig commented May 3, 2019

@pyaillet good catch! I as a user would be surprised, if my label was prefixed. So I would say, no prefix for any explicitly user-specified labels. Or what is your feeling?

@corneliusweig
Copy link
Contributor

@charlyx there is one contrived piece of code where the prefixing everything is not correct. The helm deployer needs to apply labels after creating the objects in k8s. For that, the labeler needs to merge existing and new skaffold labels. Those existing labels should of course not be prefixed with skaffold... .

@pyaillet
Copy link
Contributor

pyaillet commented May 3, 2019

I see three options there:

  1. Add a AddSkaffoldPrefixIfRequired method and call it where merge is called. However user labels would be prefixed, which is not really satisfying
  2. Add the AddSkaffoldPrefixIfRequired method, call it there, just before user labels handling. Keeping prefix hardcoded here
  3. Create a way to distinguish between ToBePrefixedLabels and ToBeKeptLabels by extending the Labeller interface, but this one seems a bit overengineered to me

I think the second might be a good option, WDYT ?

@tejal29
Copy link
Contributor

tejal29 commented May 3, 2019

Thanks @pyaillet i feel we should go with your current implementation and enforce "skaffold-" prefix via code reviews and not use AddSkaffoldPrefixIfRequired at all. We don't want to add too many branches to the flow and add more complexity.

@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: no and removed cla: yes labels May 3, 2019
@pyaillet
Copy link
Contributor

pyaillet commented May 3, 2019

I signed it!
And I'm ok with my commits being contributed to this project.

@codecov-io
Copy link

codecov-io commented May 3, 2019

Codecov Report

Merging #2062 into master will not change coverage.
The diff coverage is 75%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2062   +/-   ##
=======================================
  Coverage   56.12%   56.12%           
=======================================
  Files         180      180           
  Lines        7753     7753           
=======================================
  Hits         4351     4351           
  Misses       2986     2986           
  Partials      416      416
Impacted Files Coverage Δ
pkg/skaffold/deploy/labels.go 16.04% <ø> (ø) ⬆️
pkg/skaffold/config/options.go 90.47% <75%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 25f1b66...b843c51. Read the comment docs.

@charlyx
Copy link
Contributor Author

charlyx commented May 4, 2019

I'm ok with my commits being contributed to this project.

Copy link
Contributor

@corneliusweig corneliusweig left a comment

Choose a reason for hiding this comment

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

As it will be the task of the reviewer to ensure proper label prefixes, you could add a godoc comment to the Labeller interface (pkg/skaffold/deploy/labels.go) with a reminder that labels should be namespaced appropriately.

pkg/skaffold/config/options.go Outdated Show resolved Hide resolved
@tejal29 tejal29 added the kokoro:run runs the kokoro jobs on a PR label May 6, 2019
@kokoro-team kokoro-team removed the kokoro:run runs the kokoro jobs on a PR label May 6, 2019
@tejal29
Copy link
Contributor

tejal29 commented May 6, 2019

@pyaillet Looks like you dont have the CLA signed for the following email id.

Screenshot from 2019-05-06 11-08-25

@pyaillet
Copy link
Contributor

pyaillet commented May 6, 2019

I signed it!

@pyaillet
Copy link
Contributor

pyaillet commented May 6, 2019

Really strange, when I got to the CLA page I got:
"It looks like you've already signed this CLA. If you'd like to edit your contact information, you may do so below."
Sorry for the troubles :\

@pyaillet
Copy link
Contributor

pyaillet commented May 6, 2019

Is it related to this comment from GoogleBot ?

@charlyx
Copy link
Contributor Author

charlyx commented May 6, 2019 via email

@priyawadhwa
Copy link
Contributor

I think the CLA has been signed, looks like it just hasn't updated on the PR @tejal29

image

@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

@tejal29 tejal29 removed the cla: no label May 6, 2019
@tejal29
Copy link
Contributor

tejal29 commented May 6, 2019

Thanks @pyaillet and @priyawadhwa. I forced a Re-Scan and the error is "CLAs are signed, but unable to verify author consent" which is terminal
So i have to manually remove the label.
Thanks

@tejal29 tejal29 merged commit 0558713 into GoogleContainerTools:master May 6, 2019
@charlyx charlyx deleted the issue-2002 branch May 7, 2019 07:19
@Jonathan34
Copy link

Is it possible that this broke CI/CD:

Resource: "networking.istio.io/v1alpha3, Resource=virtualservices", GroupVersionKind: "networking.istio.io/v1alpha3, Kind=VirtualService"
Name: "istio-routes", Namespace: "development"
Object: &{map["apiVersion":"networking.istio.io/v1alpha3" "kind":"VirtualService" "metadata":map["annotations":map["kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"networking.istio.io/v1alpha3\",\"kind\":\"VirtualService\",\"metadata\":{\"annotations\":{},\"labels\":{\"app.kubernetes.io/managed-by\":\"skaffold-f25b09f\",\"environment\":\"development\",\"skaffold.dev/builder\":\"google-cloud-build\",\"skaffold.dev/cleanup\":\"true\",\"skaffold.dev/deployer\":\"kustomize\",\"skaffold.dev/profiles\":\"gcb\",\"skaffold.dev/tag-policy\":\"git-commit\",\"skaffold.dev/tail\":\"true\"},\"name\":\"istio-routes\",\"namespace\":\"development\"},\"spec\":{<redacted>}}\n"] "creationTimestamp":"2019-04-29T15:32:45Z" "generation":'\x01' "labels":map["app.kubernetes.io/managed-by":"skaffold-f25b09f" "environment":"development" "skaffold.dev/builder":"google-cloud-build" "skaffold.dev/cleanup":"true" "skaffold.dev/deployer":"kustomize" "skaffold.dev/profiles":"gcb" "skaffold.dev/tag-policy":"git-commit" "skaffold.dev/tail":"true"] "name":"istio-routes" "namespace":"development" "resourceVersion":"20715208" "selfLink":"/apis/networking.istio.io/v1alpha3/namespaces/development/virtualservices/istio-routes" "uid":"090cfcd6-6a94-11e9-af1e-42010a800034"] "spec":map[<redacted>]]}
for: "STDIN": VirtualService.networking.istio.io "istio-routes" is invalid: metadata.labels: Invalid value: "skaffold-": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue',  or 'my_value',  or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')
time="2019-05-08T15:10:51Z" level=fatal msg="deploy failed: kubectl error: kubectl apply: exit status 1"

@pyaillet
Copy link
Contributor

pyaillet commented May 8, 2019

As the prefix set here is skaffol.dev/, I would say no

@tejal29
Copy link
Contributor

tejal29 commented May 8, 2019

Looks like something else might be adding the label.
Can you provide logs of skaffold run with --verbosity=debug ?

@pyaillet
Copy link
Contributor

pyaillet commented May 8, 2019

It's strange, the only label value prefixed by skaffold- in the logs is: "app.kubernetes.io/managed-by":"skaffold-f25b09f"

@tejal29
Copy link
Contributor

tejal29 commented May 8, 2019

yeah looks like the version is not get populated. :( maybe we shd fix this to check if version is not empty.

@corneliusweig
Copy link
Contributor

But the version string (albeit weird) is not the problem, as it fits the regexp.

@Jonathan34 I think you are using kustomize to deploy, correct? Can you check if you do some label magic there? And are you using the AdmissionWebhookController or do you call istioctl manually? Maybe the clue as to what is going on is hidden there.

@Jonathan34
Copy link

Jonathan34 commented May 8, 2019

Looks like something else might be adding the label.
Can you provide logs of skaffold run with --verbosity=debug ?

is there a good place i can confidentially share the logs?
I am running skaffold from the latest skaffold docker image. the deploy step is a kustomize overlay that worked yesterday morning (probably should not use skaffold:latest :P)

The guilty label seems to be the following:
app.kubernetes.io/managed-by: skaffold-

the tag policy i set is:

 tagPolicy:
    gitCommit: {}

here is an abstract of the log:

Generating tags...
time="2019-05-08T17:03:56Z" level=debug msg="Running command: [git describe --tags --always]"
 - gcr.io/<redacted>/myservice -> time="2019-05-08T17:03:56Z" level=info msg="update check failed: get latest and current Skaffold version: parsing current semver, skipping update check: parsing semver: Version string empty"
time="2019-05-08T17:03:57Z" level=debug msg="Command output: [62577b7\n]"
time="2019-05-08T17:03:57Z" level=debug msg="Running command: [git status . --porcelain]"
gcr.io/<redacted>/myservice:62577b7
Tags generated in 1.4113427s

...
Build complete in 2m20.0544816s
Starting test...
Test complete in 20.9µs
Starting deploy...
kubectl client version: 1.14

But the version string (albeit weird) is not the problem, as it fits the regexp.

@Jonathan34 I think you are using kustomize to deploy, correct? Can you check if you do some label magic there? And are you using the AdmissionWebhookController or do you call istioctl manually? Maybe the clue as to what is going on is hidden there.

actually the skaffold- fails the regexp as it does not end with alpha numerical char.
I use kustomize.
I am not using any AdmissionWebhookController,
i am not calling istioctl manually. ihave the istio files listed in the kustomization resources so they are applied everytime with the overlays.

One overlay i have looks like this:

commonLabels:
  environment: development
bases:
  - ../../base
namespace: development
patchesStrategicMerge:
  - patches/istio-routes.yaml
  - patches/istio-whitelist-cloudsql-app-models-egress.yaml
patchesJson6902:
  - target:
      group: networking.istio.io
      version: v1alpha3
      kind: VirtualService
      name: istio-routes-ui
    path: patches/routes-ui-patch.yaml

I am willing to show my config to someone in a video conf or anything, but i can't send the whole package. Or I need to switch to the google enterprise support portal...

@corneliusweig
Copy link
Contributor

I am running skaffold from the latest skaffold docker image

I take it you are talking about gcr.io/k8s-skaffold/skaffold:latest?

@Jonathan34
Copy link

Jonathan34 commented May 8, 2019

I am running skaffold from the latest skaffold docker image

I take it you are talking about gcr.io/k8s-skaffold/skaffold:latest?

yes;

Using default tag: latest
latest: Pulling from k8s-skaffold/skaffold
Digest: sha256:275894cbe96cbf2c5262bba710530acbad91bd8af329b6d6eea9ca6086d14642
Status: Image is up to date for gcr.io/k8s-skaffold/skaffold:latest

@corneliusweig
Copy link
Contributor

corneliusweig commented May 8, 2019

So the skaffold image does have a version set (albeit a strange one):

docker run --rm -ti gcr.io/k8s-skaffold/skaffold:latest skaffold version \
  -o "{{.Version}}  {{.GitCommit}} {{.GitTreeState}}"

yields

a117236  a1172365f8c099635277a46c20acfa1e1d6ed2a7 clean%

Overall, to me it does not look like DefaultLabeller would cause the bad label.

@tejal29
Copy link
Contributor

tejal29 commented May 8, 2019

umm we shd fix that. Sorry about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants