Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed CustomImage event to NooBaaImage event for every image change #105

Merged
merged 1 commit into from
Oct 27, 2019
Merged
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
9 changes: 0 additions & 9 deletions pkg/system/phase1_verifying.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
nbv1 "github.com/noobaa/noobaa-operator/v2/pkg/apis/noobaa/v1alpha1"
"github.com/noobaa/noobaa-operator/v2/pkg/options"
"github.com/noobaa/noobaa-operator/v2/pkg/util"
corev1 "k8s.io/api/core/v1"
)

// ReconcilePhaseVerifying runs the reconcile verify phase
Expand Down Expand Up @@ -84,17 +83,9 @@ func (r *Reconciler) CheckSystemCR() error {
}
} else {
log.Infof("Using custom image %q contraints %q", imageRef.String(), ContainerImageConstraint.String())
if r.Recorder != nil {
r.Recorder.Eventf(r.NooBaa, corev1.EventTypeNormal,
"CustomImage", `Custom image version requested %q, I hope you know what you're doing ...`, imageRef)
}
}
} else {
log.Infof("Using custom image name %q the default is %q", imageRef.String(), options.ContainerImageName)
if r.Recorder != nil {
r.Recorder.Eventf(r.NooBaa, corev1.EventTypeNormal,
"CustomImage", `Custom image requested %q, I hope you know what you're doing ...`, imageRef)
}
}

// Set ActualImage to be updated in the noobaa status
Expand Down
21 changes: 20 additions & 1 deletion pkg/system/phase2_creating.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (r *Reconciler) SetDesiredCoreApp() {

podSpec := &r.CoreApp.Spec.Template.Spec
podSpec.ServiceAccountName = "noobaa"
coreImageChanged := false
for i := range podSpec.InitContainers {
c := &podSpec.InitContainers[i]
switch c.Name {
Expand All @@ -81,7 +82,10 @@ func (r *Reconciler) SetDesiredCoreApp() {
c := &podSpec.Containers[i]
switch c.Name {
case "core":
c.Image = r.NooBaa.Status.ActualImage
if c.Image != r.NooBaa.Status.ActualImage {
coreImageChanged = true
c.Image = r.NooBaa.Status.ActualImage
}
for j := range c.Env {
switch c.Env[j].Name {
// case "ENDPOINT_FORKS_NUMBER":
Expand Down Expand Up @@ -132,6 +136,12 @@ func (r *Reconciler) SetDesiredCoreApp() {
}
}
}

// generate info event for the first creation of noobaa
if r.Recorder != nil {
r.Recorder.Eventf(r.NooBaa, corev1.EventTypeNormal,
"NooBaaImage", `Using NooBaa image %q for the creation of %q`, r.NooBaa.Status.ActualImage, r.NooBaa.Name)
}
} else {
// when already exists we check that there is no update requested to the volumes
// otherwise we report that volume update is unsupported
Expand Down Expand Up @@ -162,6 +172,15 @@ func (r *Reconciler) SetDesiredCoreApp() {
}
}
}

if coreImageChanged {
// generate info event for the first creation of noobaa
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix the comment...

if r.Recorder != nil {
r.Recorder.Eventf(r.NooBaa, corev1.EventTypeNormal,
"NooBaaImage", `Updating NooBaa image to %q for %q`, r.NooBaa.Status.ActualImage, r.NooBaa.Name)
}
}

}
}

Expand Down