Add OperatorVersion in Jenkins CR status section
This commit is contained in:
		
							parent
							
								
									d278847a46
								
							
						
					
					
						commit
						826573eeb9
					
				|  | @ -48,6 +48,7 @@ type Service struct { | |||
| type JenkinsStatus struct { | ||||
| 	// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
 | ||||
| 	// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
 | ||||
| 	OperatorVersion                string       `json:"operatorVersion,omitempty"` | ||||
| 	ProvisionStartTime             *metav1.Time `json:"provisionStartTime,omitempty"` | ||||
| 	BaseConfigurationCompletedTime *metav1.Time `json:"baseConfigurationCompletedTime,omitempty"` | ||||
| 	UserConfigurationCompletedTime *metav1.Time `json:"userConfigurationCompletedTime,omitempty"` | ||||
|  |  | |||
|  | @ -13,6 +13,7 @@ import ( | |||
| 	"github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/groovy" | ||||
| 	"github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/plugins" | ||||
| 	"github.com/jenkinsci/kubernetes-operator/pkg/log" | ||||
| 	"github.com/jenkinsci/kubernetes-operator/version" | ||||
| 
 | ||||
| 	"github.com/bndr/gojenkins" | ||||
| 	"github.com/go-logr/logr" | ||||
|  | @ -373,6 +374,12 @@ func isPodTerminating(pod corev1.Pod) bool { | |||
| } | ||||
| 
 | ||||
| func (r *ReconcileJenkinsBaseConfiguration) isRecreatePodNeeded(currentJenkinsMasterPod corev1.Pod) bool { | ||||
| 	if version.Version != r.jenkins.Status.OperatorVersion { | ||||
| 		r.logger.Info(fmt.Sprintf("Jenkins Operator version has changed, actual '%+v' new '%+v' - recreating pod", | ||||
| 			r.jenkins.Status.OperatorVersion, version.Version)) | ||||
| 		return true | ||||
| 	} | ||||
| 
 | ||||
| 	if currentJenkinsMasterPod.Status.Phase == corev1.PodFailed || | ||||
| 		currentJenkinsMasterPod.Status.Phase == corev1.PodSucceeded || | ||||
| 		currentJenkinsMasterPod.Status.Phase == corev1.PodUnknown { | ||||
|  |  | |||
|  | @ -12,6 +12,7 @@ import ( | |||
| 	"github.com/jenkinsci/kubernetes-operator/pkg/controller/jenkins/plugins" | ||||
| 	"github.com/jenkinsci/kubernetes-operator/pkg/event" | ||||
| 	"github.com/jenkinsci/kubernetes-operator/pkg/log" | ||||
| 	"github.com/jenkinsci/kubernetes-operator/version" | ||||
| 
 | ||||
| 	"github.com/go-logr/logr" | ||||
| 	"github.com/pkg/errors" | ||||
|  | @ -231,6 +232,16 @@ func (r *ReconcileJenkins) setDefaults(jenkins *v1alpha1.Jenkins, logger logr.Lo | |||
| 		changed = true | ||||
| 		jenkins.Spec.Master.OperatorPlugins = plugins.BasePlugins() | ||||
| 	} | ||||
| 	if len(jenkins.Status.OperatorVersion) > 0 && version.Version != jenkins.Status.OperatorVersion { | ||||
| 		logger.Info("Setting default operator plugins after Operator version change") | ||||
| 		changed = true | ||||
| 		jenkins.Spec.Master.OperatorPlugins = plugins.BasePlugins() | ||||
| 	} | ||||
| 	if len(jenkins.Status.OperatorVersion) == 0 { | ||||
| 		logger.Info("Setting operator version") | ||||
| 		changed = true | ||||
| 		jenkins.Status.OperatorVersion = version.Version | ||||
| 	} | ||||
| 	if len(jenkins.Spec.Master.Plugins) == 0 { | ||||
| 		changed = true | ||||
| 		jenkins.Spec.Master.Plugins = map[string][]string{"simple-theme-plugin:0.5.1": {}} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue