Skip to content

Metric changes #2

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

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
2e98c38
Update alpine Docker tag to v3.19.1 (#238)
renovate[bot] Feb 12, 2024
9b947f9
Update crossplane-runtime to 14.3, go to 1.20 and build submodule (#235)
bobh66 Feb 12, 2024
b96960b
Move SYNCED before READY in output (#244)
bobh66 Feb 27, 2024
5f3cdb9
fix(ess): missing mtls injection
Mar 1, 2024
538a260
Merge pull request #246 from DrummyFloyd/fix-tls
ytsarev Mar 11, 2024
cc903d1
Update module google.golang.org/protobuf to v1.33.0 [SECURITY] (#249)
renovate[bot] Mar 14, 2024
8ba2d73
Removes incorrect entry in NOTICE
jeanduplessis Apr 2, 2024
2e5be3e
Merge pull request #252 from jeanduplessis/update-notices
jeanduplessis Apr 2, 2024
92bc309
Add support for setting env variables in a workspace
bdwyertech May 10, 2023
4fdad62
Update mocks & README
bdwyertech May 10, 2023
1c35275
prealloc
bdwyertech May 25, 2023
8cfe35b
Add new up
ytsarev Apr 3, 2024
3f88312
Add e2e example for environment usage and extend README
ytsarev Apr 3, 2024
7622434
Address PR feedback
ytsarev Apr 3, 2024
51dda57
Merge pull request #74 from bdwyertech/env-support
ytsarev Apr 3, 2024
b61ce9f
Move docs to docs/monolith folder
turkenf Apr 4, 2024
6be7585
Merge pull request #255 from turkenf/move-docs
turkenf Apr 5, 2024
f53e098
Update to go1.21 and crossplane-runtime 1.15.1
bobh66 Feb 27, 2024
e274bfb
Update e2e to go 1.21
bobh66 Apr 15, 2024
520e80f
Merge pull request #259 from bobh66/e2e21
ytsarev Apr 15, 2024
68e9af5
Update to go1.21 and crossplane-runtime 1.15.1
bobh66 Apr 15, 2024
32648b9
Merge branch 'go_1_21' of https://github.com/bobh66/provider-terrafor…
bobh66 Apr 15, 2024
a4f2514
Merge pull request #245 from bobh66/go_1_21
ytsarev Apr 15, 2024
93ae55e
Update module google.golang.org/protobuf to v1.33.0 [SECURITY] (#260)
renovate[bot] Apr 15, 2024
32968e2
Update kubernetes patches (#261)
renovate[bot] Apr 15, 2024
e854609
Update Terraform random to v3.6.1 (#262)
renovate[bot] Apr 16, 2024
33265c0
Update kubernetes patches to v0.29.4 (#263)
renovate[bot] Apr 17, 2024
173bca3
Update module github.com/hashicorp/go-getter to v1.7.4 [SECURITY] (#265)
renovate[bot] May 7, 2024
42a0db9
Rename the repo name for reusable workflows used
turkenf May 20, 2024
023aa5f
Merge pull request #266 from turkenf/rename-repo
ytsarev May 20, 2024
8694162
Update build module and go version (#272)
bobh66 Jun 13, 2024
db1616e
Update alpine Docker tag to v3.20.0 (#269)
renovate[bot] Jun 13, 2024
df30be3
Update Terraform random to v3.6.2 (#267)
renovate[bot] Jun 17, 2024
88a2ea0
Update alpine Docker tag to v3.20.1
renovate[bot] Jun 26, 2024
0b1baff
Update module github.com/hashicorp/go-getter to v1.7.5 [SECURITY]
renovate[bot] Jun 27, 2024
bd9d26b
Merge pull request #273 from upbound/renovate/alpine-3.x
jeanduplessis Jun 28, 2024
d9fc069
Merge pull request #274 from upbound/renovate/go-github.jpy.wang/hashicorp…
jeanduplessis Jun 28, 2024
ae93265
feat(workspace): don't delete workspace on every reconciliation (#276)
arththebird Jun 28, 2024
af199f8
feat: introduce MR metrics (#277)
arththebird Jul 2, 2024
b294b63
Update alpine Docker tag to v3.20.2 (#279)
renovate[bot] Jul 23, 2024
5dffb94
Update Quickstart.md
tuffacton Aug 22, 2024
1720633
Merge pull request #284 from tuffacton/patch-1
jeanduplessis Aug 22, 2024
8850b8a
Write Terraform CLI logs to container stdout (#258)
suramasamy Aug 23, 2024
9db20a3
feat: introduce json format for inline module (#165) (#283)
denniskniep Aug 26, 2024
cb09daf
Fix CI errors
bobh66 Aug 26, 2024
53929c5
Merge pull request #285 from bobh66/fix-ci
ytsarev Aug 27, 2024
aee1835
Update alpine Docker tag to v3.20.3 (#286)
renovate[bot] Sep 6, 2024
a429a7c
Update Terraform random to v3.6.3 (#289)
renovate[bot] Sep 11, 2024
7744d10
Update Terraform null to v3.2.3 (#288)
renovate[bot] Sep 11, 2024
51c10b7
Update dependency ubuntu to v24 (#290)
renovate[bot] Sep 26, 2024
5717f90
metric-changes
balu-ce Oct 28, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
ci:
uses: upbound/official-providers-ci/.github/workflows/provider-ci.yml@main
with:
go-version: "1.21"
go-version: "1.22"
upjet-based-provider: false
secrets:
UPBOUND_MARKETPLACE_PUSH_ROBOT_USR: ${{ secrets.UPBOUND_MARKETPLACE_PUSH_ROBOT_USR }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
e2e:
uses: upbound/official-providers-ci/.github/workflows/pr-comment-trigger.yml@main
with:
go-version: "1.21"
go-version: "1.22"
secrets:
UPTEST_CLOUD_CREDENTIALS: ${{ secrets.UPTEST_CLOUD_CREDENTIALS }}
UPTEST_DATASOURCE: ${{ secrets.UPTEST_DATASOURCE }}
2 changes: 1 addition & 1 deletion .github/workflows/scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ env:

jobs:
setup-vars:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
outputs:
supported_releases_number: ${{ steps.setup.outputs.supported_releases_number }}
images: ${{ steps.setup.outputs.images }}
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "build"]
path = build
url = https://github.com/upbound/build
url = https://github.com/crossplane/build
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ GO111MODULE = on
UP_VERSION = v0.28.0
# UP_CHANNEL = stable
UPTEST_VERSION = v0.5.0
CROSSPLANE_VERSION = 1.16.0
-include build/makelib/k8s_tools.mk

# Setup Images
Expand Down Expand Up @@ -177,3 +178,6 @@ go.mod.cachedir:
@go env GOMODCACHE

.PHONY: go.mod.cachedir

vendor: modules.download
vendor.check: modules.check
21 changes: 15 additions & 6 deletions apis/v1beta1/workspace_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ const (
VarFileSourceSecretKey VarFileSource = "SecretKey"
)

// A VarFileFormat specifies the format of a Terraform vars file.
// A FileFormat specifies the format of a Terraform file.
// +kubebuilder:validation:Enum=HCL;JSON
type VarFileFormat string
type FileFormat string

// Vars file formats.
var (
VarFileFormatHCL VarFileFormat = "HCL"
VarFileFormatJSON VarFileFormat = "JSON"
FileFormatHCL FileFormat = "HCL"
FileFormatJSON FileFormat = "JSON"
)

// A VarFile is a file containing many Terraform variables.
Expand All @@ -57,7 +57,7 @@ type VarFile struct {
// Format of this vars file.
// +kubebuilder:default=HCL
// +optional
Format *VarFileFormat `json:"format,omitempty"`
Format *FileFormat `json:"format,omitempty"`

// A ConfigMap key containing the vars file.
// +optional
Expand Down Expand Up @@ -108,9 +108,13 @@ type WorkspaceParameters struct {
// file. When the workspace's source is 'Remote' (the default) this can be
// any address supported by terraform init -from-module, for example a git
// repository or an S3 bucket. When the workspace's source is 'Inline' the
// content of a simple main.tf file may be written inline.
// content of a simple main.tf or main.tf.json file may be written inline.
Module string `json:"module"`

// Specifies the format of the inline Terraform content
// if Source is 'Inline'
InlineFormat FileFormat `json:"inlineFormat,omitempty"`

// Source of the root module of this workspace.
Source ModuleSource `json:"source"`

Expand Down Expand Up @@ -153,6 +157,10 @@ type WorkspaceParameters struct {

// Arguments to be included in the terraform destroy CLI command
DestroyArgs []string `json:"destroyArgs,omitempty"`

// Boolean value to indicate CLI logging of terraform execution is enabled or not
// +optional
EnableTerraformCLILogging bool `json:"enableTerraformCLILogging,omitempty"`
}

// WorkspaceObservation are the observable fields of a Workspace.
Expand Down Expand Up @@ -182,6 +190,7 @@ type WorkspaceStatus struct {
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status"
// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status"
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,terraform}
type Workspace struct {
Expand Down
2 changes: 1 addition & 1 deletion apis/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cluster/images/provider-terraform/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM alpine:3.19.1
FROM alpine:3.20.3
RUN apk --no-cache add ca-certificates bash git curl
ARG TARGETOS
ARG TARGETARCH
Expand Down
15 changes: 15 additions & 0 deletions cmd/provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"github.com/crossplane/crossplane-runtime/pkg/certificates"
"github.com/crossplane/crossplane-runtime/pkg/controller"
"github.com/crossplane/crossplane-runtime/pkg/feature"
"github.com/crossplane/crossplane-runtime/pkg/reconciler/managed"
"github.com/crossplane/crossplane-runtime/pkg/statemetrics"
"go.uber.org/zap/zapcore"

"k8s.io/client-go/tools/leaderelection/resourcelock"
Expand All @@ -35,6 +37,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/metrics"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
"github.com/crossplane/crossplane-runtime/pkg/logging"
Expand All @@ -53,6 +56,7 @@ func main() {
debug = app.Flag("debug", "Run with debug logging.").Short('d').Bool()
syncInterval = app.Flag("sync", "Sync interval controls how often all resources will be double checked for drift.").Short('s').Default("1h").Duration()
pollInterval = app.Flag("poll", "Poll interval controls how often an individual resource should be checked for drift.").Default("10m").Duration()
pollStateMetricInterval = app.Flag("poll-state-metric", "State metric recording interval").Default("5s").Duration()
pollJitter = app.Flag("poll-jitter", "If non-zero, varies the poll interval by a random amount up to plus-or-minus this value.").Default("1m").Duration()
timeout = app.Flag("timeout", "Controls how long Terraform processes may run before they are killed.").Default("20m").Duration()
leaderElection = app.Flag("leader-election", "Use leader election for the controller manager.").Short('l').Default("false").Envar("LEADER_ELECTION").Bool()
Expand Down Expand Up @@ -101,12 +105,23 @@ func main() {

kingpin.FatalIfError(apis.AddToScheme(mgr.GetScheme()), "Cannot add terraform APIs to scheme")

metricRecorder := managed.NewMRMetricRecorder()
stateMetrics := statemetrics.NewMRStateMetrics()

metrics.Registry.MustRegister(metricRecorder)
metrics.Registry.MustRegister(stateMetrics)

o := controller.Options{
Logger: log,
MaxConcurrentReconciles: *maxReconcileRate,
PollInterval: *pollInterval,
GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate),
Features: &feature.Flags{},
MetricOptions: &controller.MetricOptions{
PollStateMetricInterval: *pollStateMetricInterval,
MRMetrics: metricRecorder,
MRStateMetrics: stateMetrics,
},
}

if *enableManagementPolicies {
Expand Down
22 changes: 22 additions & 0 deletions docs/monolith/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,25 @@ spec:
At Vault side configuration is also needed to allow the write operation, see
[example](https://docs.crossplane.io/knowledge-base/integrations/vault-as-secret-store/)
here for inspiration.


## Enable Terraform CLI logs

Terraform CLI output can be written to the container logs to assist with debugging and to view detailed information about Terraform operations.
To enable it, the `Workspace` spec has an **optional** `EnableTerraformCLILogging` field.
```yaml
apiVersion: tf.upbound.io/v1beta1
kind: Workspace
metadata:
name: example-random-generator
annotations:
meta.upbound.io/example-id: tf/v1beta1/workspace
crossplane.io/external-name: random
spec:
forProvider:
source: Inline
enableTerraformCLILogging: true
...
```

- `enableTerraformCLILogging`: Specifies whether logging is enabled (`true`) or disabled (`false`). When enabled, Terraform CLI command output will be written to the container logs. Default is `false`
2 changes: 1 addition & 1 deletion docs/monolith/Quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mv up /usr/local/bin/
Verify the version of `up` with `up --version`

```shell
$ up --version
$ up version
v0.13.0
```

Expand Down
34 changes: 34 additions & 0 deletions examples/workspace-enable-logging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: tf.upbound.io/v1beta1
kind: Workspace
metadata:
name: example-random-generator
annotations:
meta.upbound.io/example-id: tf/v1beta1/workspace
# The terraform workspace will be named 'random'. If you omit this
# annotation it would be derived from metadata.name - e.g. 'example-random-generator.
crossplane.io/external-name: random
spec:
forProvider:
enableTerraformCLILogging: true
source: Inline
module: |
resource "random_id" "example_id" {
byte_length = 8
}
resource "random_password" "password" {
length = 16
special = true
}
// Non-sensitive Outputs are written to status.atProvider.outputs and to the connection secret.
output "random_id_hex" {
value = random_id.example_id.hex
}
// Sensitive Outputs are only written to the connection secret
output "random_password" {
value = random_password.password
sensitive = true
}
// Terraform has several other random resources, see the random provider for details
writeConnectionSecretToRef:
namespace: default
name: terraform-workspace-example-random-generator
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module github.com/upbound/provider-terraform

go 1.21
go 1.22

require (
github.com/MakeNowJust/heredoc v1.0.0
github.com/crossplane/crossplane-runtime v1.15.1
github.com/crossplane/crossplane-runtime v1.16.0
github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.4.0
github.com/hashicorp/go-getter v1.7.4
github.com/hashicorp/go-getter v1.7.5
github.com/pkg/errors v0.9.1
github.com/spf13/afero v1.11.0
go.uber.org/zap v1.26.0
Expand All @@ -34,6 +34,7 @@ require (
github.com/aws/aws-sdk-go v1.44.122 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/dave/jennifer v1.4.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas=
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand All @@ -224,8 +226,8 @@ github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWH
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/crossplane/crossplane-runtime v1.15.1 h1:g1h75tNYOQT152IUNxs8ZgSsRFQKrZN9z69KefMujXs=
github.com/crossplane/crossplane-runtime v1.15.1/go.mod h1:kRcJjJQmBFrR2n/KhwL8wYS7xNfq3D8eK4JliEScOHI=
github.com/crossplane/crossplane-runtime v1.16.0 h1:lz+l0wEB3qowdTmN7t0PZkfuNSvfOoEhQrEYFbYqMow=
github.com/crossplane/crossplane-runtime v1.16.0/go.mod h1:Pz2tdGVMF6KDGzHZOkvKro0nKc8EzK0sb/nSA7pH4Dc=
github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79 h1:HigXs5tEQxWz0fcj8hzbU2UAZgEM7wPe0XRFOsrtF8Y=
github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79/go.mod h1:+e4OaFlOcmr0JvINHl/yvEYBrZawzTgj6pQumOH1SS0=
github.com/dave/jennifer v1.4.1 h1:XyqG6cn5RQsTj3qlWQTKlRGAyrTcsk1kUmWdZBzRjDw=
Expand Down Expand Up @@ -384,8 +386,8 @@ github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-getter v1.7.4 h1:3yQjWuxICvSpYwqSayAdKRFcvBl1y/vogCxczWSmix0=
github.com/hashicorp/go-getter v1.7.4/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744=
github.com/hashicorp/go-getter v1.7.5 h1:dT58k9hQ/vbxNMwoI5+xFYAJuv6152UNvdHokfI5wE4=
github.com/hashicorp/go-getter v1.7.5/go.mod h1:W7TalhMmbPmsSMdNjD0ZskARur/9GJ17cfHTRtXV744=
github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo=
github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I=
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
Expand Down
Loading
Loading