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

App-operator watching label set false #77

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 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
5 changes: 3 additions & 2 deletions .nancy-ignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#pkg:golang/k8s.io/[email protected]
CVE-2020-8561 until=2024-01-08 # k8s.io/[email protected]
CVE-2023-47108 until=2024-01-18 # go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/[email protected]
CVE-2020-8561 until=2024-04-08 # k8s.io/[email protected]
CVE-2023-47108 until=2024-04-18 # go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/[email protected]
CVE-2024-24786 until=2024-04-18 # google.golang.org/[email protected]
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- Added the label `app-operator.giantswarm.io/watching` to `"false"` on `configmap` created by the operator to avoid the unstopable reconciliation of the resource.

## [0.8.4] - 2024-01-04

### Changed
Expand Down
12 changes: 12 additions & 0 deletions internal/pkg/teleport/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ func (t *Teleport) CreateConfigMap(ctx context.Context, log logr.Logger, ctrlCli
ObjectMeta: metav1.ObjectMeta{
Name: configMapName,
Namespace: clusterNamespace,
Labels: map[string]string{
"app-operator.giantswarm.io/watching": "false",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it okay to add the label upon creation already?
I'm asking because initially it is needed for the configmap to be used to configure the app. Or does this just mean it won't be watched after the initial configuration?

},
},
Data: configMapData,
}
Expand Down Expand Up @@ -104,6 +107,15 @@ func (t *Teleport) UpdateConfigMap(ctx context.Context, log logr.Logger, ctrlCli

// Update the ConfigMap's data with the modified value
configMap.Data["values"] = string(updatedValuesYaml)

// Ensure the Labels map is initialized
if configMap.Labels == nil {
configMap.Labels = make(map[string]string)
}

// Add the specific label
configMap.Labels["app-operator.giantswarm.io/watching"] = "false"

if err := ctrlClient.Update(ctx, configMap); err != nil {
return microerror.Mask(fmt.Errorf("failed to update ConfigMap: %w", err))
}
Expand Down
3 changes: 3 additions & 0 deletions internal/pkg/teleport/configmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ func Test_ConfigMapCRUD(t *testing.T) {
if err != nil {
test.CheckConfigMap(t, tc.configMapToUpdate, actualConfigMap)
}
if actualConfigMap.Labels["app-operator.giantswarm.io/watching"] != "false" {
t.Errorf("Expected label app-operator.giantswarm.io/watching=false, found %s", actualConfigMap.Labels["app-operator.giantswarm.io/watching"])
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions internal/pkg/teleport/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ func (t *Teleport) CreateSecret(ctx context.Context, log logr.Logger, ctrlClient
ObjectMeta: metav1.ObjectMeta{
Name: secretName,
Namespace: clusterNamespace,
Labels: map[string]string{
"app-operator.giantswarm.io/watching": "false",
},
},
StringData: map[string]string{
"joinToken": token,
Expand All @@ -70,6 +73,9 @@ func (t *Teleport) UpdateSecret(ctx context.Context, log logr.Logger, ctrlClient
ObjectMeta: metav1.ObjectMeta{
Name: secretName,
Namespace: clusterNamespace,
Labels: map[string]string{
"app-operator.giantswarm.io/watching": "false",
},
},
StringData: map[string]string{
"joinToken": token,
Expand Down
3 changes: 3 additions & 0 deletions internal/pkg/test/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ func NewConfigMap(clusterName, appName, namespaceName, tokenName string) *corev1
ObjectMeta: metav1.ObjectMeta{
Name: key.GetConfigmapName(clusterName, appName),
Namespace: namespaceName,
Labels: map[string]string{
"app-operator.giantswarm.io/watching": "false",
},
},
Data: map[string]string{
"values": fmt.Sprintf(ConfigMapValuesFormat, tokenName, ProxyAddr, registerName, TeleportVersion),
Expand Down