Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion istio.deps
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "PROXY_REPO_SHA",
"repoName": "proxy",
"file": "",
"lastStableSHA": "b080ac27d39c8adcaf0be843a55e8c080cbde7f9"
"lastStableSHA": "30e213147c5e54158b6176417c39c46eca60c580"
},
{
"_comment": "",
Expand Down
25 changes: 16 additions & 9 deletions pkg/config/analysis/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,29 @@ type Analyzer interface {
Analyze(c Context)
}

// CombinedAnalyzer is a special Analyzer that combines multiple analyzers into one
type CombinedAnalyzer struct {
type CombinedAnalyzer interface {
Analyzer
RelevantSubset(kinds sets.Set[config.GroupVersionKind]) CombinedAnalyzer
RemoveSkipped(schemas collection.Schemas) []string
AnalyzerNames() []string
}

// InternalCombinedAnalyzer is a special Analyzer that combines multiple analyzers into one
type InternalCombinedAnalyzer struct {
name string
analyzers []Analyzer
}

// Combine multiple analyzers into a single one.
// For input metadata, use the union of the component analyzers
func Combine(name string, analyzers ...Analyzer) *CombinedAnalyzer {
return &CombinedAnalyzer{
func Combine(name string, analyzers ...Analyzer) CombinedAnalyzer {
return &InternalCombinedAnalyzer{
name: name,
analyzers: analyzers,
}
}

func (c *CombinedAnalyzer) RelevantSubset(kinds sets.Set[config.GroupVersionKind]) *CombinedAnalyzer {
func (c *InternalCombinedAnalyzer) RelevantSubset(kinds sets.Set[config.GroupVersionKind]) CombinedAnalyzer {
var selected []Analyzer
for _, a := range c.analyzers {
for _, inputKind := range a.Metadata().Inputs {
Expand All @@ -56,15 +63,15 @@ func (c *CombinedAnalyzer) RelevantSubset(kinds sets.Set[config.GroupVersionKind
}

// Metadata implements Analyzer
func (c *CombinedAnalyzer) Metadata() Metadata {
func (c *InternalCombinedAnalyzer) Metadata() Metadata {
return Metadata{
Name: c.name,
Inputs: combineInputs(c.analyzers),
}
}

// Analyze implements Analyzer
func (c *CombinedAnalyzer) Analyze(ctx Context) {
func (c *InternalCombinedAnalyzer) Analyze(ctx Context) {
for _, a := range c.analyzers {
scope.Analysis.Debugf("Started analyzer %q...", a.Metadata().Name)
if ctx.Canceled() {
Expand All @@ -82,7 +89,7 @@ func (c *CombinedAnalyzer) Analyze(ctx Context) {
// Transformer information is used to determine, based on the disabled input collections, which output collections
// should be disabled. Any analyzers that require those output collections will be removed.
// 2. The analyzer requires a collection not available in the current snapshot(s)
func (c *CombinedAnalyzer) RemoveSkipped(schemas collection.Schemas) []string {
func (c *InternalCombinedAnalyzer) RemoveSkipped(schemas collection.Schemas) []string {
allSchemas := schemas.All()
s := sets.NewWithLength[config.GroupVersionKind](len(allSchemas))
for _, sc := range allSchemas {
Expand All @@ -109,7 +116,7 @@ mainloop:
}

// AnalyzerNames returns the names of analyzers in this combined analyzer
func (c *CombinedAnalyzer) AnalyzerNames() []string {
func (c *InternalCombinedAnalyzer) AnalyzerNames() []string {
result := make([]string, 0, len(c.analyzers))
for _, a := range c.analyzers {
result = append(result, a.Metadata().Name)
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/analysis/analyzers/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ func All() []analysis.Analyzer {
}

// AllCombined returns all analyzers combined as one
func AllCombined() *analysis.CombinedAnalyzer {
func AllCombined() analysis.CombinedAnalyzer {
return analysis.Combine("all", All()...)
}
7 changes: 7 additions & 0 deletions pkg/config/analysis/analyzers/annotations/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"istio.io/istio/pkg/config/schema/gvk"
"istio.io/istio/pkg/kube/inject"
"istio.io/istio/pkg/slices"
"istio.io/istio/pkg/config/analysis/diag"
)

// K8sAnalyzer checks for misplaced and invalid Istio annotations in K8s resources
Expand All @@ -46,6 +47,12 @@ func (*K8sAnalyzer) Metadata() analysis.Metadata {
gvk.Pod,
gvk.Deployment,
},
MessageTypes: []*diag.MessageType{
msg.UnknownAnnotation,
msg.DeprecatedAnnotation,
msg.MisplacedAnnotation,
msg.InvalidAnnotation,
},
}
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/config/analysis/analyzers/authz/authorizationpolicies.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"istio.io/istio/pkg/config/analysis/msg"
"istio.io/istio/pkg/config/resource"
"istio.io/istio/pkg/config/schema/gvk"
"istio.io/istio/pkg/config/analysis/diag"
)

// AuthorizationPoliciesAnalyzer checks the validity of authorization policies
Expand All @@ -48,6 +49,10 @@ func (a *AuthorizationPoliciesAnalyzer) Metadata() analysis.Metadata {
gvk.Namespace,
gvk.Pod,
},
MessageTypes: []*diag.MessageType{
msg.NoMatchingWorkloadsFound,
msg.ReferencedResourceNotFound,
},
}
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/config/analysis/analyzers/deployment/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"istio.io/istio/pkg/config/analysis/msg"
"istio.io/istio/pkg/config/resource"
"istio.io/istio/pkg/config/schema/gvk"
"istio.io/istio/pkg/config/analysis/diag"
)

type ApplicationUIDAnalyzer struct{}
Expand All @@ -42,6 +43,9 @@ func (appUID *ApplicationUIDAnalyzer) Metadata() analysis.Metadata {
gvk.Pod,
gvk.Deployment,
},
MessageTypes: []*diag.MessageType{
msg.InvalidApplicationUID,
},
}
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/config/analysis/analyzers/deployment/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"istio.io/istio/pkg/config/constants"
"istio.io/istio/pkg/config/resource"
"istio.io/istio/pkg/config/schema/gvk"
"istio.io/istio/pkg/config/analysis/diag"
)

type ServiceAssociationAnalyzer struct{}
Expand Down Expand Up @@ -56,6 +57,10 @@ func (s *ServiceAssociationAnalyzer) Metadata() analysis.Metadata {
gvk.Deployment,
gvk.Namespace,
},
MessageTypes: []*diag.MessageType{
msg.DeploymentAssociatedToMultipleServices,
msg.DeploymentConflictingPorts,
},
}
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/config/analysis/analyzers/deprecation/deprecation.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"istio.io/istio/pkg/config/analysis/msg"
"istio.io/istio/pkg/config/resource"
"istio.io/istio/pkg/config/schema/gvk"
"istio.io/istio/pkg/config/analysis/diag"
)

// FieldAnalyzer checks for deprecated Istio types and fields
Expand Down Expand Up @@ -66,6 +67,9 @@ func (*FieldAnalyzer) Metadata() analysis.Metadata {
Name: "deprecation.DeprecationAnalyzer",
Description: "Checks for deprecated Istio types and fields",
Inputs: deprecationInputs,
MessageTypes: []*diag.MessageType{
msg.Deprecated,
},
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"istio.io/istio/pkg/config/analysis/msg"
"istio.io/istio/pkg/config/resource"
"istio.io/istio/pkg/config/schema/gvk"
"istio.io/istio/pkg/config/analysis/diag"
)

// CaCertificateAnalyzer checks if CaCertificate is set in case mode is SIMPLE/MUTUAL
Expand All @@ -38,6 +39,10 @@ func (c *CaCertificateAnalyzer) Metadata() analysis.Metadata {
Inputs: []config.GroupVersionKind{
gvk.DestinationRule,
},
MessageTypes: []*diag.MessageType{
msg.NoServerCertificateVerificationDestinationLevel,
msg.NoServerCertificateVerificationPortLevel,
},
}
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/config/analysis/analyzers/envoyfilter/envoyfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"istio.io/istio/pkg/config/analysis/msg"
"istio.io/istio/pkg/config/resource"
"istio.io/istio/pkg/config/schema/gvk"
"istio.io/istio/pkg/config/analysis/diag"
)

// EnvoyPatchAnalyzer checks envoyFilters to see if the patch section is okay
Expand All @@ -40,6 +41,10 @@ func (*EnvoyPatchAnalyzer) Metadata() analysis.Metadata {
Inputs: []config.GroupVersionKind{
gvk.EnvoyFilter,
},
MessageTypes: []*diag.MessageType{
msg.EnvoyFilterUsesRelativeOperation,
msg.EnvoyFilterUsesRelativeOperationWithProxyVersion,
},
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"istio.io/istio/pkg/config/resource"
"istio.io/istio/pkg/config/schema/gvk"
"istio.io/istio/pkg/slices"
"istio.io/istio/pkg/config/analysis/diag"
)

type ExternalControlPlaneAnalyzer struct{}
Expand All @@ -42,6 +43,10 @@ func (s *ExternalControlPlaneAnalyzer) Metadata() analysis.Metadata {
gvk.ValidatingWebhookConfiguration,
gvk.MutatingWebhookConfiguration,
},
MessageTypes: []*diag.MessageType{
msg.ExternalControlPlaneAddressIsNotAHostname,
msg.InvalidExternalControlPlaneConfig,
},
}
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/config/analysis/analyzers/gateway/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"istio.io/istio/pkg/config/analysis/msg"
"istio.io/istio/pkg/config/resource"
"istio.io/istio/pkg/config/schema/gvk"
"istio.io/istio/pkg/config/analysis/diag"
)

type CertificateAnalyzer struct{}
Expand All @@ -36,6 +37,9 @@ func (*CertificateAnalyzer) Metadata() analysis.Metadata {
Inputs: []config.GroupVersionKind{
gvk.Gateway,
},
MessageTypes: []*diag.MessageType{
msg.GatewayDuplicateCertificate,
},
}
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/config/analysis/analyzers/gateway/conflictinggateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"istio.io/istio/pkg/config/host"
"istio.io/istio/pkg/config/resource"
"istio.io/istio/pkg/config/schema/gvk"
"istio.io/istio/pkg/config/analysis/diag"
)

// ConflictingGatewayAnalyzer checks a gateway's selector, port number and hosts.
Expand All @@ -45,6 +46,10 @@ func (*ConflictingGatewayAnalyzer) Metadata() analysis.Metadata {
Inputs: []config.GroupVersionKind{
gvk.Gateway,
},
MessageTypes: []*diag.MessageType{
msg.ReferencedResourceNotFound,
msg.ConflictingGateways,
},
}
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/config/analysis/analyzers/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"istio.io/istio/pkg/config/analysis/msg"
"istio.io/istio/pkg/config/resource"
"istio.io/istio/pkg/config/schema/gvk"
"istio.io/istio/pkg/config/analysis/diag"
)

// IngressGatewayPortAnalyzer checks a gateway's ports against the gateway's Kubernetes service ports.
Expand All @@ -45,6 +46,10 @@ func (*IngressGatewayPortAnalyzer) Metadata() analysis.Metadata {
gvk.Pod,
gvk.Service,
},
MessageTypes: []*diag.MessageType{
msg.ReferencedResourceNotFound,
msg.GatewayPortNotDefinedOnService,
},
}
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/config/analysis/analyzers/gateway/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"istio.io/istio/pkg/config/analysis/msg"
"istio.io/istio/pkg/config/resource"
"istio.io/istio/pkg/config/schema/gvk"
"istio.io/istio/pkg/config/analysis/diag"
)

// SecretAnalyzer checks a gateway's referenced secrets for correctness
Expand All @@ -46,6 +47,10 @@ func (a *SecretAnalyzer) Metadata() analysis.Metadata {
gvk.Pod,
gvk.Secret,
},
MessageTypes: []*diag.MessageType{
msg.ReferencedResourceNotFound,
msg.InvalidGatewayCredential,
},
}
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/config/analysis/analyzers/injection/image-auto.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"istio.io/istio/pkg/config/analysis/msg"
"istio.io/istio/pkg/config/resource"
"istio.io/istio/pkg/config/schema/gvk"
"istio.io/istio/pkg/config/analysis/diag"
)

// ImageAutoAnalyzer reports an error if Pods and Deployments with `image: auto` are not going to be injected.
Expand All @@ -51,6 +52,10 @@ func (a *ImageAutoAnalyzer) Metadata() analysis.Metadata {
gvk.Deployment,
gvk.MutatingWebhookConfiguration,
},
MessageTypes: []*diag.MessageType{
msg.ImageAutoWithoutInjectionError,
msg.ImageAutoWithoutInjectionWarning,
},
}
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/config/analysis/analyzers/injection/injection-image.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"istio.io/istio/pkg/config/resource"
"istio.io/istio/pkg/config/schema/gvk"
"istio.io/istio/pkg/slices"
"istio.io/istio/pkg/config/analysis/diag"
)

// ImageAnalyzer checks the image of auto-injection configured with the running proxies on pods.
Expand Down Expand Up @@ -60,6 +61,9 @@ func (a *ImageAnalyzer) Metadata() analysis.Metadata {
gvk.Pod,
gvk.ConfigMap,
},
MessageTypes: []*diag.MessageType{
msg.PodsIstioProxyImageMismatchInNamespace,
},
}
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/config/analysis/analyzers/injection/injection.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"istio.io/istio/pkg/config/resource"
"istio.io/istio/pkg/config/schema/gvk"
"istio.io/istio/pkg/slices"
"istio.io/istio/pkg/config/analysis/diag"
)

// Analyzer checks conditions related to Istio sidecar injection.
Expand All @@ -55,6 +56,12 @@ func (a *Analyzer) Metadata() analysis.Metadata {
gvk.Pod,
gvk.ConfigMap,
},
MessageTypes: []*diag.MessageType{
msg.NamespaceMultipleInjectionLabels,
msg.NamespaceInjectionEnabledByDefault,
msg.NamespaceNotInjected,
msg.PodMissingProxy,
},
}
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/config/analysis/analyzers/maturity/maturity.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"istio.io/istio/pkg/config/constants"
"istio.io/istio/pkg/config/resource"
"istio.io/istio/pkg/config/schema/gvk"
"istio.io/istio/pkg/config/analysis/diag"
)

// AlphaAnalyzer checks for alpha Istio annotations in K8s resources
Expand All @@ -49,6 +50,9 @@ func (*AlphaAnalyzer) Metadata() analysis.Metadata {
gvk.Pod,
gvk.Deployment,
},
MessageTypes: []*diag.MessageType{
msg.AlphaAnnotation,
},
}
}

Expand Down
Loading