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

fix: custom crd not printing streams logs #9136

Merged

Conversation

beastpu
Copy link
Contributor

@beastpu beastpu commented Oct 16, 2023

Description
my company uses a custom CRD (openkruise https://openkruise.io/) to manage workloads.
During local development, we discovered that aggregated logs were not being printed. Aggregated logs are crucial for microservices architecture.

dce3f3fb-d041-4a1d-8235-35be90b628a6

skaffold.yaml

apiVersion: skaffold/v4beta7
kind: Config
build:
  artifacts:
  - image: skaffold-example
  local:
    push: false
manifests:
  rawYaml:
  - sts.yaml

resourceSelector:
  allow:
    - groupKind: CloneSet.apps.kruise.io
      image:
        - .*
      labels:
        - .*
    - groupKind: StatefulSet.apps.kruise.io
      image:
        - .*
      labels:
        - .*

sts.yaml

apiVersion: apps.kruise.io/v1beta1
kind: StatefulSet
metadata:
  name: getting-started
spec:
  replicas: 1
  serviceName: getting-started
  selector:
    matchLabels:
      app: getting-started
  template:
    metadata:
      labels:
        app: getting-started
    spec:
      containers:
      - name: getting-started
        image: skaffold-example
        imagePullPolicy: IfNotPresent

User facing changes (remove if N/A)
I found that the reason was the absence of corresponding GVK (GroupVersionKind) in manifest.TransformAllowlist and manifest.TransformDenylist.

My solution is to pass ConsolidateTransformConfiguration into the NewResourceSelectorImages method because we can configure resourceSelector in the skaffold.yaml file.

@codecov
Copy link

codecov bot commented Oct 16, 2023

Codecov Report

Attention: 295 lines in your changes are missing coverage. Please review.

Comparison is base (290280e) 70.48% compared to head (2e15716) 63.71%.
Report is 1068 commits behind head on main.

Files Patch % Lines
cmd/skaffold/app/cmd/exec.go 16.32% 40 Missing and 1 partial ⚠️
cmd/skaffold/app/cmd/filter.go 47.27% 22 Missing and 7 partials ⚠️
cmd/skaffold/app/cmd/lsp.go 28.12% 23 Missing ⚠️
cmd/skaffold/app/cmd/verify.go 23.33% 23 Missing ⚠️
cmd/skaffold/app/cmd/fix.go 51.16% 17 Missing and 4 partials ⚠️
cmd/skaffold/app/cmd/inspect_job_manifest_paths.go 60.00% 15 Missing and 1 partial ⚠️
cmd/skaffold/app/cmd/inspect_namespaces.go 50.00% 13 Missing and 1 partial ⚠️
...md/skaffold/app/cmd/inspect_config_dependencies.go 45.83% 12 Missing and 1 partial ⚠️
cmd/skaffold/app/cmd/lint.go 42.85% 12 Missing ⚠️
cmd/skaffold/app/cmd/inspect_build_env.go 60.71% 11 Missing ⚠️
... and 21 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9136      +/-   ##
==========================================
- Coverage   70.48%   63.71%   -6.77%     
==========================================
  Files         515      630     +115     
  Lines       23150    32447    +9297     
==========================================
+ Hits        16317    20674    +4357     
- Misses       5776    10183    +4407     
- Partials     1057     1590     +533     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@beastpu beastpu force-pushed the fix-custom-crd-not-printing-logs branch from fca1c2b to b4a1a0b Compare October 17, 2023 01:48
@beastpu beastpu changed the title fix custom crd not printing streams logs fix: custom crd not printing streams logs Nov 10, 2023
@renzodavid9 renzodavid9 added the kokoro:force-run forces a kokoro re-run on a PR label Nov 20, 2023
@kokoro-team kokoro-team removed the kokoro:force-run forces a kokoro re-run on a PR label Nov 20, 2023
Copy link
Contributor

@renzodavid9 renzodavid9 left a comment

Choose a reason for hiding this comment

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

Hey @beastpu! Thanks for opening this PR. I left a comment for one more place we need to update the resource lists.

Checking the change, I think I found a case where still we'll not be able to get the logs: when the CRD uses a field different than image to define the image to deploy. When we are going through the manifests to get the images, Skaffold is looking for the specific image field:

func (is *imageSaver) Visit(gk apimachinery.GroupKind, navpath string, o map[string]interface{}, k string, v interface{}, rs ResourceSelector) bool {
if k != imageField {
return true
}

I think the proper way here would be to use the selectors defined in the resourceSelector from the skaffold.yaml.

With that said, I'll create another issue to track that case and tackle that in another PR; I think we can merge this PR once we have the last change from the comment I left. Thanks a lot for your help! 😄

pkg/skaffold/deploy/helm/helm.go Show resolved Hide resolved
@renzodavid9 renzodavid9 added the kokoro:force-run forces a kokoro re-run on a PR label Nov 22, 2023
@kokoro-team kokoro-team removed the kokoro:force-run forces a kokoro re-run on a PR label Nov 22, 2023
@renzodavid9 renzodavid9 merged commit 0a866ae into GoogleContainerTools:main Nov 22, 2023
16 checks passed
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.

3 participants