Skip to content

Commit 99a74c5

Browse files
Merge branch 'master' into preemption-retries
2 parents 8ba4635 + 00a4098 commit 99a74c5

Some content is hidden

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

58 files changed

+880
-821
lines changed

.github/workflows/java-client-release-to-maven.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions/checkout@v4
1313

1414
- name: Set up Maven Central Repository
15-
uses: actions/setup-java@c3ac5dd0ed8db40fedb61c32fbe677e6b355e94c
15+
uses: actions/setup-java@v4
1616
with:
1717
java-version: '11'
1818
distribution: 'temurin'
@@ -27,11 +27,8 @@ jobs:
2727

2828
- name: Build
2929
run: |
30-
cp client/java/settings.xml /home/runner/.m2
3130
cd client/java
3231
mvn clean install
33-
env:
34-
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
3532
3633
- name: Release artifacts
3734
run: |

client/java/pom.xml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,12 @@
4646
</developers>
4747

4848
<scm>
49-
<connection>scm:git:git://github.com/armadaproject/java-client.git</connection>
50-
<developerConnection>scm:git:ssh://github.com:armadaproject/java-client.git
51-
</developerConnection>
52-
<url>http://github.com/armadaproject/java-client/tree/main</url>
49+
<connection>scm:git:git://github.com/armadaproject/armada.git</connection>
50+
<developerConnection>scm:git:ssh://github.com:armadaproject/armada.git</developerConnection>
51+
<url>https://github.com/armadaproject/armada/tree/master/client/java</url>
5352
<tag/>
5453
</scm>
5554

56-
<distributionManagement>
57-
<repository>
58-
<id>central</id>
59-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
60-
</repository>
61-
</distributionManagement>
62-
6355
<profiles>
6456
<profile>
6557
<id>local</id>
@@ -297,11 +289,12 @@
297289
<plugin>
298290
<groupId>org.sonatype.central</groupId>
299291
<artifactId>central-publishing-maven-plugin</artifactId>
300-
<version>0.6.0</version>
292+
<version>0.7.0</version>
301293
<extensions>true</extensions>
302294
<configuration>
303295
<publishingServerId>central</publishingServerId>
304296
<autoPublish>true</autoPublish>
297+
<waitUntil>published</waitUntil>
305298
</configuration>
306299
</plugin>
307300

@@ -318,6 +311,12 @@
318311
</goals>
319312
</execution>
320313
</executions>
314+
<configuration>
315+
<gpgArguments>
316+
<arg>--pinentry-mode</arg>
317+
<arg>loopback</arg>
318+
</gpgArguments>
319+
</configuration>
321320
</plugin>
322321

323322
<!-- generate java sources from proto -->

client/java/settings.xml

Lines changed: 0 additions & 24 deletions
This file was deleted.

client/scala/armada-scala-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>io.armadaproject</groupId>
44
<artifactId>armada-scala-client_2.13</artifactId>
5-
<version>0.1.0-SNAPSHOT</version>
5+
<version>0.2.0-SNAPSHOT</version>
66
<name>Armada Scala Client</name>
77
<description>A Scala client for Armada.</description>
88
<inceptionYear>2025</inceptionYear>

config/lookout/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
apiPort: 10000
22
metricsPort: 9003
3+
auth:
4+
anonymousAuth: true
35
corsAllowedOrigins:
46
- "http://localhost:3000"
57
- "http://localhost:8089"

internal/lookout/application.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
package lookout
44

55
import (
6+
"fmt"
7+
68
"github.com/IBM/pgxpoolprometheus"
79
"github.com/go-openapi/loads"
810
"github.com/go-openapi/runtime/middleware"
@@ -11,6 +13,7 @@ import (
1113

1214
"github.com/armadaproject/armada/internal/common"
1315
"github.com/armadaproject/armada/internal/common/armadacontext"
16+
"github.com/armadaproject/armada/internal/common/auth"
1417
"github.com/armadaproject/armada/internal/common/compress"
1518
"github.com/armadaproject/armada/internal/common/database"
1619
"github.com/armadaproject/armada/internal/common/logging"
@@ -174,6 +177,12 @@ func Serve(configuration configuration.LookoutConfig) error {
174177
server.Port = configuration.ApiPort
175178
}
176179

180+
authServices, err := auth.ConfigureAuth(configuration.Auth)
181+
if err != nil {
182+
return fmt.Errorf("creating auth services: %w", err)
183+
}
184+
185+
restapi.SetAuthService(auth.NewMultiAuthService(authServices))
177186
restapi.SetCorsAllowedOrigins(configuration.CorsAllowedOrigins) // This needs to happen before ConfigureAPI
178187
server.ConfigureAPI()
179188
if err := server.Serve(); err != nil {

internal/lookout/configuration/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ package configuration
33
import (
44
"time"
55

6+
authconfig "github.com/armadaproject/armada/internal/common/auth/configuration"
67
profilingconfig "github.com/armadaproject/armada/internal/common/profiling/configuration"
78
"github.com/armadaproject/armada/internal/server/configuration"
89
)
910

1011
type LookoutConfig struct {
12+
Auth authconfig.AuthConfig
13+
1114
ApiPort int
1215
Profiling *profilingconfig.ProfilingConfig
1316
MetricsPort int

internal/lookout/gen/restapi/configure_lookout.go

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/go-openapi/runtime/middleware"
1515
"golang.org/x/exp/slices"
1616

17+
"github.com/armadaproject/armada/internal/common/auth"
1718
"github.com/armadaproject/armada/internal/common/serve"
1819
"github.com/armadaproject/armada/internal/lookout/configuration"
1920
"github.com/armadaproject/armada/internal/lookout/gen/restapi/operations"
@@ -28,6 +29,12 @@ func SetCorsAllowedOrigins(allowedOrigins []string) {
2829
corsAllowedOrigins = allowedOrigins
2930
}
3031

32+
var authService auth.AuthService
33+
34+
func SetAuthService(s auth.AuthService) {
35+
authService = s
36+
}
37+
3138
func configureFlags(api *operations.LookoutAPI) {
3239
// api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... }
3340
}
@@ -91,7 +98,33 @@ var UIConfig configuration.UIConfig
9198
// The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document.
9299
// So this is a good place to plug in a panic handling middleware, logging and metrics.
93100
func setupGlobalMiddleware(apiHandler http.Handler) http.Handler {
94-
return recordRequestDuration(allowCORS(uiHandler(apiHandler), corsAllowedOrigins))
101+
return allowCORS(
102+
uiHandler(
103+
authHandler(
104+
recordRequestDuration(
105+
apiHandler,
106+
),
107+
),
108+
), corsAllowedOrigins)
109+
}
110+
111+
func authHandler(handler http.Handler) http.Handler {
112+
mux := http.NewServeMux()
113+
114+
// do not authenticate requests to healthchecker endpoint
115+
mux.Handle("/health", handler)
116+
117+
authFunction := auth.CreateHttpMiddlewareAuthFunction(authService)
118+
mux.Handle("/api/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
119+
ctxWithPrincipal, err := authFunction(w, r)
120+
if err != nil {
121+
return
122+
}
123+
124+
handler.ServeHTTP(w, r.WithContext(ctxWithPrincipal))
125+
}))
126+
127+
return mux
95128
}
96129

97130
func uiHandler(apiHandler http.Handler) http.Handler {
@@ -128,13 +161,11 @@ func allowCORS(handler http.Handler, corsAllowedOrigins []string) http.Handler {
128161

129162
func recordRequestDuration(handler http.Handler) http.Handler {
130163
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
131-
// TODO: for autheticated users, record the username
132-
const unknownUser = "unknown"
133164
start := time.Now()
134165
handler.ServeHTTP(w, r)
135166
duration := time.Since(start)
136167
if strings.HasPrefix(r.URL.Path, "/api/v1/") {
137-
metrics.RecordRequestDuration(unknownUser, r.URL.Path, float64(duration.Milliseconds()))
168+
metrics.RecordRequestDuration(auth.GetPrincipal(r.Context()).GetName(), r.URL.Path, float64(duration.Milliseconds()))
138169
}
139170
})
140171
}

internal/lookout/repository/getjobs.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"k8s.io/utils/clock"
1010

1111
"github.com/armadaproject/armada/internal/common/armadacontext"
12+
"github.com/armadaproject/armada/internal/common/auth"
1213
"github.com/armadaproject/armada/internal/common/database"
1314
"github.com/armadaproject/armada/internal/common/database/lookout"
1415
"github.com/armadaproject/armada/internal/lookout/model"
@@ -63,21 +64,22 @@ func (r *SqlGetJobsRepository) GetJobs(ctx *armadacontext.Context, filters []*mo
6364
}
6465

6566
func (r *SqlGetJobsRepository) getJobs(ctx *armadacontext.Context, filters []*model.Filter, activeJobSets bool, order *model.Order, skip int, take int) (*GetJobsResult, error) {
67+
user := auth.GetPrincipal(ctx).GetName()
6668
query, err := NewQueryBuilder(r.lookoutTables).GetJobs(filters, activeJobSets, order, skip, take)
6769
if err != nil {
6870
return nil, err
6971
}
70-
logQueryDebug(query, "GetJobs")
72+
logQueryDebug(user, query, "GetJobs")
7173
var jobs []*model.Job
7274

7375
queryStart := time.Now()
7476
rows, err := r.db.Query(ctx, query.Sql, query.Args...)
7577
queryDuration := time.Since(queryStart)
7678
if err != nil {
77-
logQueryError(query, "GetJobs", queryDuration)
79+
logQueryError(user, query, "GetJobs", queryDuration)
7880
return nil, err
7981
}
80-
logSlowQuery(query, "GetJobs", queryDuration)
82+
logSlowQuery(user, query, "GetJobs", queryDuration)
8183

8284
defer rows.Close()
8385
for rows.Next() {

internal/lookout/repository/groupjobs.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/pkg/errors"
1111

1212
"github.com/armadaproject/armada/internal/common/armadacontext"
13+
"github.com/armadaproject/armada/internal/common/auth"
1314
"github.com/armadaproject/armada/internal/common/slices"
1415
"github.com/armadaproject/armada/internal/lookout/model"
1516
)
@@ -54,22 +55,24 @@ func (r *SqlGroupJobsRepository) GroupBy(
5455
skip int,
5556
take int,
5657
) (*GroupByResult, error) {
58+
user := auth.GetPrincipal(ctx).GetName()
59+
5760
query, err := NewQueryBuilder(r.lookoutTables).GroupBy(filters, activeJobSets, order, groupedField, aggregates, skip, take)
5861
if err != nil {
5962
return nil, err
6063
}
61-
logQueryDebug(query, "GroupBy")
64+
logQueryDebug(user, query, "GroupBy")
6265

6366
var groups []*model.JobGroup
6467

6568
queryStart := time.Now()
6669
groupRows, err := r.db.Query(ctx, query.Sql, query.Args...)
6770
queryDuration := time.Since(queryStart)
6871
if err != nil {
69-
logQueryError(query, "GroupBy", queryDuration)
72+
logQueryError(user, query, "GroupBy", queryDuration)
7073
return nil, err
7174
}
72-
logSlowQuery(query, "GroupBy", queryDuration)
75+
logSlowQuery(user, query, "GroupBy", queryDuration)
7376

7477
groups, err = rowsToGroups(groupRows, groupedField, aggregates, filters)
7578
if err != nil {

0 commit comments

Comments
 (0)