Skip to content

Commit 727fabd

Browse files
committed
azure: add timeout flag to schedule automatic destroy
this adds the '--timeout' flag to the 'azure <svc> create' commands that schedules a serverless containerapp job on azure that'll destroy the created resources after a delay
1 parent 203bc54 commit 727fabd

File tree

651 files changed

+110188
-61239
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

651 files changed

+110188
-61239
lines changed

cmd/mapt/cmd/aws/constants/constants.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ const (
2323
MACDHID string = "dedicated-host-id"
2424
MACDHIDDesc string = "id for the dedicated host"
2525

26-
Spot string = "spot"
27-
SpotDesc string = "if spot is set the spot prices across all regions will be checked and machine will be started on best spot option (price / eviction)"
26+
Spot string = "spot"
27+
SpotDesc string = "if spot is set the spot prices across all regions will be checked and machine will be started on best spot option (price / eviction)"
2828
)
2929

3030
func MACArchAsCirrusArch(arch string) *cirrus.Arch {

cmd/mapt/cmd/azure/hosts/linux.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func getCreateLinux(ostype data.OSType, defaultOSVersion string) *cobra.Command
9595
OSType: ostype,
9696
Username: viper.GetString(paramUsername),
9797
Spot: viper.IsSet(azparams.ParamSpot),
98+
Timeout: viper.GetString(params.Timeout),
9899
SpotTolerance: spotToleranceValue}); err != nil {
99100
logging.Error(err)
100101
}
@@ -112,6 +113,7 @@ func getCreateLinux(ostype data.OSType, defaultOSVersion string) *cobra.Command
112113
flagSet.Bool(azparams.ParamSpot, false, azparams.ParamSpotDesc)
113114
flagSet.StringP(azparams.ParamSpotTolerance, "", azparams.DefaultSpotTolerance, azparams.ParamSpotToleranceDesc)
114115
flagSet.StringSliceP(azparams.ParamSpotExcludedRegions, "", []string{}, azparams.ParamSpotExcludedRegionsDesc)
116+
flagSet.StringP(params.Timeout, "", "", params.TimeoutDesc)
115117
flagSet.AddFlagSet(params.GetCpusAndMemoryFlagset())
116118
c.PersistentFlags().AddFlagSet(flagSet)
117119
return c

cmd/mapt/cmd/azure/hosts/rhel.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func getCreateRHEL() *cobra.Command {
108108
ProfileSNC: viper.IsSet(params.ProfileSNC),
109109
Username: viper.GetString(paramUsername),
110110
Spot: viper.IsSet(azparams.ParamSpot),
111+
Timeout: viper.GetString(params.Timeout),
111112
SpotTolerance: spotToleranceValue,
112113
SpotExcludedRegions: viper.GetStringSlice(azparams.ParamSpotExcludedRegions),
113114
}); err != nil {
@@ -130,6 +131,7 @@ func getCreateRHEL() *cobra.Command {
130131
flagSet.Bool(azparams.ParamSpot, false, azparams.ParamSpotDesc)
131132
flagSet.StringP(azparams.ParamSpotTolerance, "", azparams.DefaultSpotTolerance, azparams.ParamSpotToleranceDesc)
132133
flagSet.StringSliceP(azparams.ParamSpotExcludedRegions, "", []string{}, azparams.ParamSpotExcludedRegionsDesc)
134+
flagSet.StringP(params.Timeout, "", "", params.TimeoutDesc)
133135
flagSet.AddFlagSet(params.GetGHActionsFlagset())
134136
params.AddCirrusFlags(flagSet)
135137
flagSet.AddFlagSet(params.GetCpusAndMemoryFlagset())

cmd/mapt/cmd/azure/hosts/windows.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ func getCreateWindowsDesktop() *cobra.Command {
117117
AdminUsername: viper.GetString(paramAdminUsername),
118118
Profiles: viper.GetStringSlice(paramProfile),
119119
Spot: viper.IsSet(azparams.ParamSpot),
120+
Timeout: viper.GetString(params.Timeout),
120121
SpotTolerance: spotToleranceValue,
121122
SpotExcludedRegions: viper.GetStringSlice(azparams.ParamSpotExcludedRegions)}); err != nil {
122123
logging.Error(err)
@@ -139,6 +140,7 @@ func getCreateWindowsDesktop() *cobra.Command {
139140
flagSet.StringSliceP(azparams.ParamSpotExcludedRegions, "", []string{}, azparams.ParamSpotExcludedRegionsDesc)
140141
flagSet.AddFlagSet(params.GetGHActionsFlagset())
141142
params.AddCirrusFlags(flagSet)
143+
flagSet.StringP(params.Timeout, "", "", params.TimeoutDesc)
142144
flagSet.AddFlagSet(params.GetCpusAndMemoryFlagset())
143145
c.PersistentFlags().AddFlagSet(flagSet)
144146
return c

go.mod

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ require (
2525
github.com/pulumi/pulumi-aws-native/sdk v1.29.0
2626
github.com/pulumi/pulumi-aws/sdk/v6 v6.82.1
2727
github.com/pulumi/pulumi-awsx/sdk/v2 v2.21.1
28-
github.com/pulumi/pulumi-azure-native-sdk/authorization/v2 v2.90.0
29-
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.90.0
28+
github.com/pulumi/pulumi-azure-native-sdk/app/v3 v3.5.1
29+
github.com/pulumi/pulumi-azure-native-sdk/authorization/v3 v3.5.1
30+
github.com/pulumi/pulumi-azure-native-sdk/compute/v3 v3.5.1
3031
github.com/pulumi/pulumi-azure-native-sdk/containerservice/v2 v2.90.0
31-
github.com/pulumi/pulumi-azure-native-sdk/network/v2 v2.90.0
32-
github.com/pulumi/pulumi-azure-native-sdk/resources/v2 v2.90.0
33-
github.com/pulumi/pulumi-azure-native-sdk/storage/v2 v2.90.0
32+
github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v3 v3.5.1
33+
github.com/pulumi/pulumi-azure-native-sdk/network/v3 v3.5.1
34+
github.com/pulumi/pulumi-azure-native-sdk/resources/v3 v3.5.1
35+
github.com/pulumi/pulumi-azure-native-sdk/storage/v3 v3.5.1
3436
github.com/pulumi/pulumi-tls/sdk/v5 v5.2.0
3537
)
3638

@@ -49,6 +51,7 @@ require (
4951
github.com/mitchellh/go-homedir v1.1.0 // indirect
5052
github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852 // indirect
5153
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
54+
github.com/pulumi/pulumi-azure-native-sdk/v3 v3.5.1 // indirect
5255
github.com/pulumi/pulumi-docker-build/sdk/go/dockerbuild v0.0.3 // indirect
5356
github.com/sahilm/fuzzy v0.1.1 // indirect
5457
golang.org/x/mod v0.25.0 // indirect
@@ -151,7 +154,6 @@ require (
151154
github.com/opentracing/opentracing-go v1.2.0 // indirect
152155
github.com/pkg/errors v0.9.1 // indirect
153156
github.com/pkg/term v1.1.0 // indirect
154-
github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v2 v2.90.0
155157
github.com/pulumi/pulumi-kubernetes/sdk/v4 v4.23.0
156158
github.com/rivo/uniseg v0.4.7 // indirect
157159
github.com/rogpeppe/go-internal v1.14.1 // indirect

go.sum

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -272,22 +272,26 @@ github.com/pulumi/pulumi-aws/sdk/v6 v6.82.1 h1:OMFesR8LFHKczdjw+1G8D7jWaZfl/j4fx
272272
github.com/pulumi/pulumi-aws/sdk/v6 v6.82.1/go.mod h1:H3ch/vJwSGdwO3Veyu2CJtKcElQmwnLq0XGOX8V/5Kg=
273273
github.com/pulumi/pulumi-awsx/sdk/v2 v2.21.1 h1:V0NaeP3Rx5WGysvNz6x13Dnd3visEgQubP/gzQ+X86Q=
274274
github.com/pulumi/pulumi-awsx/sdk/v2 v2.21.1/go.mod h1:j8IUGf1uw47bXxHS5H98O3NZIXvVsb7bfv/zby1cVLE=
275-
github.com/pulumi/pulumi-azure-native-sdk/authorization/v2 v2.90.0 h1:n7CIe1znqhPy/GMnzif6ces7rYJxNSN6mImbveB2Mfg=
276-
github.com/pulumi/pulumi-azure-native-sdk/authorization/v2 v2.90.0/go.mod h1:E/eRptiP+vN8CHhbqkp62Kl/ce5lc9M2/Jos4YQlSWw=
277-
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.90.0 h1:zgHEQ9qYOeLr5ji4RIZIAPp2Y7aely3cKncSbMCmPGE=
278-
github.com/pulumi/pulumi-azure-native-sdk/compute/v2 v2.90.0/go.mod h1:ppkY8kpbZNeyNqUu9IOikthVMtPp3QGMfPxpvt4cpXI=
275+
github.com/pulumi/pulumi-azure-native-sdk/app/v3 v3.5.1 h1:LnS0JLndeS5808Fn1mHY74C8hxJn3AesOa/MBX3udLI=
276+
github.com/pulumi/pulumi-azure-native-sdk/app/v3 v3.5.1/go.mod h1:uRkpdKOn5TzOvFEU8ClIg7F0qaP4qnZOIG5uo6te3C0=
277+
github.com/pulumi/pulumi-azure-native-sdk/authorization/v3 v3.5.1 h1:/ZefC2g1pgGLD15UTva15xw6r9n44UesWL+Guzbj4tc=
278+
github.com/pulumi/pulumi-azure-native-sdk/authorization/v3 v3.5.1/go.mod h1:92GeokCKmCPkjgDddtFifp52W7bcX2di5N5UfdAPsNo=
279+
github.com/pulumi/pulumi-azure-native-sdk/compute/v3 v3.5.1 h1:ZRgCfhj/h9oWe9/EJQZGtRPt0wIzlHmZSckKqqEIC/o=
280+
github.com/pulumi/pulumi-azure-native-sdk/compute/v3 v3.5.1/go.mod h1:fpZ9m+mUwFJYYbUhmynux5MhgkPr0XNoajswNVNWKFo=
279281
github.com/pulumi/pulumi-azure-native-sdk/containerservice/v2 v2.90.0 h1:hAeeWNwun6IsPynn+DmfDTdZf8yUDA/iSxWKYCGSras=
280282
github.com/pulumi/pulumi-azure-native-sdk/containerservice/v2 v2.90.0/go.mod h1:9gxE6h4R/cKQ7Wuje0g7vvqu0RSVI8GC6NEVqwlorMs=
281-
github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v2 v2.90.0 h1:al+yi/DLRIh5QD1ly6nmKEhLwsX4MJf/pSAkhgWDsyU=
282-
github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v2 v2.90.0/go.mod h1:XtnP9Glgh7qQORnr0swkSs0Nl2sW7SrbPORH8Bzbsa4=
283-
github.com/pulumi/pulumi-azure-native-sdk/network/v2 v2.90.0 h1:MY1Gsyf/EbnC6cpxTdhAvTPoQ7vYsFRdi6DuK1hQRVs=
284-
github.com/pulumi/pulumi-azure-native-sdk/network/v2 v2.90.0/go.mod h1:vokLPWkqbKuI8d3+apCHrp0BDmqf6tS4UWLRweBVv70=
285-
github.com/pulumi/pulumi-azure-native-sdk/resources/v2 v2.90.0 h1:24gy0uzkWkahHnpv38Cn1tzLmS67QUnF5bGH5dSpVj8=
286-
github.com/pulumi/pulumi-azure-native-sdk/resources/v2 v2.90.0/go.mod h1:vr80rePwLAyiE3YsSUT5yAK7L0TVoA/+nPZ6yXjfRkk=
287-
github.com/pulumi/pulumi-azure-native-sdk/storage/v2 v2.90.0 h1:ZrZ/HhSXEez4XlmFFQAZr8hAQu5z5UPTm/5Kjfx1OXI=
288-
github.com/pulumi/pulumi-azure-native-sdk/storage/v2 v2.90.0/go.mod h1:aYU8LRrKffIqYmA9/B9eqmmsLALkMlwKLPwA0UBPB/U=
283+
github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v3 v3.5.1 h1:g/3ebg8tuqHXZxiA7/vUL8x53NRhso0pd4AtpMjCCjE=
284+
github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v3 v3.5.1/go.mod h1:H4pGl/yW8lDlNGAH6PGzQL+bgW+KIctf5wW/sfK/bx4=
285+
github.com/pulumi/pulumi-azure-native-sdk/network/v3 v3.5.1 h1:AlFosM3H5fkxC0ZrmVvO4l4bnEXu9gyw7+6yworm+qg=
286+
github.com/pulumi/pulumi-azure-native-sdk/network/v3 v3.5.1/go.mod h1:KWg3ySLcYAxgIe4+TRAxFcPbEwb/V8KpIHEem1U0RjY=
287+
github.com/pulumi/pulumi-azure-native-sdk/resources/v3 v3.5.1 h1:DRJ3WAXo1yhH6YAySjlUnT0eNDV3xlI1MoNrQxxN+d8=
288+
github.com/pulumi/pulumi-azure-native-sdk/resources/v3 v3.5.1/go.mod h1:Ag4JPUH7wO3A4dLispzONEmUcy4YnIna23xiFloQHHo=
289+
github.com/pulumi/pulumi-azure-native-sdk/storage/v3 v3.5.1 h1:WijJymNZw2hYeSQy/eRLZt//7DzQK4Ww81vQ0Irb3so=
290+
github.com/pulumi/pulumi-azure-native-sdk/storage/v3 v3.5.1/go.mod h1:qhiBFlA5N7IBpoN0Eg1yyqM8b43XE+pxYeHJ8f+3K7A=
289291
github.com/pulumi/pulumi-azure-native-sdk/v2 v2.90.0 h1:clO7kyLNEPl6VCwm74/C/yoFemBjVJPompPgkSQgBoI=
290292
github.com/pulumi/pulumi-azure-native-sdk/v2 v2.90.0/go.mod h1:2IvMmB8/M+RXKlMz330M8BFD+7ChBo7mEWhzpgPAkSc=
293+
github.com/pulumi/pulumi-azure-native-sdk/v3 v3.5.1 h1:XHYZFOa7Oad66z/1OpjGJ5KykQVfxrayroZnt6+1uGA=
294+
github.com/pulumi/pulumi-azure-native-sdk/v3 v3.5.1/go.mod h1:xYRok2u4arAE8Q+j67N1V+mUqYf6ph4TFcV8r6uxbOo=
291295
github.com/pulumi/pulumi-command/sdk v1.1.0 h1:CFCa5B825ZVg2VHoNESnPIQU7QhxXthIfe6EVpR5ohE=
292296
github.com/pulumi/pulumi-command/sdk v1.1.0/go.mod h1:DhLf389o85xzbpu59VEZRxBzzBG9Tv3zMxUW+NA2pq4=
293297
github.com/pulumi/pulumi-docker-build/sdk/go/dockerbuild v0.0.3 h1:NxCXxRvzhUJP9dIvlpNlZKt/A3NHu3i9pC5XO+i8bR0=

pkg/provider/aws/action/eks/eks.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
maptContext "github.com/redhat-developer/mapt/pkg/manager/context"
2222
infra "github.com/redhat-developer/mapt/pkg/provider"
2323
"github.com/redhat-developer/mapt/pkg/provider/aws"
24+
awsConstants "github.com/redhat-developer/mapt/pkg/provider/aws/constants"
2425
"github.com/redhat-developer/mapt/pkg/provider/aws/data"
2526
"github.com/redhat-developer/mapt/pkg/provider/aws/modules/allocation"
2627
network "github.com/redhat-developer/mapt/pkg/provider/aws/modules/network/standard"
@@ -31,7 +32,6 @@ import (
3132
"github.com/redhat-developer/mapt/pkg/util"
3233
"github.com/redhat-developer/mapt/pkg/util/logging"
3334
resourcesUtil "github.com/redhat-developer/mapt/pkg/util/resources"
34-
awsConstants "github.com/redhat-developer/mapt/pkg/provider/aws/constants"
3535
)
3636

3737
type EKSRequest struct {
@@ -82,15 +82,15 @@ func Create(ctx *maptContext.ContextArgs, r *EKSRequest) (err error) {
8282
r.AvailabilityZones = data.GetAvailabilityZones(*r.AllocationData.Region)
8383

8484
cs := manager.Stack{
85-
StackName: maptContext.StackNameByProject(stackName),
86-
ProjectName: maptContext.ProjectName(),
87-
BackedURL: maptContext.BackedURL(),
85+
StackName: maptContext.StackNameByProject(stackName),
86+
ProjectName: maptContext.ProjectName(),
87+
BackedURL: maptContext.BackedURL(),
8888
ProviderCredentials: aws.GetClouProviderCredentials(
8989
map[string]string{
9090
awsConstants.CONFIG_AWS_REGION: *r.AllocationData.Region,
9191
awsConstants.CONFIG_AWS_NATIVE_REGION: *r.AllocationData.Region,
9292
}),
93-
DeployFunc: r.deployer,
93+
DeployFunc: r.deployer,
9494
}
9595

9696
sr, _ := manager.UpStack(cs)

pkg/provider/azure/action/aks/aks.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import (
44
"encoding/base64"
55
"fmt"
66

7-
"github.com/pulumi/pulumi-azure-native-sdk/authorization/v2"
7+
"github.com/pulumi/pulumi-azure-native-sdk/authorization/v3"
88
containerservice "github.com/pulumi/pulumi-azure-native-sdk/containerservice/v2/v20240801"
9-
"github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v2"
10-
"github.com/pulumi/pulumi-azure-native-sdk/resources/v2"
9+
"github.com/pulumi/pulumi-azure-native-sdk/managedidentity/v3"
10+
"github.com/pulumi/pulumi-azure-native-sdk/resources/v3"
1111
"github.com/pulumi/pulumi-tls/sdk/v5/go/tls"
1212
"github.com/pulumi/pulumi/sdk/v3/go/auto"
1313
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
@@ -198,7 +198,7 @@ func (r *AKSRequest) deployer(ctx *pulumi.Context) error {
198198
// grant the 'contributor' role to the identity on the resource group
199199
_, err = authorization.NewRoleAssignment(ctx, "roleAssignment", &authorization.RoleAssignmentArgs{
200200
PrincipalId: identity.PrincipalId,
201-
PrincipalType: pulumi.String("ServicePrincipal"),
201+
PrincipalType: pulumi.String(authorization.PrincipalTypeServicePrincipal),
202202
RoleDefinitionId: pulumi.String("/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"),
203203
Scope: rg.ID(),
204204
})

pkg/provider/azure/action/linux/linux.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package linux
33
import (
44
"fmt"
55

6-
"github.com/pulumi/pulumi-azure-native-sdk/resources/v2"
6+
"github.com/pulumi/pulumi-azure-native-sdk/resources/v3"
77
"github.com/pulumi/pulumi-command/sdk/go/command/remote"
88
"github.com/pulumi/pulumi-tls/sdk/v5/go/tls"
99
"github.com/pulumi/pulumi/sdk/v3/go/auto"
@@ -48,6 +48,7 @@ type LinuxRequest struct {
4848
SpotExcludedRegions []string
4949
GetUserdata func() (string, error)
5050
ReadinessCommand string
51+
Timeout string
5152
}
5253

5354
func Create(ctx *maptContext.ContextArgs, r *LinuxRequest) (err error) {

pkg/provider/azure/action/rhel/rhel.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type Request struct {
2525
Spot bool
2626
SpotTolerance spotAzure.EvictionRate
2727
SpotExcludedRegions []string
28+
Timeout string
2829
}
2930

3031
func Create(ctx *maptContext.ContextArgs, r *Request) (err error) {

0 commit comments

Comments
 (0)