|
| 1 | +/* |
| 2 | +Copyright 2021 The Kubernetes Authors All rights reserved. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package reason |
| 18 | + |
| 19 | +import "github.com/blang/semver" |
| 20 | + |
| 21 | +// K8sIssue represents a known issue with a particular version of Kubernetes |
| 22 | +type K8sIssue struct { |
| 23 | + // VersionAffected is the list of Kubernetes versions that has a particular issue |
| 24 | + VersionsAffected []string |
| 25 | + // Description is what will be printed to the user describing the issue |
| 26 | + Description string |
| 27 | + // URL is a link to an issue or documentation about the issue, optional. |
| 28 | + URL string |
| 29 | +} |
| 30 | + |
| 31 | +var k8sIssues = []K8sIssue{ |
| 32 | + { |
| 33 | + VersionsAffected: []string{ |
| 34 | + "1.18.16", |
| 35 | + "1.18.17", |
| 36 | + "1.19.8", |
| 37 | + "1.19.9", |
| 38 | + "1.20.3", |
| 39 | + "1.20.4", |
| 40 | + "1.20.5", |
| 41 | + "1.21.0", |
| 42 | + }, |
| 43 | + Description: "Kubernetes {{.version}} has a known performance issue on cluster startup. It might take 2 to 3 minutes for a cluster to start.", |
| 44 | + URL: "https://github.com/kubernetes/kubeadm/issues/2395", |
| 45 | + }, |
| 46 | +} |
| 47 | + |
| 48 | +// ProblematicK8sVersion checks for the supplied Kubernetes version and checks if there's a known issue with it. |
| 49 | +func ProblematicK8sVersion(v semver.Version) *K8sIssue { |
| 50 | + for _, issue := range k8sIssues { |
| 51 | + for _, va := range issue.VersionsAffected { |
| 52 | + if va == v.String() { |
| 53 | + return &issue |
| 54 | + } |
| 55 | + } |
| 56 | + } |
| 57 | + return nil |
| 58 | +} |
0 commit comments