Skip to content

Commit 555f9fa

Browse files
committed
Merge remote-tracking branch 'origin/master' into upgrade-spark-operator-2.1.1
2 parents 835a799 + 00eea86 commit 555f9fa

File tree

4 files changed

+255
-119
lines changed

4 files changed

+255
-119
lines changed

flyteadmin/auth/cookie_manager_test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"time"
1212

1313
"github.com/golang-jwt/jwt/v4"
14+
"github.com/gorilla/securecookie"
1415
"github.com/stretchr/testify/assert"
1516
"github.com/stretchr/testify/require"
1617
"golang.org/x/oauth2"
@@ -285,3 +286,52 @@ func TestCookieManager(t *testing.T) {
285286
assert.Equal(t, "flyte_auth_code", cookies[0].Name)
286287
})
287288
}
289+
290+
func TestExtractAccessTokenFromCookies(t *testing.T) {
291+
hashKeyFromSecret, err := base64.StdEncoding.DecodeString("ODg0K2EybG1IaHJHRUNUcUNsRDB2U3BhRzJIbUREWU1FeXUyYU9maTZ0RnJnYy83bVEzRC9rdTU1ZzRrZ3E3MlFiQ2E1ZmduK2NtTkw1Y2wwaVBsL2c=")
292+
require.NoError(t, err)
293+
blockKeyFromSecret, err := base64.StdEncoding.DecodeString("dkZKaG9ZcUxQSkc3dCt5VUtSWHhGcFBTOWtoNEpBYjgvZk9NeDN1bFN4Zw==")
294+
require.NoError(t, err)
295+
296+
hashKeyEncoded := string(hashKeyFromSecret)
297+
blockKeyEncoded := string(blockKeyFromSecret)
298+
299+
t.Logf("Hash key encoded: %s", hashKeyEncoded)
300+
t.Logf("Block key encoded: %s", blockKeyEncoded)
301+
302+
hashKey, err := base64.RawStdEncoding.DecodeString(hashKeyEncoded)
303+
require.NoError(t, err)
304+
blockKey, err := base64.RawStdEncoding.DecodeString(blockKeyEncoded)
305+
require.NoError(t, err)
306+
307+
t.Logf("Hash key length: %d bytes", len(hashKey))
308+
t.Logf("Block key length: %d bytes", len(blockKey))
309+
310+
cookieValue1 := "MTc2OTczMzU0MnxHd3k2YnUxeXRkT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YTRmWml5c1JieGJ6WTVfM1dBZjQ0eHE5akFMaU4zRVNYdlBnanFUcVh1dnRoQzgtYVg0THU0c2NrcGtiMlFhR001YThqSW4zdXJBenUxc0tLTVlGSnhocWxnbVN3RnJkekF1VGljb09yRUFZZlo4MkpYNElqRHppbEIweE90aU50Qk1jMDhjQk9zSkpLenBNNW9femRuQkZKYzMxeWNtTmU4VzVSamdOT0NIaGJGX1F0UjdOaXRfVzZCM1RSV25OdTI2amY0eDBoeTFydDJOZHl3QVpGSUdjZ1pDNE9IOE1LcVA4MGV3X3VjdWk5NWlYaExnbW9mWEI5U2kwenFIWnZBNFZESnV4UjJxcHpMZ0gtNVZHUm9PY1RDelJCdzlpMC1CTjg0eXRjNlJhcnpKcnhYWTNJejBfQk9Zd25pOC14ZUZOR3BsLWZrT2xzRUJESldlSUp0LWYtdTlDR0hqREZQVHVubENCV3FLU09kTWJKc2h6WHo2Q3BKWlRhVUd1VFZEc2t5QUZ5Z2QwaTFxY09RNklTNWR6VXk4MV85YWRsLXctRnA4dW56bU1lTHhZeFlJMDhvU25UaFptMmVEUEVNMXhPVzRGNERURXRoc2o5LXUxSDY2cmxZT181UUdEWEM0WXNEcHVmb3R3ZWJWZVZKM2xPS0FpN1dQclRJUUE4bFdTQndxNDJnSnRhWUlaRy1sZ2ZqWlFTZXRhUEs2SkE3M0dYR2FIYjlzMjZHRm4zMGd6TlpOYVZ4UzlqeE5rblVONUhtM1pNZ0x1R3lfUU4wUTBoYnNQRi1DODhEWW5ieGZyUGM4ZXpCZEROQ2RZR0R1eEtCZEE9PXyZ83CfdFK3CRERbq2smHnCl-Y_Vj3DcnEObviBKousyA=="
312+
313+
decoded, err := base64.StdEncoding.DecodeString(cookieValue1)
314+
if err == nil {
315+
t.Logf("Cookie 1 raw decoded (first 50 bytes): %s", string(decoded[:50]))
316+
}
317+
s := securecookie.New(hashKey, blockKey)
318+
var firstHalf string
319+
err = s.Decode("flyte_at_1", cookieValue1, &firstHalf)
320+
if err != nil {
321+
t.Logf("Error decoding cookie 1 with MaxAge disabled: %v", err)
322+
s2 := securecookie.New(hashKey, blockKey)
323+
err2 := s2.Decode("flyte_at_1", cookieValue1, &firstHalf)
324+
t.Logf("Error with validation enabled: %v", err2)
325+
}
326+
require.NoError(t, err)
327+
t.Logf("First half of access token: %s", firstHalf)
328+
329+
var secondHalf string
330+
err = s.Decode("flyte_at_2", cookieValue2, &secondHalf)
331+
require.NoError(t, err)
332+
t.Logf("Second half of access token: %s", secondHalf)
333+
334+
fullAccessToken := firstHalf + secondHalf
335+
t.Logf("Full access token: %s", fullAccessToken)
336+
assert.NotEmpty(t, fullAccessToken)
337+
}

flytectl/cmd/core/cmd.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ func generateCommandFunc(cmdEntry CommandEntry) func(cmd *cobra.Command, args []
5858
if config.GetConfig().Domain == "" {
5959
return fmt.Errorf("project and domain are required parameters")
6060
}
61-
fmt.Printf("Using Project: %s, Domain: %s\n", config.GetConfig().Project, config.GetConfig().Domain)
6261
}
6362
if _, err := config.GetConfig().OutputFormat(); err != nil {
6463
return err

flytepropeller/pkg/controller/nodes/dynamic/handler.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,12 @@ func (d dynamicNodeTaskNodeHandler) Abort(ctx context.Context, nCtx interfaces.N
243243
if err != nil {
244244
if stdErrors.IsCausedBy(err, utils.ErrorCodeUser) {
245245
logger.Errorf(ctx, "failed to build dynamic workflow, user error: %s", err)
246+
// If the dynamic workflow cannot be built because of a user error, i.e. malformed dynamic workflow,
247+
// the error is deterministic and there are no nodes that need to be cleaned up as the dynamic worklow
248+
// was never able to launch sub nodes.
249+
// Returning an error on Abort would be treated as a transient system error that is retried as often as the
250+
// system retry budget allows, surfacing the underlying user error only later aftr the system retry budget is exhausted.
251+
return nil
246252
}
247253
return err
248254
}
@@ -277,7 +283,15 @@ func (d dynamicNodeTaskNodeHandler) Finalize(ctx context.Context, nCtx interface
277283
logger.Infof(ctx, "Finalizing dynamic workflow RetryAttempt [%d]", nCtx.CurrentAttempt())
278284
dCtx, err := d.buildContextualDynamicWorkflow(ctx, nCtx)
279285
if err != nil {
280-
errs = append(errs, err)
286+
if !stdErrors.IsCausedBy(err, utils.ErrorCodeUser) {
287+
// If the dynamic workflow cannot be built because of a user error, i.e. malformed dynamic workflow,
288+
// the error is deterministic and there are no nodes that need to be cleaned up as the dynamic worklow
289+
// was never able to launch sub nodes.
290+
// Including the user error in the errors returned by Finalize would cause a transient system error
291+
// that is retried as often as the system retry budget allows, surfacing the underlying user error only
292+
// after the system retry budget is exhausted.
293+
errs = append(errs, err)
294+
}
281295
} else {
282296
if dCtx.isDynamic {
283297
if err := d.nodeExecutor.FinalizeHandler(ctx, dCtx.execContext, dCtx.subWorkflow, dCtx.nodeLookup, dCtx.subWorkflow.StartNode()); err != nil {

0 commit comments

Comments
 (0)