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 sidecarset hash without image is calculated differently when changing image tag to latest #1697

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chengjoey
Copy link
Contributor

Ⅰ. Describe what this PR does

func setDefaultContainer(sidecarContainer *v1alpha1.SidecarContainer) {
container := &sidecarContainer.Container
v1.SetDefaults_Container(container)
for i := range container.Ports {

https://github.com/kubernetes/kubernetes/blob/60c4c2b2521fb454ce69dee737e3eb91a25e0535/pkg/apis/core/v1/defaults.go#L73-L78

when change image tag to latest, the sidecarset without image hash will be changed
I think ImagePullPolicy should not be involved in the hash, because it will cause the hash to change, causing the pod not to to be upgraded

Ⅱ. Does this pull request fix one issue?

Ⅲ. Describe how to verify it

apiVersion: apps.kruise.io/v1alpha1
kind: SidecarSet
metadata:
  name: sidecarset
spec:
  selector:
    matchLabels:
      app: sample
  containers:
  - name: nginx
    image: nginx:1.19.6
  updateStrategy:
    type: RollingUpdate

change 1.19.6 to latest
This is the change I printed that participates in the hash calculation
IfNotPresent -> Always

{
    "containers": [
        {
            "name": "nginx",
            "resources": {},
            "terminationMessagePath": "/dev/termination-log",
            "terminationMessagePolicy": "File",
            "imagePullPolicy": "IfNotPresent",
            "podInjectPolicy": "BeforeAppContainer",
            "upgradeStrategy": {
                "upgradeType": "ColdUpgrade"
            },
            "shareVolumePolicy": {
                "type": "disabled"
            }
        }
    ]
}

{
    "containers": [
        {
            "name": "nginx",
            "resources": {},
            "terminationMessagePath": "/dev/termination-log",
            "terminationMessagePolicy": "File",
            "imagePullPolicy": "Always",
            "podInjectPolicy": "BeforeAppContainer",
            "upgradeStrategy": {
                "upgradeType": "ColdUpgrade"
            },
            "shareVolumePolicy": {
                "type": "disabled"
            }
        }
    ]
}

Ⅳ. Special notes for reviews

@kruise-bot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign fei-guo for approval by writing /assign @fei-guo in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kruise-bot kruise-bot added the size/XS size/XS: 0-9 label Aug 6, 2024
Copy link

codecov bot commented Aug 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 48.86%. Comparing base (0d0031a) to head (98d0f9d).
Report is 64 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1697      +/-   ##
==========================================
+ Coverage   47.91%   48.86%   +0.95%     
==========================================
  Files         162      188      +26     
  Lines       23491    19291    -4200     
==========================================
- Hits        11256     9427    -1829     
+ Misses      11014     8633    -2381     
- Partials     1221     1231      +10     
Flag Coverage Δ
unittests 48.86% <100.00%> (+0.95%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@chengjoey
Copy link
Contributor Author

@zmberg @furykerry , could you please take a look, because changing the image tag to latest will cause the pod to fail to update, I think imagePolicy should not be included in the calculation, and imagePolicy is easily affected by the mutation controller

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XS size/XS: 0-9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants