Skip to content

Commit b8a311f

Browse files
author
openshift-service-mesh-bot
committed
Automator: merge upstream changes to openshift-service-mesh/istio@master
* upstream/master: (47 commits) addons: Bump addons version (#57887) Gateway: bump to v1.4.0 (#57873) Automator: update proxy@master in istio/istio@master (#57882) move stat prefix to constants (#57879) Handle istio-cni cleanup on node restart (#57456) add stat prefix for WASM default RBAC filters (#57824) Automator: update proxy@master in istio/istio@master (#57875) Update the comments to match the iptables selection logic (#57876) Automator: update proxy@master in istio/istio@master (#57872) Automator: update proxy@master in istio/istio@master (#57870) Automator: update ztunnel@master in istio/istio@master (#57857) Security/check sa for gw secrets (#57716) Automator: update proxy@master in istio/istio@master (#57865) Automator: update proxy@master in istio/istio@master (#57856) Automator: update ztunnel@master in istio/istio@master (#57845) Automator: update proxy@master in istio/istio@master (#57850) Automator: update istio/client-go@master dependency in istio/istio@master (#57848) Remove use of comment module when testing kernel support for iptables version (#57679) Update BASE_VERSION to master-2025-10-01T19-01-35 (#57841) Automator: update istio/client-go@master dependency in istio/istio@master (#57828) ...
2 parents db76426 + 36de920 commit b8a311f

File tree

327 files changed

+14967
-11018
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

327 files changed

+14967
-11018
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "istio build-tools",
3-
"image": "gcr.io/istio-testing/build-tools:master-2683149c033b2b71ab460170c3045ae85727306e",
3+
"image": "gcr.io/istio-testing/build-tools:master-6ac9cdb3d1ad09092398ab15574ce88cf2ac31ff",
44
"privileged": true,
55
"remoteEnv": {
66
"USE_GKE_GCLOUD_AUTH_PLUGIN": "True",

Makefile.core.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ endif
4949
export VERSION
5050

5151
# Base version of Istio image to use
52-
BASE_VERSION ?= master-2025-09-23T19-02-05
52+
BASE_VERSION ?= master-2025-10-01T19-01-35
5353
ISTIO_BASE_REGISTRY ?= gcr.io/istio-release
5454

5555
export GO111MODULE ?= on

cni/pkg/cmd/root.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,25 +133,27 @@ var rootCmd = &cobra.Command{
133133
// if it is, we do NOT remove the plugin, and do
134134
// NOT do ambient watch server cleanup
135135
defer func() {
136-
var isUpgrade bool
136+
var shouldStopCleanup bool
137137
if cfg.InstallConfig.AmbientDisableSafeUpgrade {
138138
log.Info("Ambient node agent safe upgrade explicitly disabled via env")
139-
isUpgrade = false
139+
shouldStopCleanup = false
140140
} else {
141-
isUpgrade = ambientAgent.ShouldStopForUpgrade("istio-cni", nodeagent.PodNamespace)
141+
shouldStopCleanup = ambientAgent.ShouldStopCleanup("istio-cni", nodeagent.PodNamespace, cfg.InstallConfig.IstioOwnedCNIConfig)
142142
}
143-
log.Infof("Ambient node agent shutting down - is upgrade shutdown? %t", isUpgrade)
143+
log.Infof("Ambient node agent shutting down - should stop cleanup? %t", shouldStopCleanup)
144+
145+
// TODO(jaellio) - do we want to add support for a partial cleanup
144146
// if we are doing an "upgrade shutdown", then
145147
// we do NOT want to remove/cleanup the CNI plugin.
146148
//
147149
// This is important - we want it to remain in place to "stall"
148150
// new ambient-enabled pods while our replacement spins up.
149-
if !isUpgrade {
151+
if !shouldStopCleanup {
150152
if cleanErr := installer.Cleanup(); cleanErr != nil {
151153
log.Error(cleanErr.Error())
152154
}
153155
}
154-
ambientAgent.Stop(isUpgrade)
156+
ambientAgent.Stop(shouldStopCleanup)
155157
}()
156158

157159
ambientAgent.Start()

cni/pkg/install/testdata/kubeconfig-newhost

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ contexts:
1111
name: istio-cni-context
1212
current-context: istio-cni-context
1313
kind: Config
14-
preferences: {}
1514
users:
1615
- name: istio-cni
1716
user:

cni/pkg/install/testdata/kubeconfig-skip-tls

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ contexts:
1111
name: istio-cni-context
1212
current-context: istio-cni-context
1313
kind: Config
14-
preferences: {}
1514
users:
1615
- name: istio-cni
1716
user:

cni/pkg/install/testdata/kubeconfig-tls

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ contexts:
1111
name: istio-cni-context
1212
current-context: istio-cni-context
1313
kind: Config
14-
preferences: {}
1514
users:
1615
- name: istio-cni
1716
user:

cni/pkg/nodeagent/informers_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func TestInformerExistingPodAddErrorAnnotatesWithPartialStatusOnRetry(t *testing
176176
client := kube.NewFakeClient(ns, pod)
177177
fs := &fakeServer{}
178178

179-
fs.On("AddPodToMesh",
179+
call := fs.On("AddPodToMesh",
180180
ctx,
181181
mock.IsType(pod),
182182
util.GetPodIPsIfPresent(pod),
@@ -201,6 +201,11 @@ func TestInformerExistingPodAddErrorAnnotatesWithPartialStatusOnRetry(t *testing
201201

202202
assertPodAnnotatedPending(t, client, pod)
203203

204+
// allow the call to succeed, this will stop further retry events from occurring
205+
call.Return(nil)
206+
// assert that the pod has been annotated before we proceed
207+
assertPodAnnotated(t, client, pod)
208+
204209
// Assert expected calls actually made
205210
fs.AssertExpectations(t)
206211
}

cni/pkg/nodeagent/server.go

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ import (
2121
"sync/atomic"
2222
"time"
2323

24+
"github.com/cenkalti/backoff/v4"
2425
corev1 "k8s.io/api/core/v1"
26+
"k8s.io/apimachinery/pkg/api/errors"
2527
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2628
"k8s.io/client-go/rest"
2729

@@ -31,7 +33,10 @@ import (
3133

3234
const defaultZTunnelKeepAliveCheckInterval = 5 * time.Second
3335

34-
var log = scopes.CNIAgent
36+
var (
37+
log = scopes.CNIAgent
38+
tokenWaitBackoff = time.Second
39+
)
3540

3641
type MeshDataplane interface {
3742
// MUST be called first, (even before Start()).
@@ -119,18 +124,47 @@ func (s *Server) Stop(skipCleanup bool) {
119124
s.dataplane.Stop(skipCleanup)
120125
}
121126

122-
func (s *Server) ShouldStopForUpgrade(selfName, selfNamespace string) bool {
127+
// ShouldStopCleanup of istio-cni config and binary when upgrading or on node reboot
128+
func (s *Server) ShouldStopCleanup(selfName, selfNamespace string, istioOwnedCNIConfig bool) bool {
123129
dsName := fmt.Sprintf("%s-node", selfName)
124-
cniDS, err := s.kubeClient.Kube().AppsV1().DaemonSets(selfNamespace).Get(context.Background(), dsName, metav1.GetOptions{})
125-
log.Debugf("Daemonset %s has deletion timestamp?: %+v", dsName, cniDS.DeletionTimestamp)
126-
if err == nil && cniDS != nil && cniDS.DeletionTimestamp == nil {
127-
log.Infof("terminating, but parent DS %s is still present, this is an upgrade, leaving plugin in place", dsName)
128-
return true
130+
shouldStopCleanup := false
131+
var numRetries uint64
132+
// use different defaults when using an istio owned CNI config file
133+
if istioOwnedCNIConfig {
134+
shouldStopCleanup = true
135+
numRetries = 2
129136
}
130-
131-
// If the DS is gone, it's definitely not an upgrade, so carry on like normal.
132-
log.Infof("parent DS %s is gone or marked for deletion, this is not an upgrade, shutting down normally %s", dsName, err)
133-
return false
137+
err := backoff.Retry(
138+
func() error {
139+
cniDS, err := s.kubeClient.Kube().AppsV1().DaemonSets(selfNamespace).Get(context.Background(), dsName, metav1.GetOptions{})
140+
141+
if err == nil && cniDS != nil && cniDS.DeletionTimestamp == nil {
142+
log.Infof("terminating, but parent DaemonSet %s is still present, this is an upgrade or a node reboot, leaving plugin in place", dsName)
143+
shouldStopCleanup = true
144+
return nil
145+
}
146+
if errors.IsNotFound(err) || (cniDS != nil && cniDS.DeletionTimestamp != nil) {
147+
// If the DS is gone, or marked for deletion, this is not an upgrade.
148+
// We can safely shut down the plugin.
149+
log.Infof("parent DaemonSet %s is not found or marked for deletion, this is not an upgrade, shutting down normally", dsName)
150+
shouldStopCleanup = false
151+
return nil
152+
}
153+
if errors.IsUnauthorized(err) {
154+
log.Infof("permission to get parent DaemonSet %s has been revoked manually or due to uninstall, this is not an upgrade, "+
155+
"shutting down normally", dsName)
156+
shouldStopCleanup = false
157+
return nil
158+
}
159+
log.Infof("failed to get parent DS %s, retrying: %v", dsName, err)
160+
return err
161+
},
162+
// Limiting retries to 3 so other shutdown tasks can complete before the graceful shutdown period ends
163+
backoff.WithMaxRetries(backoff.NewConstantBackOff(tokenWaitBackoff), numRetries))
164+
if err != nil {
165+
log.Infof("failed to get parent DaemonSet %s, returning %t: %v", dsName, shouldStopCleanup, err)
166+
}
167+
return shouldStopCleanup
134168
}
135169

136170
// buildKubeClient creates the kube client

cni/pkg/plugin/plugin.go

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -164,23 +164,26 @@ func CmdAdd(args *skel.CmdArgs) (err error) {
164164
return err
165165
}
166166

167+
// Preemptively check if the pod is a CNI pod.
168+
// It is possible that the kubeconfig is not available if it hasn't been written yet
169+
// by the CNI pod or it is invalid which cause the CNI pod to be unable to start if
170+
// on the creation of a new K8s client. We preemptively check if the pod is a CNI pod
171+
// to avoid a deadlock on the kubeconfig when the k8s client is unnecessary to process
172+
// the CNI add event for the CNI pod itself.
173+
if conf.AmbientEnabled {
174+
k8sArgs := K8sArgs{}
175+
if err := types.LoadArgs(args.Args, &k8sArgs); err != nil {
176+
return fmt.Errorf("failed to load args: %v", err)
177+
}
178+
if isCNIPod(conf, &k8sArgs) {
179+
// If we are in a degraded state and this is our own agent pod, skip
180+
return pluginResponse(conf)
181+
}
182+
}
183+
167184
// Create a kube client
168185
client, err := newK8sClient(*conf)
169-
// If creation of a kube client fails, check if the pod is a CNI pod.
170-
// It is possible that the kubeconfig is not available if it hasn't been written yet
171-
// by the CNI pod which could be unable to start if we failed here. We skip this
172-
// failure for the CNI pod to avoid a deadlock.
173186
if err != nil {
174-
if conf.AmbientEnabled {
175-
k8sArgs := K8sArgs{}
176-
if err := types.LoadArgs(args.Args, &k8sArgs); err != nil {
177-
return fmt.Errorf("failed to load args after failed attempt to get client: %v", err)
178-
}
179-
if isCNIPod(conf, &k8sArgs) {
180-
// If we are in a degraded state and this is our own agent pod, skip
181-
return pluginResponse(conf)
182-
}
183-
}
184187
return fmt.Errorf("failed to createNewK8sClient: %v", err)
185188
}
186189

@@ -404,6 +407,6 @@ func isCNIPod(conf *Config, k8sArgs *K8sArgs) bool {
404407
log.Infof("in a degraded state and %v looks like our own agent pod, skipping", k8sArgs.K8S_POD_NAME)
405408
return true
406409
}
407-
log.Warnf("not a CNI pod, podName: %s, podNamespace: %s", k8sArgs.K8S_POD_NAME, k8sArgs.K8S_POD_NAMESPACE)
410+
log.Warnf("not a CNI pod, podName: %s, podNamespace: %s, conf pod namespace: %s", k8sArgs.K8S_POD_NAME, k8sArgs.K8S_POD_NAMESPACE, conf.PodNamespace)
408411
return false
409412
}

common/.commonfiles.sha

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c858f8951846005d3976c045fa3eae390d29a251
1+
be6513cc1433076ebdb636af99c9b171d9a36f27

0 commit comments

Comments
 (0)