istio.io/istio@v0.0.0-20240520182934-d79c90f27776/operator/pkg/controller/istiocontrolplane/errdict.go (about) 1 // Copyright Istio Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package istiocontrolplane 16 17 import ( 18 "strings" 19 20 "istio.io/istio/pkg/structured" 21 ) 22 23 const ( 24 LikelyCauseFirstPrefix = "The likely cause is " 25 LikelyCauseSecondPrefix = "Another possible cause could be " 26 ) 27 28 // General boilerplate. 29 const ( 30 // Boilerplate messages applicable all over the code base. 31 32 // Action 33 actionIfErrPersistsCheckBugList = "If this error persists, " + actionCheckBugList 34 actionIfErrSureCorrectConfigContactSupport = "If you are sure your configuration is correct, " + actionCheckBugList 35 actionCheckBugList = "see https://istio.io/latest/about/bugs for possible solutions." 36 37 // LikelyCause 38 likelyCauseAPIServer = "a problem with the Kubernetes API server" 39 likelyCauseConfiguration = "an incorrect or badly formatted configuration" 40 likelyCauseSoftwareBug = "an issue with the Istio code" 41 42 // Is the error permanent? 43 transiencePermanentForInstall = "If the error occurred immediately after installation, it is likely permanent." 44 ) 45 46 // Operator specific 47 const ( 48 // Impact 49 operatorImpactFailedToGetObjectFromAPIServer = "If the error is transient, the impact is low. If permanent, " + 50 "updates for the objects cannot be processed leading to an out of sync control plane." 51 operatorImpactNoUpdates = "In this error state, changes to the IstioOperator CR will not result in the Istio " + 52 "control plane being updated." 53 ) 54 55 var ( 56 operatorFailedToGetObjectFromAPIServer = &structured.Error{ 57 MoreInfo: "Failed to get an object from the Kubernetes API server, because of a transient " + 58 "API server error or the object no longer exists.", 59 Impact: operatorImpactFailedToGetObjectFromAPIServer, 60 LikelyCause: formatCauses(likelyCauseAPIServer) + " " + transiencePermanentForInstall, 61 Action: "If the error is because the object was deleted, it can be safely ignored. Otherwise, if the " + 62 "error persists, " + actionCheckBugList, 63 } 64 operatorFailedToAddFinalizer = &structured.Error{ 65 MoreInfo: "A finalizer could not be added to the IstioOperator resource. The " + 66 "controller uses the finalizer to temporarily prevent the resource from being deleted while the Istio " + 67 "control plane is being deleted.", 68 Impact: "When the IstioOperator resource is deleted, the Istio control plane may " + 69 "not be fully removed.", 70 LikelyCause: formatCauses(likelyCauseAPIServer), 71 Action: "Delete and re-add the IstioOperator resource. " + actionIfErrPersistsCheckBugList, 72 } 73 operatorFailedToRemoveFinalizer = &structured.Error{ 74 MoreInfo: "The finalizer set by the operator controller could not be removed " + 75 "when the IstioOperator resource was deleted.", 76 Impact: "The IstioOperator resource can not be removed by the operator controller.", 77 LikelyCause: formatCauses(likelyCauseAPIServer), 78 Action: "Remove the IstioOperator resource finalizer manually using kubectl edit.", 79 } 80 operatorFailedToMergeUserIOP = &structured.Error{ 81 MoreInfo: "The values in the selected spec.profile could not be merged with " + 82 "the user IstioOperator resource.", 83 Impact: "The operator controller cannot create and act upon the user " + 84 "defined IstioOperator resource. The Istio control plane will not be installed or updated.", 85 LikelyCause: formatCauses(likelyCauseConfiguration, likelyCauseSoftwareBug), 86 Action: "Check that the IstioOperator resource has the correct syntax. " + 87 actionIfErrSureCorrectConfigContactSupport, 88 } 89 operatorFailedToConfigure = &structured.Error{ 90 MoreInfo: "the IstioOperator Resource could not be applied on the cluster " + 91 "because of incompatible Kubernetes settings", 92 Impact: operatorImpactNoUpdates, 93 LikelyCause: formatCauses(likelyCauseConfiguration), 94 Action: "Ensure that IstioOperator config is compatible with current Kubernetes version." + 95 actionIfErrSureCorrectConfigContactSupport, 96 } 97 ) 98 99 func fixFormat(s string) string { 100 s = strings.TrimSpace(s) 101 return strings.TrimSuffix(s, ".") 102 } 103 104 func formatCauses(causes ...string) string { 105 if len(causes) == 0 { 106 return "" 107 } 108 out := LikelyCauseFirstPrefix + fixFormat(causes[0]) + "." 109 for _, c := range causes[1:] { 110 out += LikelyCauseSecondPrefix + fixFormat(c) + "." 111 } 112 return out 113 }