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

[new-component] Operator OpAMP Bridge Service #1339

Merged
merged 17 commits into from
Jan 11, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix create bug, getting prepped for refactor
  • Loading branch information
jaronoff97 committed Dec 21, 2022
commit c5ab004772809851831bf53dc2c719fd159f75e1
18 changes: 13 additions & 5 deletions cmd/remote-configuration/operator/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/go-logr/logr"
"github.com/open-telemetry/opamp-go/protobufs"
"gopkg.in/yaml.v3"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/scheme"
Expand All @@ -15,7 +16,9 @@ import (
)

const (
CollectorResource = "OpenTelemetryCollector"
CollectorResource = "OpenTelemetryCollector"
ResourceIdentifierKey = "created-by"
ResourceIdentifierValue = "remote-configuration"
)

var (
Expand Down Expand Up @@ -68,10 +71,10 @@ func (c Client) create(ctx context.Context, name string, namespace string, colle
collector.ObjectMeta.Name = name
collector.ObjectMeta.Namespace = namespace

if collector.ObjectMeta.Annotations == nil {
collector.ObjectMeta.Annotations = map[string]string{}
if collector.ObjectMeta.Labels == nil {
collector.ObjectMeta.Labels = map[string]string{}
}
collector.ObjectMeta.Annotations["created-by"] = "remote-configuration"
collector.ObjectMeta.Labels[ResourceIdentifierKey] = ResourceIdentifierValue
err := collector.ValidateCreate()
if err != nil {
return err
Expand Down Expand Up @@ -125,7 +128,9 @@ func (c Client) Apply(name string, namespace string, configmap *protobufs.AgentC
func (c Client) ListInstances() ([]v1alpha1.OpenTelemetryCollector, error) {
ctx := context.Background()
result := v1alpha1.OpenTelemetryCollectorList{}
err := c.k8sClient.List(ctx, &result)
err := c.k8sClient.List(ctx, &result, client.MatchingLabels{
ResourceIdentifierKey: ResourceIdentifierValue,
})
if err != nil {
return nil, err
}
Expand All @@ -139,6 +144,9 @@ func (c Client) GetInstance(name string, namespace string) (*v1alpha1.OpenTeleme
Namespace: namespace,
Name: name,
}, &result)
if errors.IsNotFound(err) {
return nil, nil
}
if err != nil {
return nil, err
}
Expand Down