-
Notifications
You must be signed in to change notification settings - Fork 345
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 to always use namespace when a name is involved #485
Merged
jpkrohling
merged 2 commits into
jaegertracing:master
from
jpkrohling:285-Two-jaeger-same-names
Jul 2, 2019
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
package v1 | ||
|
||
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/types" | ||
) | ||
|
||
// NewJaeger returns a new Jaeger instance with the given name | ||
func NewJaeger(name string) *Jaeger { | ||
func NewJaeger(nsn types.NamespacedName) *Jaeger { | ||
return &Jaeger{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: name, | ||
Name: nsn.Name, | ||
Namespace: nsn.Namespace, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,15 +3,16 @@ package jaeger | |
import ( | ||
"context" | ||
|
||
log "github.com/sirupsen/logrus" | ||
corev1 "k8s.io/api/core/v1" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
"github.com/jaegertracing/jaeger-operator/pkg/apis/jaegertracing/v1" | ||
v1 "github.com/jaegertracing/jaeger-operator/pkg/apis/jaegertracing/v1" | ||
"github.com/jaegertracing/jaeger-operator/pkg/inventory" | ||
) | ||
|
||
func (r *ReconcileJaeger) applyAccounts(jaeger v1.Jaeger, desired []corev1.ServiceAccount) error { | ||
opts := client.MatchingLabels(map[string]string{ | ||
opts := client.InNamespace(jaeger.Namespace).MatchingLabels(map[string]string{ | ||
"app.kubernetes.io/instance": jaeger.Name, | ||
"app.kubernetes.io/managed-by": "jaeger-operator", | ||
}) | ||
|
@@ -22,21 +23,30 @@ func (r *ReconcileJaeger) applyAccounts(jaeger v1.Jaeger, desired []corev1.Servi | |
|
||
inv := inventory.ForAccounts(list.Items, desired) | ||
for _, d := range inv.Create { | ||
jaeger.Logger().WithField("account", d.Name).Debug("creating service account") | ||
jaeger.Logger().WithFields(log.Fields{ | ||
"account": d.Name, | ||
"namespace": d.Namespace, | ||
}).Debug("creating service account") | ||
if err := r.client.Create(context.Background(), &d); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
for _, d := range inv.Update { | ||
jaeger.Logger().WithField("account", d.Name).Debug("updating service account") | ||
jaeger.Logger().WithFields(log.Fields{ | ||
"account": d.Name, | ||
"namespace": d.Namespace, | ||
}).Debug("updating service account") | ||
if err := r.client.Update(context.Background(), &d); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
for _, d := range inv.Delete { | ||
jaeger.Logger().WithField("account", d.Name).Debug("deleting service account") | ||
jaeger.Logger().WithFields(log.Fields{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This overrides the namespace from the |
||
"account": d.Name, | ||
"namespace": d.Namespace, | ||
}).Debug("deleting service account") | ||
if err := r.client.Delete(context.Background(), &d); err != nil { | ||
return err | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (and similar changes in the other
controller
functions) is the actual fix for the reported problem. All other changes are either to make the test more accurate, or to properly log what's going on.