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

fix typos in docs and unused variable #268

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/arch.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ oc get secret/pull-secret -n openshift-config -o json | jq -r ".data | .[]" | ba
}
}
```
The configuration secrets are periodically refreshed by `[configobserver](pkg/config/configobserver/configobserver.go)`. Any code can register to
The configuration secrets are periodically refreshed by [configobserver](pkg/config/configobserver/configobserver.go). Any code can register to
receive signal through channel by using config.ConfigChanged(), like for example in `insightsuploader.go`. It will then get notified if config changes.
```
configCh, cancelFn := c.configurator.ConfigChanged()
Expand All @@ -85,7 +85,7 @@ There are these main tasks scheduled:
- Disk Pruner

### Scheduling of Gatherer
Gatherer is using this logic to start information gathering from the cluster, and it is handled in `[periodic.go](pkg/controller/periodic/periodic.go)`.
Gatherer is using this logic to start information gathering from the cluster, and it is handled in [periodic.go](pkg/controller/periodic/periodic.go).

The periodic is using a producer/consumer queue. It is periodically adding the gatherer to queue. The queue has a limit for maximally one gatherer of the name in queue and because we only have gatherer "config" it is only this one in queue.
The adding to queue is run in periodic.periodicTrigger, which is started from periodic.Run function.
Expand Down Expand Up @@ -125,7 +125,7 @@ If the file names are unstable (for example reading from Api with Limit and reac

## Scheduling the ConfigObserver
Another background task started from Observer is from `pkg/config/configobserver/configobserver.go`. The observer creates configObserver by calling `configObserver.New`, which sets default observing interval to 5 minutes.
The Run method runs again wail.Poll every 5 minutes and reads both support and pull-secret secrets.
The Run method runs again wait.Poll every 5 minutes and reads both support and pull-secret secrets.

## Scheduling diskpruner and what it does
By default Insights Operator Gather is calling diskrecorder to save newly collected data in a new file, but doesn't remove old. This is the task of diskpruner. Observer calls `recorder.PeriodicallyPrune()` function. It is again using wait.Until pattern and runs approximately after every second interval.
Expand Down Expand Up @@ -195,14 +195,14 @@ I1006 12:26:36.467245 66541 request.go:1068] Response Body: {"kind":"Table","a
```

But adding Bearer token and creating Rest query is all handled automatically for us by using Clients, which are generated, type safe golang libraries,
like `[github.com/openshift/client-go](github.com/openshift/client-go)` or `[github.com/kubernetes/client-go](github.com/kubernetes/client-go)`.
like [github.com/openshift/client-go](github.com/openshift/client-go) or [github.com/kubernetes/client-go](github.com/kubernetes/client-go).
Both these libraries are generated by automation, which specifies from which Api repo and which Api Group it generates it.
All these clients are created in `[operator.go](pkg/controller/operator.go)` from the KUBECONFIG envvar defined in cluster and passed into `[clusterconfig.go](pkg/controller/clusterconfig.go)`.
All these clients are created in [operator.go](pkg/controller/operator.go) from the KUBECONFIG envvar defined in cluster and passed into [clusterconfig.go](pkg/controller/clusterconfig.go).

## How are the credentials used in clients
In IO deployment `[manifest](manifests/06-deployment.yaml)` is specified service account operator (serviceAccountName: operator). This is the account under which insights operator runs or reads its configuration or also reads the metrics.
In IO deployment [manifest](manifests/06-deployment.yaml) is specified service account operator (serviceAccountName: operator). This is the account under which insights operator runs or reads its configuration or also reads the metrics.
Because Insights Operator needs quite powerful credentials to access cluster-wide resources, it has one more service account called gather. It is created
in `[manifest](manifests/03-clusterrole.yaml)`.
in [manifest](manifests/03-clusterrole.yaml).
Code: To verify if gather account has right permissions to call verb list from apigroup machinesets I can use:
```
kubectl auth can-i list machinesets --as=system:serviceaccount:openshift-insights:gather
Expand Down Expand Up @@ -255,7 +255,7 @@ One problem with adding new operator to go.mod is that usually other operator wi

If it is impossible to reference, or operator doesn't expose generated Lister or ClientSet types in all these cases when we don't have type safe
Api, we can still use non type safe custom build types called [dynamic client](k8s.io/client-go/dynamic). There are two cases, when Lister types exists, but no ClientSet, or when no Lister types exists at all both have examples [here](https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.6.2/pkg/client#example-Client-List).
Such a client is used in `[GatherMachineSet](pkg/gather/clusterconfig/clusterconfig.go)`.
Such a client is used in [GatherMachineSet](pkg/gather/clusterconfig/clusterconfig.go).


## Gathering the data
Expand Down
2 changes: 0 additions & 2 deletions pkg/record/interface_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
)

func Test_uniqueStrings(t *testing.T) {
type args struct {
}
tests := []struct {
name string
arr []string
Expand Down